Esempio n. 1
0
/*
Call this function before starting the main loop.
need_to_initialise is 1 if starting a new game or from a gamefile, 0 if loading from a saved game (as saved games contain various initialise stuff)
playing_mission is the index of the mission (MISSION_MISSION1 etc) if playing a mission, 0 otherwise
*/
void init_main_loop(void)
{

// settings.edit_window = EDIT_WINDOW_CLOSED;
// settings.keyboard_capture = INPUT_WORLD;
/*
 int i;

 for (i = 0; i < MODE_BUTTONS; i ++)
	{
		inter.mode_button_available [i] = 1;
	}
*/
// open_sysmenu();
 resize_display_window(settings.option [OPTION_WINDOW_W], settings.option [OPTION_WINDOW_H]);
 reset_panel_positions();
// init_ex_control();

 init_commands();

 clear_sound_list();
//fpr("\n iml: ai %i riai %i", game.area_index, game.region_in_area_index);
 if (game.type == GAME_TYPE_MISSION)
  reset_music(game.area_index, game.region_in_area_index, rand());
   else
    reset_music(game.area_index, -1, rand());

 flush_game_event_queues();

// game.play_sound = 0;
// game.play_sound_counter = 0;


}
Esempio n. 2
0
// set need_to_initialise to zero if loading from disk (in which case the world has been initialised by the load function)
//  * currently need_to_initialise should always be 0
void run_game(void)
{

 init_main_loop();


 main_game_loop();

// ends when game over (or user quit)

 game.watching = WATCH_OFF;
// bcp_state.bcp_mode = BCP_MODE_EMPTY;
 init_bcode_panel();

 if (game.type == GAME_TYPE_MISSION)
	{
		w.players = 1; // this affects the template panel (prevents opening the old player 1 templates in the mission select screen)

		if (game.game_over_status == GAME_END_MISSION_COMPLETE)
	 {
 		story_mission_defeated();
 	}
	}

	close_all_panels();

 deallocate_world(); // must be called at end of game (it frees memory allocated by init_main_loop())

 reset_music(1, 0, rand());

}
Esempio n. 3
0
  void checkGameOver()
  {
    if(game.isGameOver())
      {
	reset();
	reset_music();
      }
  }
Esempio n. 4
0
void keyboard_event(const SDL_KeyboardEvent &ev)
{
  switch(ev.keysym.sym)
    {
    case SDLK_ESCAPE:
      terminate_program(0);// never returns
    case SDLK_PAUSE:
    case SDLK_p:
      GAME_STATE.toggle_pause();
      toggle_play_music();
      break;
    case SDLK_RETURN:
      GAME_STATE.reset();
      reset_music();
      break;
      // Game control
    case SDLK_q:
    case SDLK_UP:
      if(GAME_STATE.running)
	{
	  GAME_STATE.game.queueInput(rotate_ccw);
	}
      break;
    case SDLK_a:
    case SDLK_LEFT:
      if(GAME_STATE.running)
	{
	  GAME_STATE.game.queueInput(shift_left);
	}
      break;
    case SDLK_e:
      if(GAME_STATE.running)
	{
	  GAME_STATE.game.queueInput(rotate_cw);
	}
      break;
    case SDLK_d:
    case SDLK_RIGHT:
      if(GAME_STATE.running)
	{
	  GAME_STATE.game.queueInput(shift_right);
	}
      break;
    case SDLK_x:
    case SDLK_DOWN:
      if(GAME_STATE.running)
	{
	  GAME_STATE.game.queueInput(hard_drop);
	}
      break;
    default:
      break;
    }
  GAME_STATE.checkGameOver();
}