-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
executable file
·36 lines (28 loc) · 825 Bytes
/
Bullet.cpp
File metadata and controls
executable file
·36 lines (28 loc) · 825 Bytes
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
/*
Made with ❤ by srinSkit.
Created on 11 April 2018.
*/
#include "Bullet.h"
#include "Common.h"
#include <cmath>
const int Bullet::v = 8;
Bullet::Bullet(int localOriginX, int localOriginY, bool isStaticModel, bool hide)
: Model(localOriginX, localOriginY, isStaticModel, hide) {
vx = 0, vy = 0, theta = 0;
health = 1;
}
void Bullet::launch(int theta, int x, int y) {
this->x = static_cast<GLint>(x + 70 * -sin(RADIAN(theta)));
this->y = static_cast<GLint>(y + 70 * cos(RADIAN(theta)));
this->theta = theta;
vx = static_cast<int>(Bullet::v * -sin(RADIAN(theta)));
vy = static_cast<int>(Bullet::v * cos(RADIAN(theta)));
hide = false;
}
void Bullet::update() {
x += vx;
y += vy;
if (!insideView(x, y))
destroy();
}
Element *bulletElement = nullptr;