void DisplayTodaysHighScores(GraphicsDevice *graphics) { int highlights[MAX_LOCAL_PLAYERS]; int idx = 0; for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++) { const PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } highlights[idx] = p->today; } idx = 0; while (idx < MAX_ENTRY && todaysHigh[idx].score > 0) { GraphicsClear(graphics); idx = DisplayPage( "Today's highest score:", idx, todaysHigh, highlights); GameLoopData gData = GameLoopDataNew( NULL, GameLoopWaitForAnyKeyOrButtonFunc, NULL, NULL); GameLoop(&gData); } }
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow) { HWND hwnd; if (FindWindow (WINNAME, WINNAME) != NULL) // Check whether game is already running return 0; // If so, terminate now //initialize! if(GameInit(&hwnd, hinstance) != RETCODE_SUCCESS) goto DEATH; //show window ShowWindow(hwnd, ishow); UpdateWindow(hwnd); //execute game loop GameLoop(hwnd); //terminate DEATH: GameDestroy(); return 0; }
void Game::Initialize (int width, int height, int bitsPerPixel, char* windowTitle) { if (m_initialized) return; m_initialized = true; m_screenWidth = width; m_screenHeight = height; m_bpp = bitsPerPixel; m_windowTitle = windowTitle; m_renderWindow.create (sf::VideoMode(width, height, bitsPerPixel), windowTitle); m_frameRate = FRAME_RATE_CAP; m_renderWindow.setFramerateLimit (m_frameRate); m_timePerFrame = sf::seconds (1.0f / (float)m_frameRate); m_timeSinceLastFrame = sf::Time::Zero; m_clock.restart(); while (m_keepRunning) { GameLoop(); } m_renderWindow.close(); }
void Game::Start() { if (InitializeGameObjects() == true) { GameLoop(); } }
int main(int argc, char* argv[]) { Scene_t* scene; GameObject_t* obj, *target; GameObject_t* camera; printf("SethEngineC starting\n"); GameInit(0); scene = SceneNew("inicio", 0); AddBackgroundcObj(scene); obj = AddMouseObj(scene); AddGenericObj(scene, 0.5, 0.5); AddGenericObj(scene, 0.5, -0.5); AddGenericObj(scene, -0.5, 0.5); //AddGenericObj(scene, 0, 0); AddGuiObj(scene, 2.8, 0.5); AddGuiObj(scene, 2.8, 1.5); AddGuiObj(scene, 2.8, 2); camera = AddCameraObj(scene, obj); UpdateGameObjectWithTarget(obj, camera); GameAddScene(scene); return GameLoop(); }
void ScreenDogfightScores(void) { GameLoopData gData = GameLoopDataNew( NULL, GameLoopWaitForAnyKeyOrButtonFunc, NULL, DogfightScoresDraw); GameLoop(&gData); SoundPlay(&gSoundDevice, StrSound("mg")); }
void Game::StartGame() { if (_gStatus != Starting) // An instance is running return; _mainGameWindow.create(sf::VideoMode(800,600,32), "Mario Clone"); _networking.setDefaultUsernameScore(); sf::Thread netSendThread(Game::runNetworkSend); sf::Thread netRecvThread(Game::runNetworkRecv); netRecvThread.launch(); netSendThread.launch(); _gStatus = Menuing; while(!_isExit) { GameLoop(); } netRecvThread.terminate(); netSendThread.terminate(); _mainGameWindow.close(); }
int main( int argc, char** argv ) { // Create Game Game game; // Initialise Game; Return Failure if we unsuccessful if ( !GameInit(&game) ) return -1; // Load Game Assets; Return Failure if we unsuccessful if ( !GameLoadAssets(&game) ) { // Quit and Return Failure GameQuit(&game); return -2; } // Do Initial Setup of game, after resources are loaded GameSetup(&game); // Enter Main Game Loop GameLoop(&game); // Unload Game Assets GameFreeAssets(&game); // Unload Game Data when Exiting GameQuit(&game); // Return Success return 0; }
int main(int argc, char* argv[]) { auto game = Game(); game.GameLoop(argc, argv); return 0; }
INT cGame::Run() { // seed rand srand((unsigned)timeGetTime()); StartGame(); return GameLoop(); }
void Game::Start(){ if (Static::gameState != NotStarted) return; mainWindow.create(sf::VideoMode(Global::SCREEN_WIDTH, Global::SCREEN_HEIGHT, 32), "Zelda: Final Quest"); Global::gameView.setSize(Global::SCREEN_WIDTH, Global::SCREEN_HEIGHT); Global::gameView.setCenter(Global::SCREEN_WIDTH/2, Global::SCREEN_HEIGHT/2); mainWindow.setView(Global::gameView); mainWindow.setFramerateLimit(Global::FPS_RATE); Static::gameState = LoadSaveMenu; Sound gameSound; while (Static::gameState != Exiting){ timeSinceLastUpdate += timerClock.restart(); fpsTimer += fpsClock.restart(); if (fpsTimer.asMilliseconds() >= FPS_REFRESH_RATE){ std::stringstream title; title << Static::GAME_TITLE << "FPS:" << fpsCounter; mainWindow.setTitle(title.str()); fpsCounter = 0; fpsTimer = sf::Time::Zero; } if (timeSinceLastUpdate.asMilliseconds() >= 1667){ mainWindow.clear(sf::Color::Black); fpsCounter++; timeSinceLastUpdate -= timePerFrame; GameLoop(); } } mainWindow.close(); }
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT) { WNDCLASSEX wc={sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "DX Project 1", NULL}; RegisterClassEx(&wc); HWND hWnd=CreateWindow("DX Project 1", "挺进3D", WS_OVERLAPPEDWINDOW, 50, 50, 500, 500, GetDesktopWindow(), NULL, wc.hInstance, NULL); if(hWnd==NULL) return FALSE; if(SUCCEEDED(InitializeD3D(hWnd))) { ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); if(SUCCEEDED(InitializeVertexBuffer())) { g_pFont=new CFont(g_pD3DDevice, "宋体", 12, true, false, false); GameLoop(); delete g_pFont; } } CleanUp(); UnregisterClass("DX Project 1", wc.hInstance); return 0; }
void Game::Start(void) { if (_gameState != Uninitialized) { std::cout << "_gameState already initialized. Do not call Game::Start() more than one time!" << std::endl; return; } _mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Pang!"); PlayerPaddle *player1 = new PlayerPaddle(); player1->SetPosition((SCREEN_WIDTH / 2), 700); GameBall *ball = new GameBall(); ball->SetPosition((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - 15); _gameObjectManager.Add("Paddle1", player1); _gameObjectManager.Add("Ball", ball); _gameState = Game::ShowingSplash; while (!IsExiting()) { GameLoop(); } _mainWindow.close(); }
void Engine::Initialize(GameProperties props) { this->LaunchMessage(); State.Paused = false; State.Quit = false; Properties = props; Resources = ResourceManager(); Renderer = new RendererSDL(); //Renderer = new RendererOpenGL(); if(SDL_Init( SDL_INIT_VIDEO ) < 0) { printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError()); return; } Renderer->Initialize(); DefaultProperties(); Precache(); Start(); GameLoop(); Cleanup(); SDL_Quit(); }
void Game::Start() { if (_gameState != UNITIALIZED) return; _mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Platformer Proto 01"); _mainWindow.setKeyRepeatEnabled(false); _frameSpeed = 30.0f; _gameState = PLAYING; // set up test tiles //Tile *newTile = new Tile("Resources/Textures/green.jpg", true); //newTile->Load("Resources/Textures/green.jpg"); //_gameObjectManager.Add("Green Tile", newTile); _levelManager.Load("Resources/Maps/Level_Map_1.txt"); // main loop while (!IsExiting()) { GameLoop(); } _mainWindow.close(); } // end Start
void main() // Main function (standard C entry point) { badge_setup(); // Call badge setup Init(); // Initialize the game board GameLoop(); // Run the game loop }
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){ SetWindowText("Title"); SetGraphMode(WINDOW_WIDTH , WINDOW_HEIGHT,32 ); ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK ); int LoadImage = LoadGraph("Natsuiro/BLOCK/load.png"); DrawExtendGraph(0,0,WINDOW_WIDTH,WINDOW_HEIGHT, LoadImage ,false); ScreenFlip(); SetTransColor(255,0,255); Awake(); long long TIME = GetNowHiPerformanceCount(); # if BENCHMARK == TRUE long long int count = GetNowCount(); # endif while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 && !CheckHitKey(KEY_INPUT_ESCAPE) ){ GameLoop(); Sleep( (unsigned long)max( 16 - (int)( GetNowHiPerformanceCount() - TIME ) / 1000 , 0 ) ); TIME = GetNowHiPerformanceCount(); # if BENCHMARK == TRUE DrawFormatString(WINDOW_WIDTH-200,0,BLACK,"FPS %d (%dms)", (int)( 1000/( GetNowCount() - count ) ) , GetNowCount() - count ); count = GetNowCount(); # endif } DxLib_End(); return 0; }
bool ScreenMissionBriefing(const struct MissionOptions *m) { const int w = gGraphicsDevice.cachedConfig.Res.x; const int h = gGraphicsDevice.cachedConfig.Res.y; const int y = h / 4; MissionBriefingData mData; memset(&mData, 0, sizeof mData); mData.IsOK = true; // Title CMALLOC(mData.Title, strlen(m->missionData->Title) + 32); sprintf(mData.Title, "Mission %d: %s", m->index + 1, m->missionData->Title); mData.TitleOpts = FontOptsNew(); mData.TitleOpts.HAlign = ALIGN_CENTER; mData.TitleOpts.Area = gGraphicsDevice.cachedConfig.Res; mData.TitleOpts.Pad.y = y - 25; // Password if (m->index > 0) { sprintf( mData.Password, "Password: %s", gAutosave.LastMission.Password); mData.PasswordOpts = FontOptsNew(); mData.PasswordOpts.HAlign = ALIGN_CENTER; mData.PasswordOpts.Area = gGraphicsDevice.cachedConfig.Res; mData.PasswordOpts.Pad.y = y - 15; } // Split the description, and prepare it for typewriter effect mData.TypewriterCount = 0; // allow some slack for newlines CMALLOC(mData.Description, strlen(m->missionData->Description) * 2 + 1); CCALLOC(mData.TypewriterBuf, strlen(m->missionData->Description) * 2 + 1); // Pad about 1/6th of the screen width total (1/12th left and right) FontSplitLines(m->missionData->Description, mData.Description, w * 5 / 6); mData.DescriptionPos = Vec2iNew(w / 12, y); // Objectives mData.ObjectiveDescPos = Vec2iNew(w / 6, y + FontStrH(mData.Description) + h / 10); mData.ObjectiveInfoPos = Vec2iNew(w - (w / 6), mData.ObjectiveDescPos.y + FontH()); mData.ObjectiveHeight = h / 12; mData.MissionOptions = m; GameLoopData gData = GameLoopDataNew( &mData, MissionBriefingUpdate, &mData, MissionBriefingDraw); GameLoop(&gData); if (mData.IsOK) { SoundPlay(&gSoundDevice, StrSound("mg")); } CFREE(mData.Title); CFREE(mData.Description); CFREE(mData.TypewriterBuf); return mData.IsOK; }
world::world () { // creating the game window GameWindow.create(sf::VideoMode(500,500),"Brick Breaker v0.1"); // showing the splash screen GameSplashScreen = new SplashScreen ; GameSplashScreen->show("welcome.png",GameWindow); delete GameSplashScreen ; //showing the main menu MenuScreen = new menu ; MenuScreen->show(GameWindow); delete MenuScreen ; //setting up the blocks sf::Texture BlockTexture; BlockTexture.loadFromFile("block.png"); for (int i = 0 ; i < 5 ; i++) { for (int j = 0 ; j < 5 ; j++ ) { blocks[i][j].GameObjectSprite.setTexture(BlockTexture); blocks[i][j].setPositon(i*100,j*25); } } drawBlocks(); GameWindow.display(); // entering the game loop while(true) { GameLoop(); } }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pstrCmdLine, int iCmdShow){ HWND hWnd; MSG msg; WNDCLASSEX wc; static char strAppName[] = "First Windows App, Zen Style"; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hIconSm = LoadIcon(NULL, IDI_HAND); wc.hCursor = LoadCursor(NULL, IDC_CROSS); wc.lpszMenuName = NULL; wc.lpszClassName = strAppName; RegisterClassEx(&wc); hWnd = CreateWindowEx(NULL, strAppName, strAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 512,512, NULL, NULL, hInstance, NULL); g_hWndMain = hWnd;//set our global window handle ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); if(FAILED(GameInit())){;//initialize Game SetError("Initialization Failed"); GameShutdown(); return E_FAIL; } while(TRUE){ if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){ if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else{ GameLoop(); } } GameShutdown();// clean up the game return msg.wParam; }
WPARAM Game::Execute() { m_pHighResolutionTimer = new CHighResolutionTimer; m_gameWindow.Init(m_hHinstance); if(!m_gameWindow.Hdc()) { return 1; } Initialise(); m_pHighResolutionTimer->Start(); MSG msg; while(1) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } else if (m_bAppActive) { GameLoop(); } else Sleep(200); // Do not consume processor power if application isn't active } m_gameWindow.Deinit(); return(msg.wParam); }
void Game::Start(void) { if(_gameState != Uninitialized) return; _mainWindow.Create(sf::VideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,32),"Test Game"); _mainWindow.SetFramerateLimit(60); _mainWindow.Clear(sf::Color(0,0,0)); Player *player1 = new Player(); player1->SetPosition((SCREEN_WIDTH/2),(SCREEN_HEIGHT/2)); _gameObjectManager.Add("Player",player1); _gameState= Game::Playing; while(!IsExiting()) { GameLoop(); } _mainWindow.Close(); }
void MenuLoop(MenuSystem *menu) { CASSERT(menu->exitTypes.size > 0, "menu has no exit types"); GameLoopData gData = GameLoopDataNew( menu, MenuUpdate, menu, MenuDraw); GameLoop(&gData); }
void DreamsEngine::ponder(const float deltaT) { if(!mResourcesLoaded) return; std::vector<SDL_Event> evVec; gInput.readSDLEventVec(evVec); for(SDL_Event event : evVec) { BE_ST_PollEvents(event); } // Change that gGameState stuff to have more depth in the code if(gGameState == INTRO_TEXT) // Where the shareware test is shown { mpScene->ponder(deltaT); } else { if(!mpPlayLoopThread) { GameLoop(); } } }
// This runs the game void MainGame::Run() { InitSystems(); // temp _sprites.push_back(new Sprite()); _sprites.back()->Init(-1.0f, -1.0f, 1.0f, 1.0f, "Textures/kumiko.png"); _sprites.push_back(new Sprite()); _sprites.back()->Init(0.0f, -1.0f, 1.0f, 1.0f, "Textures/kumiko.png"); _sprites.push_back(new Sprite()); _sprites.back()->Init(0.0f, 0.0f, 1.0f, 1.0f, "Textures/kumiko.png"); for (int i = 0; i < 10; i++) { _sprites.push_back(new Sprite()); _sprites.back()->Init(-1.0f, 0.0f, 1.0f, 1.0f, "Textures/kumiko.png"); } //_playerTexture = ImageLoader::LoadPNG("Textures/kumiko.png"); //This only returns when the game ends GameLoop(); }
int KMonster::ThreadFunction() { int nRetCode = FALSE; LOGIN_TYPE nLoginType = ltConnectTo; int nConnectCount = 0; while (!m_nExitFlag) { ++nConnectCount; nRetCode = Login(nLoginType); if (nRetCode) { GameLoop(); nLoginType = ltReconnectTo; nConnectCount = 0; } if (!m_MonsterParam.nReconnect || nConnectCount > 10) { break; } //printf("ReConnect Count:%d\n", nConnectCount); } return TRUE; }
void Game::Start() { if (_gameState != Uninitialized) return; _mainWindow.create(sf::VideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,32),"BananaGame"); _gameState = ShowingSplash; PlayerPaddle* pl1 = new PlayerPaddle(); pl1->SetPosition(SCREEN_WIDTH/2,530); PlayerPaddle* pl2 = new PlayerPaddle(); pl2->SetPosition(SCREEN_WIDTH/2,50); AIPaddle* comp = new AIPaddle(); comp->SetPosition(SCREEN_WIDTH/2,50); GameBall* ball = new GameBall(); ball->SetPosition(SCREEN_WIDTH/2,SCREEN_HEIGHT/2); _gameObjectManager.Add("Player1",pl1); // _gameObjectManager.Add("Player2",pl2); _gameObjectManager.Add("Comp",comp); _gameObjectManager.Add("Ball",ball); while (!IsExiting()) { GameLoop(); } _mainWindow.close(); }
int main(int argc, char * argv[]) { ServerManager * servBoss; Client testClient; Client testClient2; Account toddAccount("Todd", "MyPassword", "127.0.0.1", "*****@*****.**", true); Account willAccount("Will", "HisPassword", "127.0.0.1", "*****@*****.**", true); Account jonAccount("Jon", "TurtleFarts", "127.0.0.1", "*****@*****.**", true); Account hardikaAccount("Hardika", "Kolaches", "127.0.0.1", "*****@*****.**", true); servBoss = servBoss->get(); servBoss->registerClientManager(); servBoss->AddAccount( toddAccount ); servBoss->AddAccount( willAccount ); servBoss->AddAccount( jonAccount ); servBoss->AddAccount( hardikaAccount ); servBoss->acquireClient(testClient); servBoss->acquireClient(testClient2); servBoss->setRunning(); cout << "H@x0rZ! Server is up and running on default port 9999" << endl; cout << "Server Initialization success is " << (servBoss->isRunning()? "True" : "False") << endl; GameLoop( *servBoss ); return 0; }
bool PlayerSelection(void) { PlayerSelectionData data; memset(&data, 0, sizeof data); data.IsOK = true; GetDataFilePath(data.prefixes, "data/prefixes.txt"); GetDataFilePath(data.suffixes, "data/suffixes.txt"); GetDataFilePath(data.suffixnames, "data/suffixnames.txt"); NameGenInit(&data.g, data.prefixes, data.suffixes, data.suffixnames); // Create selection menus for each local player for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++) { PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } PlayerSelectMenusCreate( &data.menus[idx], GetNumPlayers(false, false, true), idx, i, &gEventHandlers, &gGraphicsDevice, &data.g); } if (!gCampaign.IsClient) { NetServerOpen(&gNetServer); } GameLoopData gData = GameLoopDataNew( &data, PlayerSelectionUpdate, &data, PlayerSelectionDraw); GameLoop(&gData); if (data.IsOK) { for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++) { PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } // For any player slots not picked, turn them into AIs if (p->inputDevice == INPUT_DEVICE_UNSET) { PlayerSetInputDevice(p, INPUT_DEVICE_AI, 0); } } } for (int i = 0; i < GetNumPlayers(false, false, true); i++) { MenuSystemTerminate(&data.menus[i].ms); } NameGenTerminate(&data.g); return data.IsOK; }
void Game::Start(void) { if(_gameState!=Uninitialized) return; _gameState=ShowingSplash; while(!IsExiting()) { GameLoop(); } }