forked from ZhouBox/air_plane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
118 lines (96 loc) · 3.18 KB
/
main.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
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
112
113
114
115
116
117
118
#include <QApplication>
#include <QDesktopWidget>
#include <QTime>
#include <space.h>
#include <global.h>
/**
* @brief initConfigure 初始化全局使用参数,可是从文件加载或其他形式
* @param gp
*/
static void initConfigure(GlobalParameter *gp)
{
gp->level = 1;
gp->bulletSpeed = 20;
gp->bulletSupplySpeed = 1;
gp->playerPlaneSpeed = 18;
gp->enemyPlaneLittleSpeed = 16;
gp->bloodSupplySpeed = 16;
QPainterPath p;
p.addRect(QRectF(0, 0, 5, 10));
gp->_1bulletOutline = p;
#ifdef Q_OS_ANDROID
//希望获得设备的屏幕大小,以来设置参数
gp->windowsWidth = 320;//QApplication::desktop()->width();
gp->windowsHeight = 480 - 30;//QApplication::desktop()->height();
#else
gp->windowsWidth = 320;
gp->windowsHeight = 440;
#endif
QPixmap pix("://image/player.png");
gp->playerPlanePixmap << pix;
pix.load("://image/player_die1.png");
gp->playerPlanePixmap << pix;
pix.load("://image/player_die2.png");
gp->playerPlanePixmap << pix;
pix.load("://image/player_die3.png");
gp->playerPlanePixmap << pix;
pix.load("://image/player_die4.png");
gp->playerPlanePixmap << pix;
pix.load("://image/enemy.png");
gp->enemyPlanePixmap << pix;
pix.load("://image/enemy_die1.png");
gp->enemyPlanePixmap << pix;
pix.load("://image/enemy_die2.png");
gp->enemyPlanePixmap << pix;
pix.load("://image/enemy_die3.png");
gp->enemyPlanePixmap << pix;
pix.load("://image/enemyM.png");
gp->enemyPlaneMPixmap << pix;
pix.load("://image/enemyM_die1.png");
gp->enemyPlaneMPixmap << pix;
pix.load("://image/enemyM_die2.png");
gp->enemyPlaneMPixmap << pix;
pix.load("://image/enemyM_die3.png");
gp->enemyPlaneMPixmap << pix;
pix.load("://image/enemyM_die4.png");
gp->enemyPlaneMPixmap << pix;
pix.load("://image/enemyM_hurt.png");
gp->enemyPlaneMPixmap << pix;
pix.load("://image/enemyL.png");
gp->enemyPlaneLPixmap << pix;
pix.load("://image/enemyL_die1.png");
gp->enemyPlaneLPixmap << pix;
pix.load("://image/enemyL_die2.png");
gp->enemyPlaneLPixmap << pix;
pix.load("://image/enemyL_die3.png");
gp->enemyPlaneLPixmap << pix;
pix.load("://image/enemyL_die4.png");
gp->enemyPlaneLPixmap << pix;
pix.load("://image/enemyL_die5.png");
gp->enemyPlaneLPixmap << pix;
pix.load("://image/enemyL_hurt.png");
gp->enemyPlaneLPixmap << pix;
pix.load("://image/bulletA.png");
gp->bulletSupplyPixmap << pix;
pix.load("://image/bulletB.png");
gp->bulletSupplyPixmap << pix;
//gp->p_eplC = new enemyplaneLcahce();
}
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
initConfigure(GlobalParameter::instance());
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
Space sw;
#ifdef Q_OS_ANDROID
sw.showFullScreen();
#else
sw.resize(GlobalParameter::instance()->windowsWidth,
GlobalParameter::instance()->windowsHeight);
sw.move(QApplication::desktop()->rect().center() -
QPoint(GlobalParameter::instance()->windowsWidth/2,
GlobalParameter::instance()->windowsHeight/2));
sw.show();
#endif
return app.exec();
}