-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemy.cc
79 lines (60 loc) · 1.55 KB
/
Enemy.cc
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
#include "Enemy.hh"
using namespace std;
Enemy::Enemy()
{
vida = 100;
attacking = false;
}
Enemy::Enemy(sf::Sprite sprite, int hp)
{
vida = hp;
this->sprite = sprite;
attacking = false;
this->sprite.setOrigin(50, 50);
this->sprite.setScale(0.2f, 0.2f);
}
void Enemy::setPosition(float x, float y) {
sprite.setPosition(x, y);
}
sf::Texture &Enemy::getTexture() {
return texture;
}
void Enemy::take_damage(int hit_points) {
vida -= hit_points;
if (vida <= 0)
sprite.setPosition(sf::Vector2f(-1000.0f, -1000.0f)); // sep
}
// void Enemy::move(double seconds) {
// if (is_VERT) {
// if (sprite.getRotation() == 90) {
// sprite.setRotation(0);
// }
// else {
// sprite.setRotation(270);
// }
// }
// else {
// if (sprite.getRotation() == 90) {
// if(seconds == 0.0) sprite.setRotation(180);
// pos.first -= 1;
// sprite.setPosition(pos.first, pos.second);
// }
// else {
// if(seconds == 0.0) sprite.setRotation(90);
// pos.first += 1;
// sprite.setPosition(pos.first, pos.second);
// }
// }
// }
void Enemy::attack() {
player.take_damage(10);
}
int Enemy::getVida() {
return vida;
}
pair <int, int> Enemy::getPos() {
return pos;
}
void Enemy::draw(sf::RenderWindow &window) {
window.draw(sprite);
}