コード例 #1
0
ファイル: main.cpp プロジェクト: Fujisawa4654/CODEFOO2
int main (int argc, char **argv){
	SDL_Surface* screen;	//The viewing window of the game
	SDL_Event eventManager;	//Event Queue
	bool quit = false;
	Game game;

	SDL_Init(SDL_INIT_VIDEO);	//Loads up SDL information necessary for rendering
	//800x6000, 16bit colors, surface rendering type
	screen = SDL_SetVideoMode(800, 600, 16, SDL_SWSURFACE);

	game.retrieveScreen(screen);

	while (!quit){

		game.Event(quit, eventManager);

		game.Logic();

		//Fill screen black once
		SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0, 0, 0));

		game.Renderer();

		//Swap draw buffer
		SDL_Flip(screen);
	}

	SDL_Quit();


	return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: raposalorx/Old-game-engines.
int main(int argc, char** argv)
{
	// Initialize the program
	bool cont = true;
	int fps = 30;
	Timer fpsTimer;
	Game game;

	if (game.Init())
	{
		// Main program loop
		while (cont)
		{
			fpsTimer.Start();

			game.Event();
			game.Logic();
			game.Render();
			cont = game.ChangeState();

			// Manage FPS
			if (fpsTimer.GetTime() < 1000/fps)
			{
				SDL_Delay((1000/fps) - fpsTimer.GetTime());
			}
			//double cur_fps = 1000/fpsTimer.GetTime();
			//printf("%f\n", cur_fps);
		}

		fpsTimer.Stop();
	}

	// Close down and clean up
	return 0;
}