Beispiel #1
0
int main(int argc, char *argv[])
{
  if(!InitGame())
    {
      printf("%s\n", SDL_GetError());
      FreeGame();   //If InitGame failed, kill the program
      return 0;
    }

  while(ProgramIsRunning())
    {
      long int oldTime = SDL_GetTicks();  //We will use this later to see how long it took to update the frame
      SDL_FillRect(Backbuffer, NULL, 0);  //Clear the screen
      RunGame();                          //Update the game
      DrawGame();                         //Draw the screen

      int frameTime = SDL_GetTicks() - oldTime;

      if(frameTime < FRAME_DELAY)                 //Dont delay if we dont need to
	SDL_Delay(FRAME_DELAY - frameTime);     //Delay

      //In SDL 2, SDL_UpdateWindowSurface replaces SDL_Flip
      SDL_UpdateWindowSurface(Window);            //Flip the screen
    }

  FreeGame();     //Gracefully release SDL and its resources.

  return 0;
}
Beispiel #2
0
int main(int argc, char** argv) {
	//initialisation du contexte glut
	initGlut(argc, argv);

	Menu* menu = (Menu *) malloc(sizeof(Menu));

	Game* game = (Game *) malloc(sizeof(Game));

	//si probleme lors de la création du menu -> exit
	if (!MakeMenu(WINDOW_WIDTH, WINDOW_HEIGHT, menu, debut))
		return EXIT_FAILURE;

	//si porblème lors de la création du game -> exit
	if (!MakeGame(game)) {
		printf("Erreur MakeGame !!");
		return EXIT_FAILURE;
	}

	CallMenuDemarrage(menu, game);

	//liberation du *game
	FreeGame(game);
	free(game);
	game = NULL;

	//libéraiton du *menu
	free(menu);
	menu = NULL;

	return EXIT_SUCCESS;
}
Beispiel #3
0
void CTrackDlg::ReportStats(DWORD time)
{
	char response[33];

	NewGame(1);
	BucketStringOp(NULL, "hostname", bo_set, (char *)(LPCSTR)m_loginDlg.m_nick, bl_server, 0);
	BucketIntOp(NULL, "event", bo_set, m_event, bl_server, 0);

	NewPlayer(NULL, 0, (char *)(LPCSTR)m_loginDlg.m_nick);
	BucketIntOp(NULL, "time", bo_set, time, bl_player, 0);
	BucketIntOp(NULL, "pid", bo_set, m_loginDlg.m_profile, bl_player, 0);
	GenerateAuth(GetChallenge(NULL), (char *)(LPCSTR)m_loginDlg.m_password, response);
	BucketStringOp(NULL, "auth", bo_set, response, bl_player, 0);

	SendGameSnapShot(NULL, NULL, SNAP_FINAL);
	FreeGame(NULL);
}