• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GameLoop函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GameLoop函数的典型用法代码示例。如果您正苦于以下问题:C++ GameLoop函数的具体用法?C++ GameLoop怎么用?C++ GameLoop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GameLoop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
	}
}
开发者ID:ChunHungLiu,项目名称:cdogs-sdl,代码行数:25,代码来源:hiscores.c


示例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;
}
开发者ID:PtrickH,项目名称:homies,代码行数:26,代码来源:homies.cpp


示例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();
}
开发者ID:BWilson1989,项目名称:TacticalRPG,代码行数:27,代码来源:Game.cpp


示例4: GameLoop

void Game::Start() {
    
    if (InitializeGameObjects() == true) {
        GameLoop();
    }
    
}
开发者ID:sasoh,项目名称:ArkanoidClone,代码行数:7,代码来源:Game.cpp


示例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();
}
开发者ID:felipeprov,项目名称:sethengine,代码行数:29,代码来源:main.c


示例6: ScreenDogfightScores

void ScreenDogfightScores(void)
{
	GameLoopData gData = GameLoopDataNew(
		NULL, GameLoopWaitForAnyKeyOrButtonFunc, NULL, DogfightScoresDraw);
	GameLoop(&gData);
	SoundPlay(&gSoundDevice, StrSound("mg"));
}
开发者ID:Wuzzy2,项目名称:cdogs-sdl,代码行数:7,代码来源:briefing_screens.c


示例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(); 
}
开发者ID:crazypants173,项目名称:CptS-122-PA8,代码行数:27,代码来源:game.cpp


示例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;
}
开发者ID:eazygoin67,项目名称:JetFighter,代码行数:32,代码来源:Main.cpp


示例9: main

int main(int argc, char* argv[])
{
	auto game = Game();

	game.GameLoop(argc, argv);
	return 0;
}
开发者ID:PawelTroka,项目名称:LogicalGamesEnginesGenerator,代码行数:7,代码来源:main.cpp


示例10: srand

INT cGame::Run() 
{
	// seed rand
	srand((unsigned)timeGetTime());
	StartGame();
	return GameLoop();
}
开发者ID:cdave1,项目名称:tetris,代码行数:7,代码来源:tetris.cpp


示例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();
}
开发者ID:Easihh,项目名称:laughing-avenger,代码行数:29,代码来源:Game.cpp


示例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;
}
开发者ID:viticm,项目名称:pap2,代码行数:28,代码来源:TestRender.cpp


示例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();
}
开发者ID:JarOfOmens,项目名称:GUI-Project,代码行数:28,代码来源:Game.cpp


示例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();
}
开发者ID:coi2,项目名称:CPP-2D-Engine,代码行数:31,代码来源:Engine.cpp


示例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
}
开发者ID:MatzElectronics,项目名称:Simple-Libraries,代码行数:7,代码来源:Shooter.c


示例16: WinMain

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;
} 
开发者ID:YAZAWA68,项目名称:greedgreen,代码行数:33,代码来源:System.cpp


示例17: ScreenMissionBriefing

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;
}
开发者ID:Wuzzy2,项目名称:cdogs-sdl,代码行数:60,代码来源:briefing_screens.c


示例18: drawBlocks

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();
			}
}
开发者ID:kharazi,项目名称:BlockBreaker,代码行数:35,代码来源:world.cpp


示例19: WinMain

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;
}
开发者ID:wrybri,项目名称:comp4995Research,代码行数:60,代码来源:main2.cpp


示例20: Initialise

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);
}
开发者ID:foundry,项目名称:glTemplate,代码行数:34,代码来源:Game.cpp



注:本文中的GameLoop函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GameOver函数代码示例发布时间:2022-05-30
下一篇:
C++ GameEventSpawn函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap