-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBossGoblin.cpp
More file actions
91 lines (73 loc) · 2.24 KB
/
BossGoblin.cpp
File metadata and controls
91 lines (73 loc) · 2.24 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// Created by segalle on 11/23/21.
//
#include "BossGoblin.h"
namespace entities{
namespace characters{
BossGoblin::BossGoblin() : Enemy(),
attack_counter(0),
jump_counter(0){
sprite = assets->getSprite("bossGoblin");
setId(boss_goblin_id);
}
BossGoblin::~BossGoblin() {}
void BossGoblin::attack() {
p_position = player->getPosition();
fire = new EnergyOrb();
fire->setDamage(projectile_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 BossGoblin::run() {
if(attack_counter >= attack_speed) {
attack();
attack_counter = 0;
}
attack_counter++;
if(jump_counter >= jump_speed) {
jump();
jump_counter = 0;
}
jump_counter++;
walk();
}
void BossGoblin::walk(){
p_position = player->getPosition();
if(p_position.x + 50 > position.x){
position.x += walk_speed;
}
else{
position.x -= walk_speed;
}
fall();
position.y += speed.y;
}
int BossGoblin::getCollisionDamage() {
if(attack_counter > attack_speed) {
attack_counter = 0;
return collision_damage;
}
return 0;
}
Entity* BossGoblin::getProjectile() {
Entity* aux = static_cast <Entity*> (fire);
fire = nullptr;
return aux;
}
void BossGoblin::jump(){
speed.y = jump_height;
ground = false;
}
int BossGoblin::projectile_damage = 40;
int BossGoblin::collision_damage = 70;
int BossGoblin::attack_speed = 976;
float BossGoblin::walk_speed = 0.35;
float BossGoblin::jump_speed = 288;
float BossGoblin::jump_height = -10;
}
}