static void Draw(void) { MoveStars(); ShowStars(); if (nitro > 0) { speed = (float)(nitro / 10) + 1.0; if (speed > MAXWARP) { speed = MAXWARP; } if (++nitro > MAXWARP*10) { nitro = -nitro; } } else if (nitro < 0) { nitro++; speed = (float)(-nitro / 10) + 1.0; if (speed > MAXWARP) { speed = MAXWARP; } } glFlush(); if (doubleBuffer) { glutSwapBuffers(); } }
void Idle(void) { MoveStars(); ShowStars(); if (nitro > 0) { speed = (float)(nitro / 10) + 1.0; if (speed > MAXWARP1) { speed = MAXWARP1; } if (++nitro > MAXWARP1*10) { nitro = -nitro; } } else if (nitro < 0) { nitro++; speed = (float)(-nitro / 10) + 1.0; if (speed > MAXWARP1) { speed = MAXWARP1; } } glFlush(); /* if (doubleBuffer) { tkSwapBuffers(); }*/ }
static void Idle(void) { if (overlayInit == GL_FALSE) { glutUseLayer(GLUT_OVERLAY); glClear(GL_COLOR_BUFFER_BIT); /* glColor3f(1.0, 0.0, 0.0);*/ glIndexf( 2.0 ); glBegin(GL_POLYGON); glVertex2i(windW/4-10, windH/4-10); glVertex2i(windW/2-10, windH/4-10); glVertex2i(windW/2-10, windH/2-10); glVertex2i(windW/4-10, windH/2-10); glEnd(); glIndexf( 0.0 ); glBegin(GL_POLYGON); glVertex2i(windW/4, windH/4); glVertex2i(windW/2, windH/4); glVertex2i(windW/2, windH/2); glVertex2i(windW/4, windH/2); glEnd(); glIndexf( 1.0 ); glBegin(GL_POLYGON); glVertex2i(windW/4+10, windH/4+10); glVertex2i(windW/2+10, windH/4+10); glVertex2i(windW/2+10, windH/2+10); glVertex2i(windW/4+10, windH/2+10); glEnd(); glutUseLayer(GLUT_NORMAL); overlayInit = GL_TRUE; } MoveStars(); ShowStars(); if (nitro > 0) { speed = (float)(nitro / 10) + 1.0; if (speed > MAXWARP) { speed = MAXWARP; } if (++nitro > MAXWARP*10) { nitro = -nitro; } } else if (nitro < 0) { nitro++; speed = (float)(-nitro / 10) + 1.0; if (speed > MAXWARP) { speed = MAXWARP; } } glFlush(); if (doubleBuffer) { glutSwapBuffers(); } }
//--------------------------------------------------------------- // Name: DynamicStarField() // Desc: //--------------------------------------------------------------- int DynamicStarField(RECT *starField, int nNumofStars, CVECTOR velVec, int nFrame) { static PARTICLE *stars = new PARTICLE[nNumofStars]; static RECT tempField = {0,0,1,1}; //reverse the velocity vector so the stars move in the oppsoite direction as the ship velVec.Reverse(); //velVec.y = -velVec.y; //init the stars if(!nFrame) //if first frame InitStars(stars, starField, tempField, nNumofStars); DrawStars(stars, nNumofStars); MoveStars(stars, nNumofStars, tempField, velVec); if(bDebugMode) DebugInfo(stars, nFrame, nNumofStars, tempField); return(1); }
/*========================================================================= // Name: Game_Loop() // Desc: The main loop for the game //=======================================================================*/ static void Game_Loop() { if (!bPause) { if (!bGameOver) { cluster.dropCount--; /* Decrease time until the next fall */ if (cluster.dropCount == 0) { if (MoveCluster(0)) /* If cluster "collides"... */ NewCluster(); /* then create a new one ;) */ } /* Increase Level */ if (((level == 0) && (lines >= 10)) || ((level == 1) && (lines >= 20)) || ((level == 2) && (lines >= 40)) || ((level == 3) && (lines >= 80)) || ((level == 4) && (lines >= 100)) || ((level == 5) && (lines >= 120)) || ((level == 6) && (lines >= 140)) || ((level == 7) && (lines >= 160)) || ((level == 8) && (lines >= 180)) || ((level == 9) && (lines >= 200))) { level++; PutSound(&sndNextlevel); } } else { GameOverAnimation(); } if (bCrazy) /* If crazy mode is actived... */ BoxDrawMove(); /* ... change box settings! */ MoveStars(); /* Move stars */ UpdateParticles(); /* Move particles */ } DrawScene(); }
void MainMenu::Process() { Input& input = Input::GetInstance(); OpenGL& opengl = OpenGL::GetInstance(); ScreenManager& sm = ScreenManager::GetInstance(); const OpenGL::TimeScale timeScale = opengl.GetTimeScale(); // Stop user doing something when they're not supposed to if (state == msInMenu) { // Look at keys if (input.QueryAction(Input::DOWN)) { // Move the selection down switch (selOption) { case optStart: selOption = optScore; break; case optScore: selOption = optOptions; break; case optOptions: selOption = optExit; break; default: break; } InterfaceSounds::PlayBleep(); input.ResetAction(Input::DOWN); } else if (input.QueryAction(Input::UP)) { // Move the selection up switch (selOption) { case optScore: selOption = optStart; break; case optOptions: selOption = optScore; break; case optExit: selOption = optOptions; break; default: break; } InterfaceSounds::PlayBleep(); input.ResetAction(Input::UP); } else if (input.QueryAction(Input::FIRE)) { // Select this option switch (selOption) { case optStart: state = msFadeToStart; break; case optScore: state = msFadeToHigh; break; case optOptions: state = msFadeToOpt; break; case optExit: state = msFadeToExit; break; } InterfaceSounds::PlaySelect(); input.ResetAction(Input::FIRE); } else if (input.QueryResetAction(Input::SCREENSHOT)) OpenGL::GetInstance().DeferScreenShot(); } // See what menu state we're in if (state == msFadeIn) { // Apply the fade to the menu items if (fade >= 1.0) { // Switch to the next state state = msInMenu; fade = 1.0; } else fade += MENU_FADE_SPEED * timeScale; } else if (state == msFadeToStart) { // Apply fade if (fade <= 0.0) { // Move to the game screen sm.SelectScreen("GAME"); Game* g = static_cast<Game*>(sm.GetScreenById("GAME")); g->NewGame(); } else { fade -= MENU_FADE_SPEED * timeScale; bigness += 0.5f; } } else if (state == msFadeToHigh) { // Apply fade if (fade <= 0.0f) { // Move to the high score screen HighScores* hs = static_cast<HighScores*>(sm.GetScreenById("HIGH SCORES")); hs->DisplayScores(); } else { fade -= MENU_FADE_SPEED * timeScale; bigness += 0.5f; } } else if (state == msFadeToOpt) { // Apply fade if (fade <= 0.0f) { // Move to the options screen sm.SelectScreen("OPTIONS"); } else { fade -= MENU_FADE_SPEED * timeScale; bigness += 0.5f; } } else if (state == msFadeToExit) { // Apply fade if (fade <= 0.0f) { // Exit the game opengl.Stop(); } else { fade -= MENU_FADE_SPEED * timeScale; bigness += 0.5f; } } MoveStars(); }