-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bullet.cpp
65 lines (44 loc) · 1019 Bytes
/
Bullet.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
54
55
56
57
58
59
60
61
62
63
64
65
#include "Bullet.h"
Bullet::Bullet(TextureAPI bulletTexture, double x, double y, int vel, double angle) {
this->bulletTexture = bulletTexture;
mPosX = x;
mPosY = y;
this->angle = angle;
}
Bullet::~Bullet() {
}
void Bullet::render(SDL_Renderer *renderer, double angle ) {
bulletTexture.render(renderer, mPosX, mPosY, NULL, angle);
}
void Bullet::free() {
bulletTexture.free();
}
double Bullet::getX() {
return mPosX;
}
double Bullet::getY() {
return mPosY;
}
void Bullet::setX(double x) {
mPosX = x;
}
void Bullet::setY(double y) {
mPosY = y;
}
double Bullet::getAngle() {
return angle;
}
void Bullet::setAngle(double angle) {
this->angle = angle;
}
int Bullet::getBulletRadius() {
return BULLET_RADIUS;
}
bool Bullet::isCollision(double centerX, double centerY, int radius) {
double d = (centerX - (mPosX+7))*(centerX - (mPosX+7)) + (centerY - (mPosY+7))*(centerY - (mPosY+7));
if (d > (BULLET_RADIUS + radius)*(BULLET_RADIUS + radius)) {
return false;
}else {
return true;
}
}