// Display fuction used to redraw our graphics as our game runs. void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear frame buffer. switch(gameState) { case STATE_CALIBRATE: gameState = calibrateDisplay(); break; case STATE_START: gameState = startDisplay(); break; case STATE_PLAY: gameState = playDisplay(); break; case STATE_HIGHSCORES: gameState = highScoreDisplay(); break; case STATE_GAMEOVER: gameState = gameOverDisplay(); break; } isShotFired = false; glFlush(); glutSwapBuffers(); }
MainWindow::MainWindow( GameEngine * currentEngine) : isGameLaunched(false),keystate() { currentGameEngine = currentEngine ; // menubar creation menuBar = new QMenuBar(); QMenu * gameMenu = menuBar->addMenu("Game"); gameMenu->addAction("New Game",this,SLOT(diplayNewGame())); gameMenu->addAction("Stop Game",currentGameEngine, SLOT(stop())); gameMenu->addAction("Options",this, SLOT(displayOptions())); gameMenu->addSeparator(); gameMenu->addAction("Quit",qApp,SLOT(quit())); QMenu * helpMenu = menuBar->addMenu("Help"); helpMenu->addAction("About chmeup",this,SLOT(displayAbout())); setFixedSize(screenWidthGlobal + 2 * BORDER_WIDTH ,screenHeightGlobal + menuBar->sizeHint().height() + 2* BORDER_HEIGHT); // central widget setCentralWidget(&screen); connect(currentGameEngine, SIGNAL(updateUI()), this, SLOT(update())) ; connect(currentGameEngine, SIGNAL(requestKeyUI()),this,SLOT(keysNeeded())); connect(currentGameEngine, SIGNAL(displayGameOverScreen()), this, SLOT(gameOverDisplay())); connect(currentGameEngine, SIGNAL(displayGameWonScreen()),this,SLOT(gameWonDisplay())); connect(this,SIGNAL(sendKeys(KeyPressedFrame * )),currentGameEngine,SLOT(getKeyFrame(KeyPressedFrame *))); connect(this,SIGNAL(sendPause()), currentGameEngine, SLOT(pause())); setMenuBar(menuBar); }