-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplane.cpp
More file actions
46 lines (39 loc) · 825 Bytes
/
plane.cpp
File metadata and controls
46 lines (39 loc) · 825 Bytes
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
#include "plane.h"
Plane::Plane()
{
// Load Image
m_Plane.load(PLANE_PATH);
// Init Pos
m_X = WINDOW_W * 0.5 - m_Plane.width()*0.5;
m_Y = WINDOW_H - m_Plane.height();
// Rect
m_Rect.setWidth(m_Plane.width());
m_Rect.setHeight(m_Plane.height());
m_Rect.moveTo(m_X,m_Y);
m_recorder = 0;
}
void Plane::setPosition(int x, int y)
{
m_X = x;
m_Y = y;
m_Rect.moveTo(m_X,m_Y);
}
void Plane::shoot()
{
m_recorder++;
if(m_recorder < BULLET_INTERVAL)
{
return;
}
m_recorder = 0;
for(int i = 0 ; i < BULLET_NUM;i++)
{
if(m_bullets[i].m_Free)
{
m_bullets[i].m_Free = false;
m_bullets[i].m_X = m_X + m_Rect.width()*0.5 - 10;
m_bullets[i].m_Y = m_Y - 25 ;
break;
}
}
}