-
Notifications
You must be signed in to change notification settings - Fork 0
/
bullet.h
65 lines (41 loc) · 1.25 KB
/
bullet.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
#include "SDL/SDL.h"
class Bullet:public Character{
private:
bool condition;
public:
Bullet(int x, int y, bool cond){
lives=1;
faceright=false; //ambil y baris pertama
count=0; // 0-3
box.x=x;
box.y=y;
box.w=32;
box.h=32;
condition=cond;
//condition=rand()%2;
loadSprite("./images/bullet.bmp");
}
~Bullet(){
}
void set_condition(bool x){condition=x;}
bool get_condition(){return condition;}
void set_x(int x){box.x=x;}
int get_x(){return box.x;}
void set_y(int y){box.y=y;}
int get_y(){return box.y;}
void moveLeft(){
box.x-=velx;
count++;
if (count>3) count=0;
}
void moveRight(){
box.x+=velx;
count++;
if (count>3) count=0;
}
void move(){
if (condition==0){
moveLeft();
}else moveRight();
}
};