您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GameLoop函数代码示例

51自学网 2021-06-01 21:02:55
  C++
这篇教程C++ GameLoop函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了GameLoop函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,


示例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);	//terminateDEATH:	GameDestroy();	return 0;}
开发者ID:PtrickH,项目名称:homies,代码行数:26,


示例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,


示例4: GameLoop

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


示例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,


示例6: ScreenDogfightScores

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


示例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,


示例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,


示例9: main

int main(int argc, char* argv[]){	auto game = Game();	game.GameLoop(argc, argv);	return 0;}
开发者ID:PawelTroka,项目名称:LogicalGamesEnginesGenerator,代码行数:7,


示例10: srand

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


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例21: Player

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();}
开发者ID:paulhunter,项目名称:ROU,代码行数:26,


示例22: MenuLoop

void MenuLoop(MenuSystem *menu){	CASSERT(menu->exitTypes.size > 0, "menu has no exit types");	GameLoopData gData = GameLoopDataNew(		menu, MenuUpdate, menu, MenuDraw);	GameLoop(&gData);}
开发者ID:Wuzzy2,项目名称:cdogs-sdl,代码行数:7,


示例23: BE_ST_PollEvents

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();        }    }}
开发者ID:roman-murashov,项目名称:Commander-Genius,代码行数:28,


示例24: InitSystems

// This runs the gamevoid 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();}
开发者ID:Teh-Lemon,项目名称:Game-Engine,代码行数:26,


示例25: while

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;}
开发者ID:viticm,项目名称:pap2,代码行数:27,


示例26: PlayerPaddle

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();}
开发者ID:mihhaiii,项目名称:pong-game,代码行数:31,


示例27: main

int main(int argc, char * argv[]) {	ServerManager * servBoss;	Client testClient;	Client testClient2;	Account toddAccount("Todd", "MyPassword", "127.0.0.1", "[email
C++ GameOver函数代码示例
C++ GameEventSpawn函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。