MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->running = true; this->setFocus(); setFixedSize(GAME_WIDTH,GAME_HEIGHT); ui->backgroundFrame->setFixedSize(GAME_WIDTH,GAME_HEIGHT); //inicializacion atributos AspectRatioPixmapLabel* labelprueba = new AspectRatioPixmapLabel(); QPixmap pixPrueba(":/gameElement/assets/spaceship1.png"); labelprueba->setPixmap(pixPrueba); labelprueba->setFixedSize(50,50); labelprueba->setParent(this); labelprueba->show(); labelprueba->move(GAME_WIDTH/2,GAME_HEIGHT- 70); labelprueba->setScaledContents(true); player = newPlayerShip(labelprueba); playerBullets = new QList<PlayerBeam*>(); enemies = new QList<enemy_T*>(); scoreNumbers = new QList<QLabel*>(); Lives = new QList<QLabel*>(); //Inicializacion variables misc numbers[0] = ":/miscelanious/assets/numeral0.png"; numbers[1] = ":/miscelanious/assets/numeral1.png"; numbers[2] = ":/miscelanious/assets/numeral2.png"; numbers[3] = ":/miscelanious/assets/numeral3.png"; numbers[4] = ":/miscelanious/assets/numeral4.png"; numbers[5] = ":/miscelanious/assets/numeral5.png"; numbers[6] = ":/miscelanious/assets/numeral6.png"; numbers[7] = ":/miscelanious/assets/numeral7.png"; numbers[8] = ":/miscelanious/assets/numeral8.png"; numbers[9] = ":/miscelanious/assets/numeral9.png"; //---------------------------------- // generateNextLevel(); //Asignación de los Threads this->gameloop = new GameLoopThread(true); //Connects necesarios para el funcionamiento connect(gameloop,SIGNAL(gameUpdate()),this,SLOT(gameUpdate())); connect(gameloop,SIGNAL(gameRender()),this,SLOT(gameRender())); connect(gameloop,SIGNAL(gameDrawn()),this,SLOT(gameDrawn())); this->gameloop->start(); }
INT WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE, LPWSTR, INT ) { hinst = hInstance; //将实例句柄存储在全局变量中 MyRegisterClass(hInstance); //注册窗口类 ReadConf(); //读取配置文件 //创建并显示主窗口 if (MyShowWindow(hInstance, SW_SHOWDEFAULT)) { Init(); ShowCursor(false); #ifndef _DEBUG //创建脚本处理线程 boost::thread Thread_Script_Process(Script_Process); #endif //主消息循环: MSG msg; ZeroMemory(&msg,sizeof(msg)); while(msg.message != WM_QUIT) { if(PeekMessage(&msg,NULL,0U,0U,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else gameRender(); } //传递线程退出消息给ScriptThread ScriptThreadExit = true; ReleaseMusicModule(); #ifndef _DEBUG //等待脚本处理线程结束 Thread_Script_Process.join(); #endif //释放dx渲染库 ReleaseDxDrawDLL(); } UnregisterClass(szWindowClass,hinst); return 0; }