-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bullet.cpp
82 lines (77 loc) · 1.43 KB
/
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "Bullet.h"
using namespace std;
Bullet::Bullet()
{
x_speed=0;
y_speed=0;
is_move=false;
angle=0;
type=1;
starting_point=0;
CurrentTime = 0;
LastTime = 0;
}
Bullet::~Bullet()
{
}
void Bullet::HandleMove(const int &x_border,const int &y_border)
{
if(type == 1 )
{
x_pos+=x_speed*cos(angle*PI/180);
y_pos+=(y_speed)*sin(angle*PI/180);
}
else if(type == 3)
{
x_pos+=x_speed*cos(angle*PI/180);
y_pos+=(y_speed)*sin(angle*PI/180);
angle+=30;
}
else if(type == 4)
{
x_pos+=x_speed*cos(angle*PI/180);
y_pos+=(y_speed)*sin(angle*PI/180);
}
else if (type == 5)
{
x_pos-=1;
y_pos = y_pos + cos(x_pos*PI/200);
}
else if (type == 6)
{
x_pos-=1;
y_pos = y_pos + cos(x_pos*PI/200);
}
else if(type == 8)
{
x_pos += x_speed*cos(angle*PI/180);;
y_pos += 0.5* sin (angle*PI/180);
}
else if( type == 9)
{
x_pos += x_speed*sin(angle*PI/180);;
y_pos += 0.5*cos(angle*PI/180);
}
// type này của spaceship
else if(type == 10)
{
x_pos+= 7;
y_pos-=1;
}
else if(type == 11)
{
x_pos+= 7;
y_pos+=1;
}
//
if(y_pos<0 || y_pos>y_border)
{
is_move=false;
}
if(x_pos<0 || x_pos>x_border)
{
is_move=false;
}
Rect.x=x_pos;
Rect.y=y_pos;
}