-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeakGoblin.cpp
More file actions
58 lines (46 loc) · 1.37 KB
/
WeakGoblin.cpp
File metadata and controls
58 lines (46 loc) · 1.37 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
//
// Created by segalle on 11/21/21.
//
#include "WeakGoblin.h"
namespace entities{
namespace characters{
WeakGoblin::WeakGoblin() : Enemy(),
attack_counter(0){
assets->getSprite("weakGoblin");
setId(weak_goblin_id);
health = 30;
}
WeakGoblin::~WeakGoblin() {}
void WeakGoblin::attack() {
p_position = player->getPosition();
fire = new DarkEnergyOrb();
fire->setDamage(damage);
fire->setPosition(position.x + sprite->getGlobalBounds().width/2 - 20, position.y + sprite->getGlobalBounds().height/2);
if (position.x> p_position.x){
fire->setDirection(-1);
}
else{
fire->setDirection(1);
}
}
void WeakGoblin::run() {
if(attack_counter >= attack_speed) {
attack();
attack_counter = 0;
}
attack_counter++;
fall();
position.y += speed.y;
}
int WeakGoblin::getCollisionDamage() {
return 0;
}
Entity *WeakGoblin::getProjectile() {
Entity* aux = static_cast <Entity*> (fire);
fire = nullptr;
return aux;
}
int WeakGoblin::attack_speed = 288;
int WeakGoblin::damage = 5;
}
}