Exemplo n.º 1
0
void display(void)
{
  if(Game_HitGround())
    {
      // Check keyboard for reset
      Airplane_Keyboard(&thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag);
      Game_Over();
      
      if(resetFlag == 1)
	{
	  Game_Reset(&forward, &up, &right, &position, &velocity, &thrust, &yawRate, &pitchRate, &rollRate, 
		     &firstPersonView, &resetFlag, &camera_position, &camera_look, camMatrix);
	}
    }
  else
    {
      // Get user input
      Airplane_Keyboard(&thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag);
      
      // Update airplane dynamics
      Dynamics_CalcRot(yawRate, pitchRate, rollRate, &forward, &up, &right);
      Dynamics_CalcPos(thrust, &forward, &velocity, &position);
      
      // Update camera
      Camera_Update(firstPersonView, &forward, &up, &position, velocity, &camera_position, &camera_look, camMatrix);
      
      printError("pre display");
      
      // clear the screen
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      
      // Draw ground and skybox
      World_Draw(&camera_position, &camera_look, camMatrix, &position, &up, firstPersonView);
      
      // Check for collision
      Game_CollisionDetection(&position, &forward, &up, &right);
      
      // The game loop
      Game_Loop(position);
      
      // Draw target
      Game_DrawTarget(camMatrix, &camera_position);

      // Draw airplane
      Airplane_Draw(&forward, &up, &right, &position, &camera_position, camMatrix);

      // Reset game?
      if(resetFlag == 1)
      {
	Game_Reset(&forward, &up, &right, &position, &velocity, &thrust, &yawRate, &pitchRate, &rollRate, 
		   &firstPersonView, &resetFlag, &camera_position, &camera_look, camMatrix);
      }
    }
    
    printError("display");
    
    glutSwapBuffers();
}
Exemplo n.º 2
0
/**
DEBUG procedure: a random sequence of moves to check correct implementation
*/
void Game_Engine::Debug_Test_Sequence()
{

	Game_Reset();
	Settings_Reset();
	Game_Reset();
	for(int i = 0; i < maximum_plys+1; i++){
		Play_Move(Select_Move_Random());
		fflush(stdout);
		Output_Board_State();
	}

	Settings_Reset();
	Game_Reset();
	Settings_Reset();
	for(int i = 0; i < maximum_plys+1; i++){
		Play_Move(Select_Move_Random());
		fflush(stdout);
		Output_Board_State();
	}

	Settings_Reset();
	for(int i = 0; i < maximum_plys+1; i++){
		if(game_ended == 0){
			Play_Move_Unsafe(Select_Move_Random());
			fflush(stdout);
			Output_Board_State();
		}else
			i = maximum_plys;
	}

	fflush(stdout);
	gmp->Print("Moves history:");
	for(int i = 0; i < maximum_plys+1; i++)
		gmp->Print(" %d", history_moves[i]);
	gmp->Print("\n");

	fflush(stdout);
	Settings_Reset();

	for(int i = 0; i < 10; i++)
		Game_Reset();

	for(int i = 0; i < 10; i++)
		Settings_Reset();

	fflush(stdout);
}
Exemplo n.º 3
0
void GMGS_HandleInput(Game *game, SDL_Event *e) {
   if (e->type == SDL_KEYDOWN) {
		switch(e->key.keysym.scancode) {
		case SDL_SCANCODE_DOWN:
		case SDL_SCANCODE_LEFT:
		case SDL_SCANCODE_RIGHT:
		case SDL_SCANCODE_UP:
			break;
		default:
		   Game_Reset(game);
		   break;
		}
   }
}
Exemplo n.º 4
0
/**
Play a 1v1 human game by standard input/output.
For each move the player inputs the horizontal and vertical coordinate, e.g.: 4 6
PASS action is played with: 0 0

@param board_width Size of game board
@param showCurrentScore Display score after each play
*/
void Game_Engine::Simulate_Human_Game()
{

	//instantiate players
	Player_Engine* players[] = {new Player_Human(this), new Player_Human(this)};

	//restart and play a game
	Game_Reset();
	Simulate_Output_Game(players);

	//clean up
	delete players[0];
	delete players[1];

}
Exemplo n.º 5
0
//allocate memory and initialize variables
void Game_Engine::Initialize()
{

	//set init flag
	is_initialized = true;

	//initialize values common to all derivate objects
	Initialize_Common();

	//initialize settings
	Init_Settings();

	//allocate resources
	Allocate_Memory();
	
	//reset game state
	Game_Reset();
}
/**
 * \brief Initialize game
 */
PUBLIC void Game_Init( void )
{
	Com_Printf( "\n------ Game Init ------\n" );


	// noset vars
//	dedicated = Cvar_Get( "dedicated", "0", CVAR_ROM );

	// latched vars
//	sv_cheats = Cvar_Get( "cheats", "0", CVAR_SERVERINFO |CVAR_LATCH );

	skill = Cvar_Get( "skill", "1", CVAR_LATCH );
	g_version = Cvar_Get( "g_version", "0", CVAR_ARCHIVE | CVAR_LATCH ); 
	g_fov = Cvar_Get( "g_fov", "68", CVAR_ARCHIVE | CVAR_LATCH ); 
	g_autoaim = Cvar_Get( "g_autoaim", "1", CVAR_ARCHIVE | CVAR_LATCH ); 
//	maxentities = Cvar_Get( "maxentities", "1024", CVAR_LATCH );
    mapScale = Cvar_Get( "mapScale", "10", CVAR_ARCHIVE );


	// dm map list
	Cmd_AddCommand( "map", Map_f );
	Cmd_AddCommand( "load", Load_f );
	Cmd_AddCommand( "save", Save_f );

    Cmd_AddCommand( "toggleautomap", Con_ToggleAutomap_f );


	WM_BuildTables();
	CorrectBossDeathTimeouts();

	Powerup_Reset();
	Sprite_Reset();

	Game_Reset();
	PL_Init();

	Com_Printf( "\n-----------------------\n" );
	
}
Exemplo n.º 7
0
void Game_Engine::Settings_Apply_Changes()
{
	Clear_Memory();
	Allocate_Memory();
	Game_Reset();
}