-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.cpp
More file actions
101 lines (79 loc) · 1.7 KB
/
GameObject.cpp
File metadata and controls
101 lines (79 loc) · 1.7 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "GameObject.h"
#include "Messages_defs.h"
GameObject::GameObject() :
GameObject(nullptr) {
}
GameObject::GameObject(SDLGame* game) :
game_(game),
active_(true),
width_(),
height_(),
position_(),
velocity_(),
acceleration_(0, 0),
rotation_(0.0) {
}
GameObject::~GameObject() {
}
SDLGame* GameObject::getGame() const {
return game_;
}
void GameObject::setGame(SDLGame* game) {
game_ = game;
}
bool GameObject::isActive() const {
return active_;
}
void GameObject::setActive(bool active) {
active_ = active;
}
bool GameObject::toggleActive() {
active_ = !active_;
return active_;
}
double GameObject::getWidth() const {
return width_;
}
void GameObject::setWidth(double width) {
width_ = width;
}
double GameObject::getHeight() const {
return height_;
}
void GameObject::setHeight(double height) {
height_ = height;
}
Vector2D GameObject::getPosition() const {
return position_;
}
void GameObject::setPosition(const Vector2D &pos) {
position_.set(pos);
}
Vector2D GameObject::getVelocity() const {
return velocity_;
}
void GameObject::setVelocity(const Vector2D &vel) {
velocity_.set(vel);
}
Vector2D GameObject::getAcceleration() const {
return acceleration_;
}
void GameObject::scale(double s) {
width_ *= s;
height_ *= s;
}
void GameObject::setAcceleration(const Vector2D &vel) {
acceleration_.set(vel);
}
double GameObject::getRotation() const {
return rotation_;
}
void GameObject::setRotation(double angle) {
rotation_ = fmod(angle, 360.0);
}
void GameObject::receive(const void* senderObj, const msg::Message& msg) {
// By default objects do no do anything when receiving a message.
// Only those interested will implement this method
}
void GameObject::init() {
}