-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeroPlane.cpp
More file actions
47 lines (41 loc) · 1.02 KB
/
Copy pathHeroPlane.cpp
File metadata and controls
47 lines (41 loc) · 1.02 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
//
// Created by 熊志耀 on 2022/1/9.
//
#include "HeroPlane.h"
#include "config.h"
HeroPlane::HeroPlane() {
m_Plane.load(HERO_PATH);
m_X = GAME_WIDTH*0.5 - m_Plane.width()*0.5;
m_Y = GAME_HEIGHT - m_Plane.height();
//初始化边框
m_Rect.setWidth(m_Plane.width());
m_Rect.setHeight(m_Plane.height());
m_Rect.moveTo(m_X, m_Y);
m_recoder = 0;
}
void HeroPlane::setPosition(int x, int y) {
m_X = x;
m_Y = y;
m_Rect.moveTo(m_X, m_Y);
}
void HeroPlane::shoot() {
//累加时间间隔记录变量
m_recoder++;
//如果记录的数字未达到发射间隔,直接return
if(m_recoder < BULLET_INTERVAL)
{
return;
}
//到达法身事件,重制发射记录
m_recoder= 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;
}
}
}