-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShip_Shooter.h
111 lines (83 loc) · 1.91 KB
/
Ship_Shooter.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
extern Gamebuino gb;
extern const byte font3x5[];
extern const int PLAYER;
extern const int ALIEN;
extern const byte SHIP[];
extern const byte CLOUD_BIG[];
extern const byte CLOUD_MEDIUM[];
extern const byte CLOUD_SMALL[];
extern const byte BULLET[];
extern const byte ALIEN_1[];
extern const byte ALIEN_2[];
extern const byte ALIEN_3[];
class clouds{
private:
int pos_x = random(LCDWIDTH, LCDWIDTH * 2);
int pos_y = random(-5, LCDHEIGHT + 10);
int rotation = random(0, 4);
int flip = random(0, 4);
byte * cloud;
int speed = 2;
public:
clouds(int type);
void move_cloud(){
if(gb.frameCount % 2)
pos_x -= speed;
}
bool cloud_out(){
return pos_x < -40 ? true: false;
}
void draw_cloud();
};
class bullet{
private:
int pos_x;
int pos_y;
int whose_bullet; //1 - PLAYER; 2 - ALIEN
int bullet_speed = 2;
public:
bullet(int x, int y, int who_fires);
int get_x(){
return pos_x;
}
int get_y(){
return pos_y;
}
void move_bullet(){
whose_bullet == PLAYER ? pos_x += bullet_speed : pos_x -= bullet_speed;
}
void draw_bullet(){
gb.display.drawBitmap(pos_x, pos_y, BULLET);
}
bool bullet_out(); //checks if bullet is out of screen
};
class aliens{
private:
int type;
int pos_x;
int pos_y;
int speed;
int point_value;
byte * alien;
int bullet_speed;
int life;
//used in type 3
bool bounce;
int line; //random; after alien reaches top or bottom line this will be reduced with every move. After 0 alien goes only forward
public:
aliens(int type);
void move_alien();
void display_alien(){
gb.display.drawBitmap(pos_x, pos_y, alien);
}
bool alien_out(){
return pos_x < -10 ? true : false;
}
bullet *alien_fire(){
return new bullet(pos_x, pos_y, ALIEN);
}
bool alien_collision(int bullet_x, int bullet_y, bullet ** ptr_bullet_obj, int &score);
bool alien_collision(int bullet_x, int bullet_y){
return gb.collideBitmapBitmap(bullet_x, bullet_y, BULLET, pos_x, pos_y, alien);
}
};