/* ============================= idGameBustOutWindow::CommonInit ============================= */ void idGameBustOutWindow::CommonInit() { BOEntity *ent; // Precache images declManager->FindMaterial( "game/bustout/ball" ); declManager->FindMaterial( "game/bustout/doublepaddle" ); declManager->FindMaterial( "game/bustout/powerup_bigpaddle" ); declManager->FindMaterial( "game/bustout/powerup_multiball" ); declManager->FindMaterial( "game/bustout/brick" ); // Precache sounds declManager->FindSound( "arcade_ballbounce" ); declManager->FindSound( "arcade_brickhit" ); declManager->FindSound( "arcade_missedball" ); declManager->FindSound( "arcade_sadsound" ); declManager->FindSound( "arcade_extraball" ); declManager->FindSound( "arcade_powerup" ); ResetGameState(); numLevels = 0; boardDataLoaded = false; levelBoardData = NULL; // Create Paddle ent = new BOEntity( this ); paddle = new BOBrick( ent, 260.f, 440.f, 96.f, 24.f ); paddle->ent->SetMaterial( "game/bustout/paddle" ); }
/* ============================= idGameBustOutWindow::UpdateGame ============================= */ void idGameBustOutWindow::UpdateGame() { int i; if ( onNewGame ) { ResetGameState(); // Create Board SetCurrentBoard(); gamerunning = true; } if ( onContinue ) { gameOver = false; ballsRemaining = 3; onContinue = false; } if ( onNewLevel ) { currentLevel++; ClearBoard(); SetCurrentBoard(); ballSpeed = BALL_SPEED * ( 1.f + ((float)currentLevel/5.f) ); if ( ballSpeed > BALL_MAXSPEED ) { ballSpeed = BALL_MAXSPEED; } updateScore = true; onNewLevel = false; } if(gamerunning == true) { UpdatePaddle(); UpdateBall(); UpdatePowerups(); for( i = 0; i < entities.Num(); i++ ) { entities[i]->Update( timeSlice, gui->GetTime() ); } // Delete entities that need to be deleted for( i = entities.Num()-1; i >= 0; i-- ) { if( entities[i]->removed ) { BOEntity* ent = entities[i]; delete ent; entities.RemoveIndex(i); } } if ( updateScore ) { UpdateScore(); updateScore = false; } } }
/* ============================= idGameBearShootWindow::UpdateGame ============================= */ void idGameBearShootWindow::UpdateGame() { int i; if ( onNewGame ) { ResetGameState(); if ( goal ) { goal->position.x = 550; goal->position.y = 164; goal->velocity.Zero(); } if ( helicopter ) { helicopter->position.x = 550; helicopter->position.y = 100; helicopter->velocity.Zero(); } if ( bear ) { bear->SetVisible( false ); } bearTurretAngle.SetFloat( 0.f ); bearTurretForce.SetFloat( 200.f ); gamerunning = true; } if ( onContinue ) { gameOver = false; timeRemaining = 60.f; onContinue = false; } if(gamerunning == true) { int current_time = gui->GetTime(); idRandom rnd( current_time ); // Check for button presses UpdateButtons(); if ( bear ) { UpdateBear(); } if ( helicopter && goal ) { UpdateHelicopter(); } // Update Wind if ( windUpdateTime < current_time ) { float scale; int width; windForce = rnd.CRandomFloat() * ( MAX_WINDFORCE * 0.75f ); if (windForce > 0) { windForce += ( MAX_WINDFORCE * 0.25f ); wind->rotation = 0; } else { windForce -= ( MAX_WINDFORCE * 0.25f ); wind->rotation = 180; } scale = 1.f - (( MAX_WINDFORCE - idMath::Fabs(windForce) ) / MAX_WINDFORCE); width = 100*scale; if ( windForce < 0 ) { wind->position.x = 500 - width + 1; } else { wind->position.x = 500; } wind->SetSize( width, 40 ); windUpdateTime = current_time + 7000 + rnd.RandomInt(5000); } // Update turret rotation angle if ( turret ) { turretAngle = bearTurretAngle.GetFloat(); turret->rotation = turretAngle; } for( i = 0; i < entities.Num(); i++ ) { entities[i]->Update( timeSlice ); } // Update countdown timer timeRemaining -= timeSlice; timeRemaining = idMath::ClampFloat( 0.f, 99999.f, timeRemaining ); gui->SetStateString( "time_remaining", va("%2.1f", timeRemaining ) ); if ( timeRemaining <= 0.f && !gameOver ) { gameOver = true; updateScore = true; } if ( updateScore ) { UpdateScore(); updateScore = false; } } }
/* ============================= idGameBearShootWindow::CommonInit ============================= */ void idGameBearShootWindow::CommonInit() { BSEntity * ent; // Precache sounds declManager->FindSound( "arcade_beargroan" ); declManager->FindSound( "arcade_sargeshoot" ); declManager->FindSound( "arcade_balloonpop" ); declManager->FindSound( "arcade_levelcomplete1" ); // Precache dynamically used materials declManager->FindMaterial( "game/bearshoot/helicopter_broken" ); declManager->FindMaterial( "game/bearshoot/goal_dead" ); declManager->FindMaterial( "game/bearshoot/gun_blast" ); ResetGameState(); ent = new (TAG_OLD_UI) BSEntity( this ); turret = ent; ent->SetMaterial( "game/bearshoot/turret" ); ent->SetSize( 272, 144 ); ent->position.x = -44; ent->position.y = 260; entities.Append( ent ); ent = new (TAG_OLD_UI) BSEntity( this ); ent->SetMaterial( "game/bearshoot/turret_base" ); ent->SetSize( 144, 160 ); ent->position.x = 16; ent->position.y = 280; entities.Append( ent ); ent = new (TAG_OLD_UI) BSEntity( this ); bear = ent; ent->SetMaterial( "game/bearshoot/bear" ); ent->SetSize( BEAR_SIZE, BEAR_SIZE ); ent->SetVisible( false ); ent->position.x = 0; ent->position.y = 0; entities.Append( ent ); ent = new (TAG_OLD_UI) BSEntity( this ); helicopter = ent; ent->SetMaterial( "game/bearshoot/helicopter" ); ent->SetSize( 64, 64 ); ent->position.x = 550; ent->position.y = 100; entities.Append( ent ); ent = new (TAG_OLD_UI) BSEntity( this ); goal = ent; ent->SetMaterial( "game/bearshoot/goal" ); ent->SetSize( 64, 64 ); ent->position.x = 550; ent->position.y = 164; entities.Append( ent ); ent = new (TAG_OLD_UI) BSEntity( this ); wind = ent; ent->SetMaterial( "game/bearshoot/wind" ); ent->SetSize( 100, 40 ); ent->position.x = 500; ent->position.y = 430; entities.Append( ent ); ent = new (TAG_OLD_UI) BSEntity( this ); gunblast = ent; ent->SetMaterial( "game/bearshoot/gun_blast" ); ent->SetSize( 64, 64 ); ent->SetVisible( false ); entities.Append( ent ); }