-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
67 lines (52 loc) · 1.6 KB
/
Bullet.cpp
File metadata and controls
67 lines (52 loc) · 1.6 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
57
58
59
60
61
62
63
64
65
66
67
#include "Bullet.h"
Bullet::Bullet(double x, double y, double incX, double incY):DrawObject(x,y,2),incX(incX),incY(incY),readyToDelete(false){};
//***********************************************
// OTHER FUNCTIONS
//***********************************************
void Bullet::update(){
calcPos();
};
void Bullet::calcPos(){
X += incX * vel;
Y += incY * vel;
if(outOfBoundaries()) readyToDelete = true;
};
void Bullet::drawShadow() const{
double correctedX = X - CAMERA->getX();
double correctedY = Y - CAMERA->getY();
//GRAPHIC
circlefill(CANVAS, (int)correctedX+8, (int)correctedY+8, size+2, makecol(0,0,20));
};
void Bullet::draw() const{
double correctedX = X - CAMERA->getX();
double correctedY = Y - CAMERA->getY();
//GRAPHIC
circlefill(CANVAS, (int)correctedX-2, (int)correctedY-2, size, makecol(255,0,0));
circlefill(CANVAS, (int)correctedX-2, (int)correctedY-2, size-1, makecol(255,200,200));
};
bool Bullet::isReadyToDelete() const {
return readyToDelete;
};
bool Bullet::outOfBoundaries() const{
if(X < leftLimit || X > rightLimit || Y < upperLimit || Y > bottomLimit){
return true;
}
return false;
};
void Bullet::dispose(){
readyToDelete = true;
};
//***********************************************
// OPERATOR OVERLOADS
//***********************************************
void Bullet::operator=(const Bullet &Bullet2){
X = Bullet2.X;
Y = Bullet2.Y;
};
bool Bullet::operator==(const Bullet &Bullet2) const {
if (X == Bullet2.getX() && Y == Bullet2.getY()){
return true;
}else{
return false;
}
};