-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovingEntity.cpp
More file actions
56 lines (42 loc) · 1.05 KB
/
MovingEntity.cpp
File metadata and controls
56 lines (42 loc) · 1.05 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
//
// Created by segalle on 08/11/2021.
//
#include "MovingEntity.h"
namespace entities {
namespace characters {
MovingEntity::MovingEntity() :
Entity(),
fire(nullptr),
health(100),
speed(0, 0),
ground(false){}
MovingEntity::~MovingEntity() {}
void MovingEntity::takeDamage(int dmg) {
health -= dmg;
}
int MovingEntity::getHealth() {
return health;
}
void MovingEntity::fall() {
if(ground){
speed.y = 0;
}
else{
speed.y += gravity;
}
}
void MovingEntity::setGround(bool on_ground) {
ground = on_ground;
if (ground) {
speed.y = 0;
}
}
void MovingEntity::setFallSpeed(float speed) {
this->speed.y = speed;
}
void MovingEntity::setHealth(int health) {
this->health = health;
}
float MovingEntity::gravity = 0.2;
}
}