-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentity.cpp
More file actions
71 lines (64 loc) · 1.68 KB
/
Copy pathentity.cpp
File metadata and controls
71 lines (64 loc) · 1.68 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
#include "entity.h"
#include "shape.h"
#include "coordinate.h"
Entity::Entity(Coordinate c_position, float c_half_size, float c_x_speed, float c_y_speed) : position(c_position), half_size(c_half_size), x_speed(c_x_speed), y_speed(c_y_speed) {};
// getters
Coordinate Entity::getPosition() const {
return position;
}
float Entity::getHalfSize() const {
return half_size;
}
float Entity::getXSpeed() const {
return x_speed;
}
float Entity::getYSpeed() const {
return y_speed;
}
float Entity::getXAcceleration() const {
return x_acceleration;
}
float Entity::getYAcceleration() const {
return y_acceleration;
}
std::vector<Shape> Entity::getShapes() const {
return shapes;
}
// setters
void Entity::setPosition(Coordinate new_position) {
position = new_position;
}
void Entity::setHalfSize(float new_half_size) {
half_size = new_half_size;
}
void Entity::setXSpeed(float new_x_speed) {
x_speed = new_x_speed;
}
void Entity::setYSpeed(float new_y_speed) {
y_speed = new_y_speed;
}
void Entity::setXAcceleration(float new_x_acceleration) {
x_acceleration = new_x_acceleration;
}
void Entity::setYAcceleration(float new_y_acceleration) {
y_acceleration = new_y_acceleration;
}
void Entity::setShapes(std::vector<Shape> new_shapes) {
shapes = new_shapes;
}
// others
void Entity::updatePosition() {
for (Shape shape : shapes) {
for (Coordinate coord : shape.getCoords()) {
coord.setX(coord.getX() + x_speed);
coord.setY(coord.getY() + y_speed);
}
}
position.setX(position.getX() + x_speed);
position.setY(position.getY() + y_speed);
}
void Entity::drawEntity() {
for (Shape shape : shapes) {
shape.drawShape();
}
}