本文整理汇总了C++中GameLoop函数的典型用法代码示例。如果您正苦于以下问题:C++ GameLoop函数的具体用法?C++ GameLoop怎么用?C++ GameLoop使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GameLoop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayTodaysHighScores
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);
}
}
示例2: WinMain
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;
}
示例3: while
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();
}
示例4: GameLoop
void Game::Start() {
if (InitializeGameObjects() == true) {
GameLoop();
}
}
示例5: main
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();
}
示例6: ScreenDogfightScores
void ScreenDogfightScores(void)
{
GameLoopData gData = GameLoopDataNew(
NULL, GameLoopWaitForAnyKeyOrButtonFunc, NULL, DogfightScoresDraw);
GameLoop(&gData);
SoundPlay(&gSoundDevice, StrSound("mg"));
}
示例7: netSendThread
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();
}
示例8: main
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;
}
示例9: main
int main(int argc, char* argv[])
{
auto game = Game();
game.GameLoop(argc, argv);
return 0;
}
示例10: srand
INT cGame::Run()
{
// seed rand
srand((unsigned)timeGetTime());
StartGame();
return GameLoop();
}
示例11: while
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();
}
示例12: WinMain
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;
}
示例13: PlayerPaddle
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();
}
示例14: ResourceManager
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();
}
示例15: main
void main() // Main function (standard C entry point)
{
badge_setup(); // Call badge setup
Init(); // Initialize the game board
GameLoop(); // Run the game loop
}