-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.cpp
More file actions
56 lines (45 loc) · 1.11 KB
/
Enemy.cpp
File metadata and controls
56 lines (45 loc) · 1.11 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
#include "Enemy.hpp"
#include "Items.hpp"
#include "Dijkstra.hpp"
#include <iostream>
const glm::vec2& Enemy::get_pos() {
return this->position;
}
const glm::vec2& Enemy::get_vel() {
return this->velocity;
}
const glm::u8vec4& Enemy::get_color() {
return this->color;
}
void Enemy::set_vel(glm::vec2 &vel) {
this->velocity = vel;
}
float Enemy::get_hp() {
return this->hp;
}
float Enemy::distance(const glm::vec2 &player_pos) {
return glm::distance(this->position, player_pos);
}
float Enemy::get_width() {
return this->width;
}
Sprite* Enemy::get_sprite() {
return this->s;
}
void Enemy::on_hit(Bullet* b) {
this->hp -= b->get_damage();
}
void Enemy::set_boss() {
this->is_boss = true;
}
void Enemy::draw(glm::vec2 camera_center, glm::vec2 size, std::vector<Vertex> &vertices) {
if(moving) {
//TODO: fix elapsed calculations
float anim_duration = *(anim.durations.rbegin());
anim_elapsed -= floorf(anim_elapsed / anim_duration) * anim_duration;
anim.draw(anim_elapsed, camera_center, position, size, 0.f, color, vertices);
}
else {
s->draw(camera_center, position, size, 0, color, vertices);
}
}