加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.cpp 3.18 KB
一键复制 编辑 原始数据 按行查看 历史
zhouxiang 提交于 2013-09-16 19:39 . modefy
#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();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化