// // Draw The Scene // void DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glClearColor(0.0f, 0.0f, 0.3f, 0.0f); // Black Background // begin scene --- BEGIN_BOT; RenderWalls(); RenderPlane(); SetLights(); driver_objects[STARS_OBJECT]->render(); Draw_Wall_List(); DrawExplosions(); DrawFireAnts(); END_BOT; // Draw the multiple sets of Heads up displays Super_DrawText(); Draw_Title(); DrawHUD(); } // end of the function
void LoseLife(char *reason) { //Draw cracked screen - but draw all the rest of the world & hud first CloseGraphics(); OpenGraphics(); DrawWorld(&world, cameraPos, cameraAngle); DrawHUD(); DrawArrow(cameraAngle.y); DrawRadarDots(true); DrawRadarArm(sweepAngle * sweepStepCount++); DrawRadarDots(false); //finally! DrawCrackedScreen(); SetTextColor(RED); DrawText(25,40,reason); if (--lives<=0) { SetTextColor(GREEN); DrawText(30,55,"GAME OVER!"); } Show(); PlaySound(SOUND_EXPLOSION); //dead? if (lives<=0) { Sleep(2000); //Reset back to splash screen ResetTimer(); mode=0; Splash(); } else { // Hit but still going InitialiseWorld(); } }
// // Render // void Render(unsigned Width, unsigned Height) { g_ElapsedTime = GetElapsedMilliseconds(); BeginFrame(); glViewport(0, 0, Width, Height); glClear(GL_DEPTH_BUFFER_BIT); // No need to clear color buffer, because we draw background image g_View = XMMatrixTranslation(0.0f, 0.0f, g_Distance); g_Proj = XMMatrixPerspectiveFovRH(XMConvertToRadians(45.0f), Width / (float)Height, 0.1f, 100.0f); // Bunny rotation g_SpinX += g_ElapsedTime / 50.0f; // Setup light positions for (int i = 0; i < MAX_POINT_LIGHTS; ++i) { POINT_LIGHT_SOURCE *pLight = &g_PointLights[i]; CalcLightPosition(pLight); } g_pBackground->SetScreenSize(Width, Height); g_pBackground->Draw(); DrawBunny(); DrawLights(); DrawHUD(Width, Height); EndFrame(); g_pFraps->OnPresent(); }
void PS3Graphics::Refresh() { // Is this sufficient for a callback redraw? glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_QUADS, 0, 4); DrawHUD(); psglSwap(); last_redraw = sys_time_get_system_time(); }
void PS3Graphics::Draw(int width, int height, uint16_t* screen) { glClear(GL_COLOR_BUFFER_BIT); glBufferSubData(GL_TEXTURE_REFERENCE_BUFFER_SCE, 0, width * height * 2, screen); glTextureReferenceSCE(GL_TEXTURE_2D, 1, width, height, 0, GL_RGB5_A1, width*2, 0); UpdateCgParams(width, height, width, height); glDrawArrays(GL_QUADS, 0, 4); DrawHUD(); last_redraw = sys_time_get_system_time(); }
void HUD::Draw() { SetScreenViewport(); D3DXMATRIX temp; D3DXMatrixAffineTransformation2D(&temp, 1, nullptr, 0, nullptr); SpriteBatch->SetTransform(&temp); SpriteBatch->Begin(D3DXSPRITE_ALPHABLEND); DrawFrame(); DrawHUD(); SpriteBatch->End(); }
//start the game void InitialiseGame() { srand(ReadTimer()); mode=1; score=0; InitialiseWorld(); refreshCount=0; resetCount=50; behaviourCount=0; ResetArrow(); arrowRefAngle=0; cameraPos=CreatePoint(0.0,5.0,0.0); cameraAngle=CreatePoint(0.0,0.0,0.0); blocked=0; lives=3; DrawHUD(); }
// // Draw // void Game::Draw() { if(!showExitConfirm) { raycaster->Draw(); DrawHUD(); DrawMessages(); framework->ShowFPS(); //if(framework->GetJButton(0, JOY_BTTN_START)) framework->Debug(true); } else { framework->FillRect(NULL, Colors::black.ToUint32()); framework->DrawTextCentered("Do you really want to quit this game?" " Press Y for Yes and N For No...", Colors::white); } }
void ObjectManager_DrawObjects() { spriteDrawIndex = 0; DrawHUD(); DrawObjectCollection(&pickupCollection); DrawObjectCollection(&effectCollection); playerObject->drawFunction(playerObject); DrawObjectCollection(&enemyCollection); DrawObjectCollection(&playerProjectileCollection); DrawObjectCollection(&enemyProjectileCollection); DrawObjectCollection(&breakablesCollection); // sets the last used sprite's link to 0, telling the hardware to // only draw the sprites we've set. VDP_setSprite(spriteDrawIndex, 0, 0, 0, 0, 0); }
// // Draw The Scene // void DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glClearColor(0.0f, 0.0f, 0.3f, 0.0f); // Black Background //BEGIN_CAMERA // setup viewing camera BEGIN_BOT; //RenderGrid(); RenderWalls(); RenderPlane(); #if ENABLE_LIGHTS SetLights(); #endif driver_objects[STARS_OBJECT]->render(); Draw_Wall_List(); DrawExplosions(); // draw fire explosions DrawFireAnts(); // the mother of all enemies //END_CAMERA // end viewing camera END_BOT; // Draw the heads up display -- Super_DrawText(); Draw_Title(); DrawHUD(); } // end of the function
void WillowGame::GamePaint(RECT rect) { CameraHUD(); DrawEnemies(); DrawChests(); DrawCoins(); DrawBridge(); DrawWillow(); DrawFireballs(); DrawWizard(); DrawShopkeepers(); DrawHUD(); }
void Heartbeat() { if (gbUnload) return; static ULONGLONG LastGetTick = 0; static bool bFirstHeartBeat = true; static ULONGLONG TickDiff = 0; static fMQPulse pEQPlayNicePulse = NULL; static DWORD BeatCount = 0; ULONGLONG Tick = MQGetTickCount64(); BeatCount++; if (bFirstHeartBeat) { LastGetTick = Tick; bFirstHeartBeat = false; } // This accounts for rollover TickDiff += (Tick - LastGetTick); LastGetTick = Tick; #ifndef ISXEQ while (TickDiff >= 100) { TickDiff -= 100; if (gDelay>0) gDelay--; DropTimers(); } #endif if (!gStringTableFixed && pStringTable) // Please dont remove the second condition { FixStringTable(); gStringTableFixed = TRUE; } DebugTry(int GameState = GetGameState()); if (GameState != -1) { if ((DWORD)GameState != gGameState) { DebugSpew("GetGameState()=%d vs %d", GameState, gGameState); gGameState = GameState; DebugTry(Benchmark(bmPluginsSetGameState, PluginsSetGameState(GameState))); } } else return; DebugTry(UpdateMQ2SpawnSort()); #ifndef ISXEQ_LEGACY #ifndef ISXEQ DebugTry(DrawHUD()); //if (gGameState==GAMESTATE_INGAME && !bMouseLook && ScreenMode==3) //{ // DebugTry(pWndMgr->DrawCursor()); //} #endif #endif bRunNextCommand = TRUE; DebugTry(Pulse()); #ifndef ISXEQ_LEGACY #ifndef ISXEQ DebugTry(Benchmark(bmPluginsPulse, DebugTry(PulsePlugins()))); #endif if (pEQPlayNicePulse) { pEQPlayNicePulse(); } else { HMODULE hmEQPlayNice; if (((BeatCount % 63) == 0) && (hmEQPlayNice = GetModuleHandle("EQPlayNice.dll"))) { if (pEQPlayNicePulse = (fMQPulse)GetProcAddress(hmEQPlayNice, "Compat_ProcessFrame")) pEQPlayNicePulse(); } } #endif DebugTry(ProcessPendingGroundItems()); static bool ShownNews = false; if (gGameState == GAMESTATE_CHARSELECT && !ShownNews) { ShownNews = true; if (gCreateMQ2NewsWindow) CreateMQ2NewsWindow(); } #ifndef ISXEQ DWORD CurTurbo = 0; if (gDelayedCommands) {// delayed commands lockit lk(ghLockDelayCommand); DoCommand((PSPAWNINFO)pLocalPlayer, gDelayedCommands->szText); PCHATBUF pNext = gDelayedCommands->pNext; LocalFree(gDelayedCommands); gDelayedCommands = pNext; } while (bRunNextCommand) { if (!DoNextCommand()) break; if (!gTurbo) break;//bRunNextCommand = FALSE; if (++CurTurbo>gMaxTurbo) break;//bRunNextCommand = FALSE; } DoTimedCommands(); #endif }
void Game::Render() { //Clear screen SDL_RenderClear(renderer); switch (gameState) { case GameState::Title: //Draw Title screen and animated bat, text flashes on enter tm->draw("title", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, renderer, SDL_FLIP_NONE); if (!enterPressed) tm->drawFrame("titlebat", 368, 192, 144, 112, frameRow, frameCount, renderer, SDL_FLIP_NONE); if (enterPressed) { tm->drawFrame("titlebat", 368, 192, 144, 112, frameRow, frameCount, renderer, SDL_FLIP_NONE); tm->drawFrame("titlecover", 145, 255, 224, 16, 1, titleCount, renderer, SDL_FLIP_NONE); } break; case GameState::Intro: //Draw intro screen, player walks across and stops in center, 2 bats and a cloud animated in background tm->draw("intro", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, renderer, SDL_FLIP_NONE); if (posX > 240) tm->drawFrame("player_introwalk", posX, posY, 32, 64, 1, frameCount, renderer, SDL_FLIP_HORIZONTAL); else tm->draw("player_intro", posX, posY + 2, 32, 64, renderer, SDL_FLIP_HORIZONTAL); tm->draw("introcloud", (int) floor(cloudX), cloudY, 64, 32, renderer, SDL_FLIP_NONE); tm->draw("introcover", 480, 128, 32, 64, renderer, SDL_FLIP_NONE); tm->drawFrame("introbat", (int)floor(bat1X), (int)floor(bat1Y), 16, 16, 1, frameCount, renderer, SDL_FLIP_NONE); tm->drawFrame("introbat", (int)floor(bat2X), (int)floor(bat2Y), 16, 16, 1, frameCount, renderer, SDL_FLIP_NONE); break; case GameState::Fade: //Draw blank screen to transition between levels tm->draw("fade", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, renderer, SDL_FLIP_NONE); break; case GameState::Running: //Draw the HUD DrawHUD(); //Draw level, includes player, enemies etc levels[levelN].DrawLevel(tm, renderer, camera, frameCount); break; case GameState::Door: //Draw the HUD DrawHUD(); //Draw level without enemies and objects levels[levelN].DrawLevelChange(tm, renderer, camera, frameCount, doorTimer); break; case GameState::LevelComplete: DrawHUD(); levels[levelN].DrawLevel(tm, renderer, camera, frameCount); if (goToMap && levelCompleteTimer > 60) tm->draw("fade", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, renderer, SDL_FLIP_NONE); break; case GameState::Map: tm->draw("fade", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, renderer, SDL_FLIP_NONE); tm->draw("map", mapX, 0, 784, SCREEN_HEIGHT, renderer, SDL_FLIP_NONE); if (mapX == 0) { if (levelN == 4) { tm->drawFrame("map_bat", 182, 214, 32, 32, 1, frameCount % 2, renderer, SDL_FLIP_NONE); tm->drawFrame("map_mark", 302, 274, 32, 32, 1, frameCount % 2, renderer, SDL_FLIP_NONE); tm->drawFrame("player_introwalk", playerX, 306, 32, 64, 1, frameCount, renderer, SDL_FLIP_NONE); } if (levelN == 10) { tm->drawFrame("map_bat", 342, 183, 32, 32, 1, frameCount % 2, renderer, SDL_FLIP_NONE); tm->drawFrame("map_mark", 158, 216, 32, 32, 1, frameCount % 2, renderer, SDL_FLIP_NONE); tm->drawFrame("player_introwalk", playerX, 306, 32, 64, 1, frameCount, renderer, SDL_FLIP_NONE); } } DrawHUD(); break; case GameState::GameOver: tm->draw("game_over", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, renderer, SDL_FLIP_NONE); tm->draw("game_over_heart", 176, heartY, 16, 16, renderer, SDL_FLIP_NONE); DrawHUD(); break; default: break; } SDL_RenderPresent(renderer); }
// ------------------------------------------------------------------------------------------------ void PlayerCharacterView :: Draw() { DrawHUD(); } // ----------------------------------------------------------------------------------------------
//Main program loop - Run gets called until it returns false bool Run() { //Main loop - get keypresses and interpret them keystate=GetRemoteKeys(); if(keystate & KEY_HOME) { return false; } switch(mode) { case 0: { //Splash screen if (keystate & KEY_INPUT2) { //Button B //Start game InitialiseGame(); PlaySound(SOUND_BEEP); } if (keystate & KEY_INPUT1) { //Button A //show help ShowHelp(); PlaySound(SOUND_BEEP); } } break; case 2: { //Help - wait for 'OK' press if (keystate & KEY_INPUT2) { //Button B //Reset back to splash screen ResetTimer(); mode=0; Splash(); PlaySound(SOUND_BEEP); } } break; case 1: { //Game if (keystate & KEY_INPUT1) { //Button A //Reset back to splash screen ResetTimer(); mode=0; Splash(); } if (keystate & KEY_RUN) { //Go button //Fire! PlaySound(SOUND_SHOOT); refreshCount = 0; int hit; hit = LineHitsObject(cameraPos, cameraAngle); if (hit == tankObjectIndex) { //we hit the tank! score += 100; CloseGraphics(); OpenGraphics(); DrawWorld(&world, cameraPos, cameraAngle); DrawHUD(); DrawExplosion(); DrawArrow(cameraAngle.y); DrawRadarDots(true); DrawRadarArm(sweepAngle * sweepStepCount++); DrawRadarDots(false); SetTextColor(CYAN); DrawText(6,100,"Quit"); Show(); PlaySound(SOUND_EXPLOSION); PlaceTank(cameraPos, cameraAngle); } } //Have the movement sticks changed? This bit doesn't care about buttons if((keystate & (KEY_RIGHT_BACK+KEY_RIGHT_FORWARD+KEY_LEFT_BACK+KEY_LEFT_FORWARD)) != (oldKeystate & (KEY_RIGHT_BACK+KEY_RIGHT_FORWARD+KEY_LEFT_BACK+KEY_LEFT_FORWARD))) { MoveCamera(&cameraPos, &cameraAngle, baselinePos, arrowRefAngle, ReadTimer(), oldKeystate); arrowRefAngle=cameraAngle.y; baselinePos=cameraPos; ResetTimer(); oldKeystate = keystate; if (keystate==0) //we've just stopped moving refreshCount=0; } if (mode==1) { if (sweepStepCount == SWEEPSTEPS) sweepStepCount=0; if (--behaviourCount<0) ChooseBehaviour(); MoveTank(); MoveCamera(&cameraPos, &cameraAngle, baselinePos, arrowRefAngle, ReadTimer(), oldKeystate); //is it time to reset the tank model? Otherwise it gradually gets distorted if (--resetCount<0) { //Refresh the tank model which is prone to getting distorted //due to cumulative inaccuracies of sin/cos approximations Point3d angle=world.objects[tankObjectIndex].heading; Point3d tankPos=world.objects[tankObjectIndex].centre; world.objects[tankObjectIndex]=tank; MoveObject(&(world.objects[tankObjectIndex]), tankPos); RotateObjectYAxis(&(world.objects[tankObjectIndex]), angle.y); resetCount=50; } //Is it time to redraw the world? if (--refreshCount<0) { //Seems a bit brutal to have to close graphics but it's //the only way to clear the screen that'll let us draw //on it properly again - ClearScreen or ClearRectangle mess up CloseGraphics(); OpenGraphics(); DrawWorld(&world, cameraPos, cameraAngle); DrawHUD(); refreshCount=2; } DrawArrow(cameraAngle.y); DrawRadarDots(true); DrawRadarArm(sweepAngle * sweepStepCount++); DrawRadarDots(false); SetTextColor(CYAN); DrawText(6,100,"Quit"); Show(); //just in case we changed mode... if (mode==0) Splash(); } } } Sleep(50); return true; }
void AHUD::PostRender() { // Theres nothing we can really do without a canvas or a world - so leave now in that case if ( (GetWorld() == nullptr) || (Canvas == nullptr)) { return; } // Set up delta time RenderDelta = GetWorld()->TimeSeconds - LastHUDRenderTime; if ( PlayerOwner != NULL ) { // draw any debug text in real-time DrawDebugTextList(); } if ( bShowDebugInfo ) { if (DebugCanvas) { DebugCanvas->DisplayDebugManager.Initialize(DebugCanvas, GEngine->GetTinyFont(), FVector2D(4.f, 50.f)); ShowDebugInfo(DebugCanvas->DisplayDebugManager.GetMaxCharHeightRef(), DebugCanvas->DisplayDebugManager.GetYPosRef()); } } else if ( bShowHUD && FApp::CanEverRender() ) { DrawHUD(); // No need to do work to determine hit box candidates if there will never be any if (HitBoxMap.Num() > 0) { ULocalPlayer* LocalPlayer = GetOwningPlayerController() ? Cast<ULocalPlayer>(GetOwningPlayerController()->Player) : NULL; if (LocalPlayer && LocalPlayer->ViewportClient) { TArray<FVector2D> ContactPoints; if (!FSlateApplication::Get().IsFakingTouchEvents()) { FVector2D MousePosition; if (LocalPlayer->ViewportClient->GetMousePosition(MousePosition)) { ContactPoints.Add(MousePosition); } } for (int32 FingerIndex = 0; FingerIndex < EKeys::NUM_TOUCH_KEYS; ++FingerIndex) { FVector2D TouchLocation; bool bPressed = false; GetOwningPlayerController()->GetInputTouchState((ETouchIndex::Type)FingerIndex, TouchLocation.X, TouchLocation.Y, bPressed); if (bPressed) { ContactPoints.Add(TouchLocation); } } const FVector2D ContactPointOffset = GetCoordinateOffset(); if (!ContactPointOffset.IsZero()) { for (FVector2D& ContactPoint : ContactPoints) { ContactPoint += ContactPointOffset; } } UpdateHitBoxCandidates( MoveTemp(ContactPoints) ); } } else if (HitBoxesOver.Num() > 0) { // We still need to dispatch any end cursor over messages even if we don't have any hitboxes anymore for (const FName HitBoxName : HitBoxesOver) { NotifyHitBoxEndCursorOver(HitBoxName); } HitBoxesOver.Reset(); } } if( bShowHitBoxDebugInfo ) { RenderHitBoxes( Canvas->Canvas ); } DrawSafeZoneOverlay(); LastHUDRenderTime = GetWorld()->TimeSeconds; }