-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovingEntity.cpp
40 lines (30 loc) · 881 Bytes
/
MovingEntity.cpp
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
#include "MovingEntity.h"
MovingEntity::MovingEntity(void)
{
velocity = glm::vec2();
}
MovingEntity::~MovingEntity(void)
{
}
//------------------------------------------------SET ----------------------------------------------//
void MovingEntity::setVelocity(glm::vec2 velocityIn)
{
velocity = velocityIn;
}
//------------------------------------------------GET ----------------------------------------------//
glm::vec2 MovingEntity::getVelocity(void)
{
return velocity;
}
//------------------------------------------------UPDATE -------------------------------------------//
void MovingEntity::updatePosition(void)
{
position.x += velocity.x;
position.y += velocity.y;
for (Entity* child : children)
{
MovingEntity* movingChild = dynamic_cast<MovingEntity*> (child); // Null if not CircleShape
if(movingChild != NULL)
movingChild->updatePosition();
}
}