-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbomb.cpp
54 lines (43 loc) · 1.14 KB
/
bomb.cpp
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
/*
* File: bomb.cpp
* Author: 2019202344
*
* Created on 6 de Dezembro de 2019, 15:50
*/
#include "bomb.h"
#include "player.h"
#include "cube.h"
#include "enemybase.h"
float bomb_t::sGravityAcceleration = -10;
wf_object_t* bomb_t::sBombModel = NULL;
void bomb_t::init(wf_object_loader_t& loader) {
sBombModel = loader.loadRes("presente");
}
bomb_t::bomb_t(const point3f& offset, const vector3f& velocity, float h) :
projectile_t(offset, velocity), horizontal(h) {
}
void bomb_t::move(float time) {
projectile_t::move(time);
getVelocity().z += time * sGravityAcceleration;
}
void bomb_t::hit(obstacle_t* other) {
printf("A bomb hit an obstacle\n");
projectile_t::hit(other);
if (enemy_base_t * base = dynamic_cast<enemy_base_t*> (other)) {
printf("The bomb fell onto a base\n");
base->kill();
}
}
void bomb_t::setGravityAcceleration(float acc) {
bomb_t::sGravityAcceleration = acc;
}
void bomb_t::draw() const {
// TODO Draw bomb model
glRotatef(horizontal, 0, 0, 1);
glRotatef(90, 1, 0, 0);
if (sBombModel == NULL) {
drawCube();
} else {
sBombModel->draw();
}
}