-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentity.cpp
More file actions
77 lines (62 loc) · 1.16 KB
/
Copy pathentity.cpp
File metadata and controls
77 lines (62 loc) · 1.16 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
#include "entity.h"
Entity::Entity(int posx, int posy, int speed) :
defaultPosx(posx),
defaultPosy(posy)
{
this->posx = posx;
this->posy = posy;
this->speed = speed;
this->state = 0;
setMoving(false);
resetOrientation();
}
QRectF Entity::boundingRect() const
{
return QRect(0,0,charW,charH);
}
int Entity::getPosx() const
{
return posx;
}
void Entity::setPosx(int x)
{
posx = x;
}
int Entity::getPosy() const
{
return posy;
}
void Entity::setPosy(int y)
{
posy = y;
}
int Entity::getSpeed() const
{
return speed;
}
bool Entity::isMoving() const
{
return moving;
}
void Entity::setMoving(bool value)
{
moving = value;
}
void Entity::resetOrientation()
{
// By default any Entity faces right
facingDirection = Direction::RIGHT;
direction = Direction::NONE;
nextDirection = Direction::NONE; // Default NONE since Entity has not decided on next movement at this point
moving = false;
state = 0; // Resets animation
}
void Entity::setDefaultPosition()
{
setPosx(defaultPosx);
setPosy(defaultPosy);
}
void Entity::advanceAnimation()
{
state++;
}