void MenuButtonMoveCallback(GUI_BUTTON *btn,INT32 reason) { if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE) { RenderMainMenu(); InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY); } if(reason & MSYS_CALLBACK_REASON_GAIN_MOUSE) { RenderMainMenu(); InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY); } }
//----------------------------------------------------------------------------------- void TheGame::Render() { Renderer::instance->ClearScreen(0.3f, 0.3f, 0.3f); Renderer::instance->BeginOrtho(Vector2::ZERO, Vector2(1600, 900)); Renderer::instance->DrawText2D(Vector2(0, 0), GetStateString(GetGameState()), 5.0f, RGBA::VAPORWAVE, true, BitmapFont::CreateOrGetFontFromGlyphSheet("Runescape")); switch (GetGameState()) { case GameState::GENERATION: Renderer::instance->ClearScreen(0.3f, 0.3f, 0.3f); RenderGeneration(); break; case GameState::MAIN_MENU: Renderer::instance->ClearScreen(RGBA::CORNFLOWER_BLUE); RenderMainMenu(); break; case GameState::MAP_SELECTION: Renderer::instance->ClearScreen(RGBA::FOREST_GREEN); RenderMapSelection(); break; case GameState::PLAYING: Renderer::instance->ClearScreen(RGBA::BLACK); RenderPlaying(); break; case GameState::PAUSED: Renderer::instance->ClearScreen(RGBA::CORNFLOWER_BLUE); RenderPaused(); break; } Renderer::instance->EndOrtho(); }
void ClassDemoApp::Setup() { SDL_Init(SDL_INIT_VIDEO); displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 400, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(displayWindow); SDL_GL_MakeCurrent(displayWindow, context); #ifdef _WINDOWS glewInit(); #endif glViewport(0, 0, 800, 400); projectionMatrix.setOrthoProjection(-12.0f, 12.0f, -6.0f, 6.0f, -1.0f, 1.0f); program = new ShaderProgram(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl"); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); blocksTexture = LoadTexture(RESOURCE_FOLDER"arne_sprites.png"); playerTexture = LoadTexture(RESOURCE_FOLDER"herowalk_03.png"); fontTexture = LoadTexture(RESOURCE_FOLDER"pixel_font.png"); spritesTexture = LoadTexture(RESOURCE_FOLDER"complete.png"); keysTexture = LoadTexture(RESOURCE_FOLDER"keys_02.png"); Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096); someSound = Mix_LoadWAV("hitfx.wav"); music = Mix_LoadMUS("LoBatTwinkle.mp3"); RenderMainMenu(); }
void ClassDemoApp::ProcessEvents() { while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) { done = true; } else if (event.type == SDL_KEYDOWN) { if (event.key.keysym.scancode == SDL_SCANCODE_SPACE && state == STATE_GAME_LEVEL) { shoot(); } else if (event.key.keysym.scancode == SDL_SCANCODE_RETURN) { if (state == STATE_GAME_OVER) { RenderMainMenu(); } else if (state == STATE_MAIN_MENU) { RenderGameLevel(); } } } } glClearColor(0.2f, 0.2f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); program->setModelMatrix(modelMatrix); program->setViewMatrix(viewMatrix); program->setProjectionMatrix(projectionMatrix); glUseProgram(program->programID); switch (state) { case STATE_MAIN_MENU: DrawText(fontTexture, "SPACE INVADERS", 0.3, 0, -1.9f, 0.7f); DrawText(fontTexture, "PRESS ENTER TO BEGIN", 0.1, 0, -1.0f, -0.5f); break; case STATE_GAME_LEVEL: player->Draw(program); bullet.Draw(program); DrawText(fontTexture, "SCORE: " + std::to_string(score), 0.1, 0, -0.37f, 1.8f); for (Entity& enemy : enemies) { enemy.Draw(program); } break; case STATE_GAME_OVER: DrawText(fontTexture, "SCORE: " + std::to_string(score), 0.1, 0, -0.37f, 1.8f); DrawText(fontTexture, "GAMEOVER", 0.1, 0, -0.37f, 0.9f); DrawText(fontTexture, "PRESS ENTER TO CONTINUE", 0.1, 0, -1.1f, 0.0f); for (Entity& enemy : enemies) { enemy.Draw(program); } break; } SDL_GL_SwapWindow(displayWindow); }
//Calls a render function based on gamestate void Render() { if(gamestate == 0) { RenderMainMenu(); } else { RenderGame(); } }
void gameApp::UpdateAndRender() { while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) { done = true; } } // Render(); //doBattle + encounter goes here. // Update(); //changes states and stages //testing RenderMainMenu(); }
void GameApp::Render(){ glClear(GL_COLOR_BUFFER_BIT); switch (state){ case MAIN_MENU: RenderMainMenu(); break; case GAMEPLAY: RenderGamePlay(); break; case GAME_OVER: RenderGameOver(); break; case PAUSE: RenderPause(); break; } SDL_GL_SwapWindow(displayWindow); }
void gameApp::Render() { glClearColor(0.2f, 0.2f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); switch (state) { case MAIN_MENU: { RenderMainMenu(); Mix_FadeInMusic(titlemewsic, -1, 500); } case MAIN_QUEST: { RenderQuest(); Mix_FadeInMusic(stagemewsic, -1, 1000); } case MAIN_DEATH: { RenderGameOver(); Mix_FadeInMusic(gameovermewsic, -1, 300); } } }
void ClassDemoApp::Setup() { SDL_Init(SDL_INIT_VIDEO); displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 360, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(displayWindow); SDL_GL_MakeCurrent(displayWindow, context); #ifdef _WINDOWS glewInit(); #endif glViewport(0, 0, 640, 360); projectionMatrix.setOrthoProjection(-3.55, 3.55, -2.0, 2.0, -1.0, 1.0); program = new ShaderProgram(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl"); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); spritesTexture = LoadTexture(RESOURCE_FOLDER"complete.png"); fontTexture = LoadTexture(RESOURCE_FOLDER"pixel_font.png"); RenderMainMenu(); }
// WANNE - MP: In this method we decide if we want to play a single or multiplayer game void MenuButtonCallback(GUI_BUTTON *btn,INT32 reason) { INT8 bID; bID = (UINT8)btn->UserData[0]; if (!(btn->uiFlags & BUTTON_ENABLED)) return; if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP ) { // handle menu gbHandledMainMenu = bID; RenderMainMenu(); if( gbHandledMainMenu == NEW_GAME ) { giMAXIMUM_NUMBER_OF_PLAYER_SLOTS = CODE_MAXIMUM_NUMBER_OF_PLAYER_SLOTS; if(is_networked) { is_networked = FALSE; // Snap: UN-Init MP save game directory if ( !InitSaveDir() ) { //if something didnt work, dont even know how to make error code...//hayden } }; SetMainMenuExitScreen( GAME_INIT_OPTIONS_SCREEN ); } else if (gbHandledMainMenu == NEW_MP_GAME) { is_networked = TRUE; // WANNE - MP: Only reset this here, because otherwise after a MP game ends and a new starts, we would receive the files again. fClientReceivedAllFiles = FALSE; giMAXIMUM_NUMBER_OF_PLAYER_SLOTS = 7; // Snap: Re-Init MP save game directory if ( !InitSaveDir() ) { //if something didnt work, dont even know how to make error code...//hayden } // WANNE: Removed, cause I don't think it is needed if we only want to play a multiplayer game! // Reload the external gameplay data, because maybe we started a MP game before! //LoadExternalGameplayData(TABLEDATA_DIRECTORY); SetMainMenuExitScreen( MP_JOIN_SCREEN ); // OJW - 20081129 //SetMainMenuExitScreen( GAME_INIT_OPTIONS_SCREEN ); } else if( gbHandledMainMenu == LOAD_GAME ) { giMAXIMUM_NUMBER_OF_PLAYER_SLOTS = CODE_MAXIMUM_NUMBER_OF_PLAYER_SLOTS; if(is_networked) { is_networked = FALSE; // Snap: UN-Init MP save game directory if ( !InitSaveDir() ) { //if something didnt work, dont even know how to make error code...//hayden } } if( gfKeyState[ ALT ] ) gfLoadGameUponEntry = TRUE; } InitDependingGameStyleOptions(); btn->uiFlags &= (~BUTTON_CLICKED_ON ); } if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) { RenderMainMenu(); btn->uiFlags |= BUTTON_CLICKED_ON; } }
UINT32 MainMenuScreenHandle( ) { UINT32 cnt; UINT32 uiTime; if( guiSplashStartTime + 4000 > GetJA2Clock() ) { SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); SetMusicMode( MUSIC_NONE ); return MAINMENU_SCREEN; //The splash screen hasn't been up long enough yet. } if( guiSplashFrameFade ) { uiTime = GetJA2Clock(); if( guiSplashFrameFade > 2 ) ShadowVideoSurfaceRectUsingLowPercentTable( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); else if( guiSplashFrameFade > 1 ) ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0 ); else { uiTime = GetJA2Clock(); SetMusicMode( MUSIC_MAIN_MENU ); } guiSplashFrameFade--; InvalidateScreen(); EndFrameBufferRender(); SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); return MAINMENU_SCREEN; } SetCurrentCursorFromDatabase( CURSOR_NORMAL ); if( gfMainMenuScreenEntry ) { InitMainMenu( ); gfMainMenuScreenEntry = FALSE; gfMainMenuScreenExit = FALSE; guiMainMenuExitScreen = MAINMENU_SCREEN; SetMusicMode( MUSIC_MAIN_MENU ); } if ( fInitialRender ) { ClearMainMenu(); RenderMainMenu(); fInitialRender = FALSE; } RestoreButtonBackGrounds(); // Render buttons for ( cnt = 0; cnt < NUM_MENU_ITEMS; cnt++ ) { MarkAButtonDirty( iMenuButtons[ cnt ] ); } RenderButtons( ); EndFrameBufferRender( ); HandleMainMenuInput(); HandleMainMenuScreen(); if( gfMainMenuScreenExit ) { ExitMainMenu( ); gfMainMenuScreenExit = FALSE; gfMainMenuScreenEntry = TRUE; } if( guiMainMenuExitScreen != MAINMENU_SCREEN ) gfMainMenuScreenEntry = TRUE; return( guiMainMenuExitScreen ); }
void ClassDemoApp::UpdateGameLevel(float elapsed) { const Uint8 *keys = SDL_GetKeyboardState(NULL); if (keys[SDL_SCANCODE_LEFT]) { player->x -= elapsed * 6.0f; if( player->x < -3.55f + player->width / 2.0f) { player->x = -3.55f + player->width / 2.0f; } } if (keys[SDL_SCANCODE_RIGHT]) { player->x += elapsed * 6.0f; if (player->x > 3.55f - player->width / 2.0f) { player->x = 3.55f - player->width / 2.0f; } } timeCount += elapsed; if (timeCount > 0.15f) { for (Entity& enemy : enemies) { if (enemy.active) { if (player->collidesWith(enemy)) { RenderGameOver(); } if (moveEnemyDown) { enemy.y -= 0.3f; } else { enemy.x += 0.1f * enemyDirection; if (enemy.x < -3.0f || enemy.x > 3.0f) { enemyHitWall = true; } } } } moveEnemyDown = false; if (enemyHitWall) { moveEnemyDown = true; enemyDirection *= -1.0f; enemyHitWall = false; } timeCount -= 0.15f; } if (bullet.active) { bullet.y += 10.0f * elapsed; if (bullet.y > 2.0f) { bullet.active = false; } else { for (Entity& enemy : enemies) { if (bullet.collidesWith(enemy)) { enemy.active = false; bullet.active = false; score++; numOfEnemies--; if (numOfEnemies <= 0) { RenderMainMenu(); } break; } } } } }
void ClientGame::Render() { glHint(GL_LINE_SMOOTH_HINT, GL_NICEST ); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST ); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); if (m_gameState == GameState_MainMenu) { RenderMainMenu(); return; } if (m_gameState == GameState_WaitingForServer) { return; } glClearColor( 0.97f * 0.9f, 0.96f * 0.9f, 0.89f * 0.9f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glDisable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(m_mapX, m_mapX + m_xSize * m_mapScale, m_mapY + m_ySize * m_mapScale, m_mapY); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); const int outerBorder = 35; // Draw the background. glColor(0xFFFFFFFF); glBegin(GL_QUADS); glVertex2i(-outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, m_yMapSize + outerBorder); glVertex2i(-outerBorder, m_yMapSize + outerBorder); glEnd(); // Outer thick border of the map glColor(0xFF7FD6F2); glLineWidth(2); glBegin(GL_LINE_LOOP); glVertex2i(-outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, m_yMapSize + outerBorder); glVertex2i(-outerBorder, m_yMapSize + outerBorder); glEnd(); // Grid glColor(0xFF7FD6F2); glLineWidth(1); glBegin(GL_LINES); for (int x = 0; x < m_xMapSize / m_gridSpacing; ++x) { glVertex2i(x * m_gridSpacing, 0); glVertex2i(x * m_gridSpacing, m_yMapSize); } glVertex2i(m_xMapSize, 0); glVertex2i(m_xMapSize, m_yMapSize); for (int y = 0; y < m_yMapSize / m_gridSpacing; ++y) { glVertex2i(0, y * m_gridSpacing); glVertex2i(m_xMapSize, y * m_gridSpacing); } glVertex2i(0, m_yMapSize); glVertex2i(m_xMapSize, m_yMapSize); glEnd(); // Buildings. glEnable(GL_TEXTURE_2D); glColor(0xFFFFFFFF); for (int i = 0; i < m_map.GetNumStops(); ++i) { const Stop& stop = m_map.GetStop(i); Vec2 position = stop.point; const Texture* texture = NULL; switch (stop.structureType) { case StructureType_Bank: texture = &m_buildingBankTexture; break; case StructureType_Tower: texture = &m_buildingTowerTexture; break; case StructureType_Police: texture = &m_buildingPoliceTexture; break; } if (texture != NULL) { Render_DrawSprite(*texture, static_cast<int>(position.x) - texture->xSize / 2, static_cast<int>(position.y) - texture->ySize / 2); } } for (int i = 0; i < m_state.GetNumEntities(); ++i) { const Entity* entity = m_state.GetEntity(i); switch (entity->GetTypeId()) { case EntityTypeId_Building: { const BuildingEntity* building = static_cast<const BuildingEntity*>(entity); Vec2 position = m_map.GetStop(building->m_stop).point; if (building->m_raided) { Render_DrawSprite(m_buildingRaidedHouseTexture, static_cast<int>(position.x) - m_buildingRaidedHouseTexture.xSize / 2, static_cast<int>(position.y) - m_buildingHouseTexture.ySize / 2); } else { Render_DrawSprite(m_buildingHouseTexture, static_cast<int>(position.x) - m_buildingHouseTexture.xSize / 2, static_cast<int>(position.y) - m_buildingHouseTexture.ySize / 2); } } break; } } glDisable(GL_TEXTURE_2D); // Rails. glLineWidth(8.0f / m_mapScale); glBegin(GL_LINES); for (int i = 0; i < m_map.GetNumRails(); ++i) { const Rail& rail = m_map.GetRail(i); const Stop& stop1 = m_map.GetStop(rail.stop1); const Stop& stop2 = m_map.GetStop(rail.stop2); assert(rail.line >= 0); unsigned long color = m_map.GetLineColor(rail.line); // Draw the rails partially transparent to make the buldings more readable. color = (color & 0x00FFFFFF) | 0x90000000; glColor( color ); glVertex(stop1.point); glVertex(stop2.point); } glEnd(); // Stops. for (int i = 0; i < m_map.GetNumStops(); ++i) { const Stop& stop = m_map.GetStop(i); float inflate = 0.0f; if (i == m_hoverStop) { inflate = 5.0f; } if (stop.line == -1) { glColor( 0xFF000000 ); DrawCircle(stop.point, 8.0f + inflate); glColor( 0xFFFFFFFF ); DrawCircle(stop.point, 6.0f + inflate); } else { glColor( m_map.GetLineColor(stop.line) ); DrawCircle(stop.point, 8.0f + inflate); } } // Draw the legend of the grid. Font_BeginDrawing(m_font); glColor(0xFF7FD6F2); int fontHeight = Font_GetTextHeight(m_font); for (int x = 0; x < m_xMapSize / m_gridSpacing; ++x) { char buffer[32]; sprintf(buffer, "%d", x); int textWidth = Font_GetTextWidth(m_font, buffer); Font_DrawText(buffer, x * m_gridSpacing + m_gridSpacing / 2 - textWidth / 2, -outerBorder + 5); Font_DrawText(buffer, x * m_gridSpacing + m_gridSpacing / 2 - textWidth / 2, m_yMapSize + 5); } for (int y = 0; y < m_yMapSize / m_gridSpacing; ++y) { char buffer[32]; sprintf(buffer, "%c", 'A' + y); Font_DrawText(buffer, -outerBorder + 10, y * m_gridSpacing + m_gridSpacing / 2 - fontHeight / 2); Font_DrawText(buffer, m_xMapSize + 10, y * m_gridSpacing + m_gridSpacing / 2 - fontHeight / 2); } Font_EndDrawing(); glEnable(GL_TEXTURE_2D); // DL: How about blinking for showing selection? const float kBlinkDuration = 0.2f; const float kBlinkCycleDuration = 1.0f; float blinkT = fmodf(m_time, kBlinkCycleDuration); float blinkAlpha = 1.0f; if (blinkT < kBlinkDuration) { blinkAlpha = (cosf(2.0f*kPi*blinkT/kBlinkDuration)+1.0f)/2.0f; } unsigned long blinkColor = (static_cast<int>(blinkAlpha*255.0f) << 24) | 0xffffff; // Entities int index = 0; const AgentEntity* agent; while (m_state.GetNextEntityWithType(index, agent)) { if (m_selectedAgent == agent->GetId() && m_pathLength == 0) { glColor(blinkColor); } else { glColor(0xFFFFFFFF); } Vec2 position = GetAgentPosition(agent); if (agent->m_state == AgentEntity::State_Hacking) { Render_DrawSprite(m_agentHackingTexture, static_cast<int>(position.x) - m_agentHackingTexture.xSize / 2, static_cast<int>(position.y) - m_agentHackingTexture.ySize / 2); } else if (agent->m_state == AgentEntity::State_Stakeout) { Render_DrawSprite(m_agentStakeoutTexture, static_cast<int>(position.x) - m_agentStakeoutTexture.xSize / 2, static_cast<int>(position.y) - m_agentStakeoutTexture.ySize / 2); } else if (agent->m_intel != -1) { Render_DrawSprite(m_agentIntelTexture, static_cast<int>(position.x) - m_agentIntelTexture.xSize / 2, static_cast<int>(position.y) - m_agentIntelTexture.ySize / 2); } else { Render_DrawSprite(m_agentTexture, static_cast<int>(position.x) - m_agentTexture.xSize / 2, static_cast<int>(position.y) - m_agentTexture.ySize / 2); } } m_mapParticles.Draw(); // Draw the UI. glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, m_xSize, m_ySize, 0); glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glBegin(GL_QUADS); glVertex2i(0, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize); glVertex2i(0, m_ySize); glEnd(); glColor(0xFF86DDEE); glLineWidth(1); glBegin(GL_LINE_LOOP); glVertex2i(0, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize); glVertex2i(0, m_ySize); glEnd(); glEnable(GL_TEXTURE_2D); for (int i = 0; i < ButtonId_NumButtons; ++i) { if (m_button[i].enabled) { int xButton, yButton, xButtonSize, yButtonSize; GetButtonRect((ButtonId)i, xButton, yButton, xButtonSize, yButtonSize); if (m_button[i].toggled) { glColor(0xFFB0E8E1); } else { glColor(0xFFFFFFFF); } int buttonOffset = 0; int shadowOffset = 10; Render_DrawSprite( m_buttonShadowTexture, xButton + shadowOffset, yButton + shadowOffset ); if (m_activeButton == i && m_activeButtonDown) { buttonOffset = 5; } Render_DrawSprite( m_buttonTexture[i], xButton + buttonOffset, yButton + buttonOffset ); } } m_notificationLog.Draw(); const int maxPlayers = 32; const PlayerEntity* player[maxPlayers] = { NULL }; int numPlayers = m_state.GetEntitiesWithType(player, maxPlayers); // Show the players. const int playerBoxHeight = 150; glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glLineWidth(1); glBegin(GL_QUADS); for (int i = 0; i < numPlayers; ++i) { int x = m_xSize - 300; int y = 10 + (playerBoxHeight + 15) * i; glVertex2i( x, y ); glVertex2i( m_xSize, y ); glVertex2i( m_xSize, y + playerBoxHeight ); glVertex2i( x, y + playerBoxHeight ); } glEnd(); glColor(0xFF86DDEE); glBegin(GL_LINE_LOOP); for (int i = 0; i < numPlayers; ++i) { int x = m_xSize - 300; int y = 10 + (playerBoxHeight + 15) * i; glVertex2i( x, y ); glVertex2i( m_xSize, y ); glVertex2i( m_xSize, y + playerBoxHeight ); glVertex2i( x, y + playerBoxHeight ); } glEnd(); glEnable(GL_TEXTURE_2D); glColor(0xFFFFFFFF); const int scaledAgentWidth = (m_agentTexture.xSize * fontHeight) / m_agentTexture.ySize; const int scaledHouseWidth = (m_buildingHouseTexture.xSize * fontHeight) / m_buildingHouseTexture.ySize; const int scaledIntelWidth = (m_intelTexture.xSize * fontHeight) / m_intelTexture.ySize; for (int i = 0; i < numPlayers; ++i) { Render_DrawSprite(m_playerPortraitTexture, m_xSize - 290, 20 + (playerBoxHeight + 15) * i); int offset = 0; if (player[i]->m_hackingBank) { Render_DrawSprite(m_playerBankHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerBankHackedTexture.ySize); offset += m_playerBankHackedTexture.xSize; } if (player[i]->m_hackingTower) { Render_DrawSprite(m_playerCellHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerCellHackedTexture.ySize); offset += m_playerCellHackedTexture.xSize; } if (player[i]->m_hackingPolice) { Render_DrawSprite(m_playerPoliceHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerPoliceHackedTexture.ySize); offset += m_playerPoliceHackedTexture.xSize; } Render_DrawSprite(m_agentTexture, m_xSize - 280, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledAgentWidth, fontHeight); Render_DrawSprite(m_buildingHouseTexture, m_xSize - 180, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledHouseWidth, fontHeight); Render_DrawSprite(m_intelTexture, m_xSize - 80, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledIntelWidth, fontHeight); } Font_BeginDrawing(m_font); glColor(0xFF000000); for (int i = 0; i < numPlayers; ++i) { Font_DrawText(player[i]->m_name, m_xSize - m_playerPortraitTexture.xSize - 60, 20 + (playerBoxHeight + 15) * i); char buffer[32]; sprintf(buffer, "x%d", player[i]->m_numAgents); Font_DrawText(buffer, m_xSize - 280 + scaledAgentWidth + 5, playerBoxHeight - 25 + (playerBoxHeight + 15) * i); sprintf(buffer, "x%d", player[i]->m_numSafeHouses); Font_DrawText(buffer, m_xSize - 180 + scaledHouseWidth + 5, playerBoxHeight - 25 + (playerBoxHeight + 15) * i); sprintf(buffer, "x%d", player[i]->m_numIntels); Font_DrawText(buffer, m_xSize - 80 + scaledHouseWidth + 5, playerBoxHeight - 25 + (playerBoxHeight + 15) * i); } glColor(0xFF000000); Font_EndDrawing(); // Tool tip. const char* toolTip = NULL; if (m_hoverButton == ButtonId_Capture) { toolTip = "Search and capture any enemy agents\nat this location"; } else if (m_hoverButton == ButtonId_Stakeout) { toolTip = "Put the agent into stakeout mode\nso any enemy agents passing through\nthe stop will be detected"; } else if (m_hoverButton == ButtonId_Infiltrate) { toolTip = "Search and infiltrate enemy safe\nhouses at this location"; } else if (m_hoverButton == ButtonId_Hack) { toolTip = "Hack the building to gather\ninformation"; } else if (m_hoverButton == ButtonId_Intel) { toolTip = "Pickup/drop the intel"; } if (toolTip != NULL) { int xTipSize = 510; int yTipSize = 120; int xTip = 10; int yTip = m_ySize - yStatusBarSize - yTipSize - 10; glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glLineWidth(1); glBegin(GL_QUADS); glVertex2i( xTip, yTip ); glVertex2i( xTip + xTipSize, yTip ); glVertex2i( xTip + xTipSize, yTip + yTipSize ); glVertex2i( xTip, yTip + yTipSize ); glEnd(); glColor(0xFF86DDEE); glBegin(GL_LINE_LOOP); glVertex2i( xTip, yTip ); glVertex2i( xTip + xTipSize, yTip ); glVertex2i( xTip + xTipSize, yTip + yTipSize ); glVertex2i( xTip, yTip + yTipSize ); glEnd(); glColor(0xFF000000); Font_BeginDrawing(m_font); Font_DrawText(toolTip, xTip + 10, yTip + 10); Font_EndDrawing(); } glEnable(GL_TEXTURE_2D); glColor(0xFFFFFFFF); for (int i = 0; i < numPlayers; ++i) { if (player[i]->m_eliminated) { Render_DrawSprite(m_playerEliminatedTexture, m_xSize - 250, 20 + (playerBoxHeight + 15) * i); } } m_screenParticles.Draw(); if (m_gameState == GameState_GameOver) { const int windowWidth = 200; const int widonwHeight = 100; glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glLineWidth(1); glBegin(GL_QUADS); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glEnd(); glColor(0xFF86DDEE); glBegin(GL_LINE_LOOP); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glEnd(); glEnable(GL_TEXTURE_2D); Font_BeginDrawing(m_font); const char* text = m_isWinner ? "You WIN!" : "GAME OVER"; glColor(0xff000000); int textWidth = Font_GetTextWidth(m_font, text); Font_DrawText(text, (m_xSize - textWidth)/2, (m_ySize - fontHeight)/2); Font_EndDrawing(); } }