-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamestate.h
58 lines (47 loc) · 1.07 KB
/
gamestate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include "tube/simple_continuous.h"
#include "tube/simple_discrete.h"
#include "tube/object.h"
#include "vertex.h"
namespace openage {
namespace tubepong {
struct event {
int player;
enum state_e {
UP, DOWN, START, IDLE, LOST
} state;
event(int id, state_e s) : player(id), state(s) {}
event() : player(0), state(IDLE) {}
};
class PongPlayer : public tube::TubeObject {
public:
PongPlayer() {
speed.set_drop(0, 1);
position.set_drop(0, 0.5);
lives.set_drop(0, 1);
state.set_drop(0, event(0, event::IDLE));
size.set_drop(0, 0.1);
y = 0;
id = 0;
}
tube::SimpleDiscrete<float> speed;
tube::SimpleContinuous<float> position;
tube::SimpleDiscrete<int> lives;
tube::SimpleDiscrete<event> state;
tube::SimpleDiscrete<float> size;
float y;
int id;
};
class PongBall : public tube::TubeObject {
public:
tube::SimpleDiscrete<util::vertex<2, float> > speed;
tube::SimpleContinuous<util::vertex<2, float> > position;
};
class PongState {
public:
PongPlayer p1;
PongPlayer p2;
PongBall ball;
util::vertex<2, int> resolution;
};
}} // openage::tubepong