/*********************************************************** switch gui helpers ***********************************************************/ void LbaNetEngine::SwitchGuiToChooseWorld() { if(m_currentstate == EChoosingWorld) return; m_lbaNetModel.Pause(); //m_lbaNetModel.ResetZoom(); PlayMenuMusic(); m_gui_handler.SwitchGUI(1); m_oldstate = m_currentstate; m_currentstate = EChoosingWorld; }
void Show_Presents(void) { int timeRemaining = 8*ONE_FIXED-ONE_FIXED/2; do { CheckForWindowsMessages(); { char *textPtr = GetTextString(TEXTSTRING_FOXINTERACTIVE); int y = (480-AvPMenuGfxStorage[AVPMENUGFX_PRESENTS].Height)/2; PlayMenuMusic(); DrawMainMenusBackdrop(); if (timeRemaining > 6*ONE_FIXED) { // DrawGraphicWithFadingLevel(&Starfield_Backdrop,timeRemaining-7*ONE_FIXED); // DrawAvPMenuGfx_Faded(AVPMENUGFX_BACKDROP, 0, 0, 15*ONE_FIXED-timeRemaining*2,AVPMENUFORMAT_LEFTJUSTIFIED); FadedScreen((15*ONE_FIXED-timeRemaining*2)/3); } else if (timeRemaining > 5*ONE_FIXED) { RenderMenuText(textPtr,MENU_CENTREX,y,6*ONE_FIXED-timeRemaining,AVPMENUFORMAT_CENTREJUSTIFIED); } else if (timeRemaining > 4*ONE_FIXED) { RenderMenuText(textPtr,MENU_CENTREX,y,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); } else if (timeRemaining > 3*ONE_FIXED) { RenderMenuText(textPtr,MENU_CENTREX,y,timeRemaining-3*ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); } FlipBuffers(); } #if ALLOW_SKIP_INTRO DirectReadKeyboard(); #endif FrameCounterHandler(); timeRemaining-=NormalFrameTime; } #if ALLOW_SKIP_INTRO while((timeRemaining>0) && !GotAnyKey); #else while(timeRemaining>0);// && !GotAnyKey); #endif }
/*********************************************************** switch gui helpers ***********************************************************/ void LbaNetEngine::SwitchGuiToLogin() { if(m_currentstate == ELogin) return; // disconnect from servers m_Chatcl->CloseConnection(); m_Gamecl->CloseConnection(); // clean up the world on disconnect m_lbaNetModel.CleanupWorld(); PlayMenuMusic(); m_gui_handler.SwitchGUI(0); m_oldstate = m_currentstate; m_currentstate = ELogin; }
void Show_ARebellionGame(void) { int timeRemaining = 7*ONE_FIXED; do { CheckForWindowsMessages(); { char *textPtr = GetTextString(TEXTSTRING_PRESENTS); int y = (480-AvPMenuGfxStorage[AVPMENUGFX_AREBELLIONGAME].Height)/2; DrawMainMenusBackdrop(); // DrawAvPMenuGfx(AVPMENUGFX_BACKDROP, 0, 0, ONE_FIXED+1,AVPMENUFORMAT_LEFTJUSTIFIED); PlayMenuMusic(); if (timeRemaining > 13*ONE_FIXED/2) { // DrawAvPMenuGfx(AVPMENUGFX_AREBELLIONGAME, MENU_CENTREX, y, 14*ONE_FIXED-timeRemaining*2,AVPMENUFORMAT_CENTREJUSTIFIED); RenderMenuText(textPtr,MENU_CENTREX,y,14*ONE_FIXED-timeRemaining*2,AVPMENUFORMAT_CENTREJUSTIFIED); // DrawGraphicWithAlphaChannel(&RebellionLogo,timeRemaining*2-13*ONE_FIXED); } else if (timeRemaining > 5*ONE_FIXED) { // DrawAvPMenuGfx(AVPMENUGFX_AREBELLIONGAME, MENU_CENTREX, y, ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); RenderMenuText(textPtr,MENU_CENTREX,y,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); // DrawGraphicWithAlphaChannel(&RebellionLogo,0); } else if (timeRemaining > 3*ONE_FIXED) { // DrawAvPMenuGfx(AVPMENUGFX_AREBELLIONGAME, MENU_CENTREX, y, (timeRemaining-3*ONE_FIXED)/2,AVPMENUFORMAT_CENTREJUSTIFIED); RenderMenuText(textPtr,MENU_CENTREX,y,(timeRemaining-3*ONE_FIXED)/2,AVPMENUFORMAT_CENTREJUSTIFIED); // DrawGraphicWithAlphaChannel(&RebellionLogo, ONE_FIXED - (timeRemaining-3*ONE_FIXED)/2); } FlipBuffers(); } DirectReadKeyboard(); FrameCounterHandler(); timeRemaining-=NormalFrameTime; } #if ALLOW_SKIP_INTRO while((timeRemaining>0) && !GotAnyKey); #else while(timeRemaining>0);// && !GotAnyKey); #endif }
void Show_AvPLogo(void) { int timeRemaining = 5*ONE_FIXED; do { CheckForWindowsMessages(); { int y = (480-AvPMenuGfxStorage[AVPMENUGFX_ALIENSVPREDATOR].Height)/2; DrawMainMenusBackdrop(); // DrawAvPMenuGfx(AVPMENUGFX_BACKDROP, 0, 0, ONE_FIXED+1,AVPMENUFORMAT_LEFTJUSTIFIED); PlayMenuMusic(); if (timeRemaining > 9*ONE_FIXED/2) { DrawAvPMenuGfx(AVPMENUGFX_ALIENSVPREDATOR, MENU_CENTREX, y, -timeRemaining*2+10*ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); } else if (timeRemaining > 4*ONE_FIXED) { DrawAvPMenuGfx(AVPMENUGFX_ALIENSVPREDATOR, MENU_CENTREX, y, ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); } else { DrawAvPMenuGfx(AVPMENUGFX_ALIENSVPREDATOR, MENU_CENTREX, y, timeRemaining/4,AVPMENUFORMAT_CENTREJUSTIFIED); timeRemaining-=NormalFrameTime/4; } FlipBuffers(); } DirectReadKeyboard(); FrameCounterHandler(); timeRemaining-=NormalFrameTime; } #if ALLOW_SKIP_INTRO while((timeRemaining>0) && !GotAnyKey); #else while(timeRemaining>0);// && !GotAnyKey); #endif }
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HGLRC hRC; HDC hDC = NULL; int width, height; int x_screenLocation, y_screenLocation; static bool isMenu = true; const char RESHEADER[] = "Resolution"; const char RESSAVEDHEADER[] = "Resolution Save..."; const char RESWRTFAIL[] = "Game needs to be run from hard drive or other writeable media."; switch(message) { case WM_CREATE: hDC = GetDC(hwnd); g_HDC = hDC; SetupPixelFormat(hDC); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); // Initialise sphere chain to avoid crashes. for(counter = 0; counter < CHAINMAXLENGTH; counter++) ASphere[counter] = NULL; break; case WM_KEYDOWN: switch(wParam) { case VK_ESCAPE: switch(iFeatureIsInitialised) { case 1: case 2: case 3: case 4: case 5: currentMenu = 2; PostMessage(hwnd, ID_GAME_MENU, wParam, lParam); break; case 6: case 7: case 8: currentMenu = 3; PostMessage(hwnd, ID_GAME_MENU, wParam, lParam); break; case 9: currentMenu = 0; PostMessage(hwnd, ID_GAME_MENU, wParam, lParam); break; default: break; } break; case VK_F1: if(!isMenu) { if(WriteResFile(640, 480)) MessageBox(NULL, "Game will now play at 640 x 480 resolution.", RESHEADER, MB_OK); else MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK); if(!CheckCurrentResolution(640, 480)) ChangeScreenResolution(640, 480); } break; case VK_F2: if(!isMenu) { if(WriteResFile(800, 600)) MessageBox(NULL, "Game will now play at 800 x 600 resolution.", RESHEADER, MB_OK); else MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK); if(!CheckCurrentResolution(800, 600)) ChangeScreenResolution(800, 600); } break; case VK_F3: if(!isMenu) { if(WriteResFile(1024, 768)) MessageBox(NULL, "Game will now play at 1024 x 768 resolution.", RESHEADER, MB_OK); else MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK); if(!CheckCurrentResolution(1024, 768)) ChangeScreenResolution(1024, 768); } break; case VK_F4: if(!isMenu) { if(WriteResFile(1280, 1024)) MessageBox(NULL, "Game will now play at 1280 x 1024 resolution.", RESHEADER, MB_OK); else MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK); if(!CheckCurrentResolution(1280, 1024)) ChangeScreenResolution(1280, 1024); } break; default: break; } break; case WM_LBUTTONDOWN: Sleep(400); // Retains mouse coords for 2/5 of a second to prevent filtering through to last menu. x_screenLocation = LOWORD(lParam); y_screenLocation = HIWORD(lParam); g_x_region = x_screenLocation; g_y_region = y_screenLocation; g_wParam = wParam; g_lParam = lParam; break; case ID_GAME_MENU: if(!CheckCurrentResolution(800, 600) && !windowed) ChangeScreenResolution(800, 600); DisablePriorOpenGLCommands(); PlaySound(NULL, NULL, SND_NODEFAULT); // Stop previous sound! InitialiseAGUIMenu(); PlayMenuMusic(); iFeatureIsInitialised = 0; ShowCursor(true); isMenu = true; break; case SPHR_STANDARD: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildStandardSphereChain(); PlayStandardMusic(); iFeatureIsInitialised = 1; ShowCursor(false); isMenu = false; break; case SPHR_SUPBLAST: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildSphereChainWithPowerUp(0.0f, 0.0f, 0.7f, "supblast.bmp"); PlaySupremeBlastMusic(); iFeatureIsInitialised = 2; ShowCursor(false); isMenu = false; break; case SPHR_REBIRTH: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildSphereChainWithPowerUp(0.7f, 0.0f, 0.0f, "rebirth.bmp"); PlayRebirthMusic(); iFeatureIsInitialised = 3; ShowCursor(false); isMenu = false; break; case SPHR_SBREBTH: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildSphereChainWithPowerUp(0.7f, 0.0f, 0.7f, "sbrebirth.bmp"); PlaySupaFlyMusic(); iFeatureIsInitialised = 4; ShowCursor(false); isMenu = false; break; case SPHR_INVISIBL: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildSphereChainWithPowerUp(0.7f, 0.0f, 0.7f, "invisibility.bmp"); PlayInvisibilityMusic(); iFeatureIsInitialised = 5; ShowCursor(false); isMenu = false; break; case PU_SUPBLAST: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildPowerUp("supblast.bmp"); PlaySupremeBlastMusic(); iFeatureIsInitialised = 6; ShowCursor(false); isMenu = false; break; case PU_REBIRTH: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildPowerUp("rebirth.bmp"); PlayRebirthMusic(); iFeatureIsInitialised = 7; ShowCursor(false); isMenu = false; break; case PU_INVISIBL: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_BuildPowerUp("invisibility.bmp"); PlayInvisibilityMusic(); iFeatureIsInitialised = 8; ShowCursor(false); isMenu = false; break; case ENV_PAGOE: if(!windowed) FetchResolution(); DisablePriorOpenGLCommands(); dik_InitialisePostApocalypticGarderOfEden(); PlayPAGoEMusic(); iFeatureIsInitialised = 9; ShowCursor(false); isMenu = false; break; case WM_SIZE: height = HIWORD(lParam); width = LOWORD(lParam); if(height == 0) height = 1; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(54.0f, (GLfloat) width/(GLfloat) height, 1.0f, 3000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return 0; break; case WM_DESTROY: CleanUpLoadTextures(); FreeChainMemory(); DeleteDirectSoundResources(); DeleteDirectInputResources(); DisablePriorOpenGLCommands(); DestroyFont(); wglMakeCurrent(hDC, NULL); wglDeleteContext(hRC); PostQuitMessage(0); break; case WM_QUIT: DestroyWindow(hwnd); break; default: return DefWindowProc(hwnd, message, wParam, lParam); break; } return DefWindowProc(hwnd, message, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow = SW_SHOW) { HWND hwnd; MSG msg; WNDCLASSEX wcl; RECT windowRect; DWORD dwExStyle; DWORD dwStyle; int mbResponse; // To remind myself if I'm using the debug build! #ifdef _DEBUG MessageBox(NULL, "This is the DEBUG build!", "DEBUG!", MB_OK); #endif mbResponse = MessageBox(NULL, "Would you like to play in windowed mode?", "AntiVirus 2 Game Demo Display Mode", MB_ICONQUESTION | MB_YESNOCANCEL | MB_DEFBUTTON1); switch(mbResponse) { case IDYES: windowed = true; break; case IDNO: windowed = false; break; case IDCANCEL: exit(0); break; default: break; } // Define a window class. wcl.cbSize = sizeof(WNDCLASSEX); wcl.hInstance = hInstance; wcl.lpszClassName = szWinName; wcl.lpfnWndProc = WindowFunc; wcl.style = CS_HREDRAW | CS_VREDRAW; wcl.hCursor = (HCURSOR) LoadImage(hInstance, MAKEINTRESOURCE(IDC_CURSOR1), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE); wcl.hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); wcl.lpszMenuName = NULL; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hbrBackground = reinterpret_cast <HBRUSH> (GetStockObject(BLACK_BRUSH)); // Adjust size in pixels for performance reasons. windowRect.left = 0; windowRect.top = 0; windowRect.right = 800; windowRect.bottom = 600; // Register the window class. if(!RegisterClassEx(&wcl)) return 0; if(windowed) { SwitchToWindowed(hwnd, hInstance); ShowWindow(hwnd, SW_SHOW); } else { // Switch to full screen. if(!SwitchToFullScreen(hwnd, hInstance, windowRect, dwExStyle, dwStyle, windowRect.right, windowRect.bottom, 32)) MessageBox(NULL, "Switch to full screen failed.", "Full Screen Error...", MB_OK); ShowWindow(hwnd, SW_MAXIMIZE); } ghwnd = hwnd; UpdateWindow(hwnd); // Start off and initialise game here! InitialiseAGUIMenu(); iFeatureIsInitialised = 0; // Do not invoke any gameplay modes. // Display the splashscreen! ShowCursor(false); if(windowed) SplashScreenInWindow(); else SplashScreen(); Sleep(4000); ShowCursor(true); // Initialise DirectSound and DiectInput components of DirectX if(!(DirectSoundInitialisation() && DirectInputDevicesInitialisation(hInstance))) { MessageBox(hwnd, "Program shutting down.", "DirectX Unrecoverable Error", MB_OK | MB_ICONINFORMATION); DeleteDirectSoundResources(); DeleteDirectInputResources(); exit(0); } // Fire up the menu beat! PlayMenuMusic(); // Initialise player position in the environment. SphereObjectCoords[0].xcoord = 780.0f; SphereObjectCoords[0].ycoord = 270.0f; SphereObjectCoords[0].zcoord = -500.0f; FetchCurrentTime(); ZeroMemory(&msg, sizeof(MSG)); while(msg.message != WM_DESTROY) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else if(CheckTimeDelta()) GameLoopBody(hwnd); } ChangeDisplaySettings(NULL, 0); // Restore original screen resolution. return (int) msg.wParam; }