Esempio n. 1
0
File: view.c Progetto: jep-dev/spide
extern bool View_init(int width, int height, 
		const char *title, View *view){
	sfRenderWindow *window = view -> window;
	sfRenderWindow_setVerticalSyncEnabled(
			window, true);
	sfRenderWindow_setFramerateLimit(
			window, 58);

	glEnable(GL_DEPTH_TEST);

	return true;
}
Esempio n. 2
0
int game_setup(jnx_hashmap *configuration)
{
  assert(configuration);
  config = configuration;
  assert(config);
  videomode = sfVideoMode_getDesktopMode();
  JNX_LOG(NULL,"Video mode is %d %d\n",videomode.width,videomode.height);	
  main_window = sfRenderWindow_create(videomode,"Gridfire",sfDefaultStyle,NULL);
  int max_fps = atoi(jnx_hash_get(config,"MAXFPS"));
  assert(max_fps);
  sfRenderWindow_setFramerateLimit(main_window,max_fps);
  main_view = sfView_create();
  sfVector2f view_size;
  view_size.x = videomode.width;
  view_size.y = videomode.height;
  sfView_setSize(main_view,view_size);
  clear_color = sfColor_fromRGB(0,0,0);
  JNX_LOG(NULL,"Creating game _clock\n");
  _clock = sfClock_create();
  JNX_LOG(NULL,"Creating bounding map\n");
  int game_bound = atoi(jnx_hash_get(configuration,"GAMEBOUNDS"));
  cartographer_setbounds(0,game_bound,0,game_bound);

  int star_density = atoi(jnx_hash_get(configuration,"STARCOUNT"));
  starfield_create(cartographer_getbounds(),star_density);
  JNX_LOG(NULL,"Initial setup complete\n");	
  /*-----------------------------------------------------------------------------
   *  Game text
   *-----------------------------------------------------------------------------*/
  game_start_text = game_ui_text_builder("GRIDFIRE",sfView_getCenter(main_view),sfColor_fromRGB(255,0,0),sfTextRegular,40);
  game_over_text = game_ui_text_builder("GAME OVER",sfView_getCenter(main_view),sfColor_fromRGB(255,255,255),sfTextRegular,30);
  game_start_button_text = game_ui_text_builder("Start",sfView_getCenter(main_view),sfColor_fromRGB(255,0,0),sfTextRegular,15);
  game_author_text = game_ui_text_builder("By Alex Jones",sfView_getCenter(main_view),sfColor_fromRGB(255,0,0),sfTextRegular,15);
  next_level_text = game_ui_text_builder("Congratulations",sfView_getCenter(main_view),sfColor_fromRGB(255,255,255),sfTextRegular,45);
  next_level_button_text = game_ui_text_builder("Press enter for the next level",sfView_getCenter(main_view),sfColor_fromRGB(255,0,0),sfTextRegular,20);
  game_loading_text = game_ui_text_builder("LOADING",sfView_getCenter(main_view),sfColor_fromRGB(255,0,0),sfTextRegular,40);
  game_finish_text = game_ui_text_builder("GAME COMPLETE",sfView_getCenter(main_view),sfColor_fromRGB(255,0,0),sfTextRegular,40);
  assert(game_finish_text);
  assert(game_loading_text);
  assert(next_level_button_text);
  assert(game_start_text);
  assert(game_over_text);
  assert(game_start_button_text);
  assert(game_author_text);
  assert(next_level_text);	
  /*-----------------------------------------------------------------------------
   *  Game level setup
   *-----------------------------------------------------------------------------*/
  max_levels = atoi(jnx_hash_get(configuration,"MAXLEVELS"));
  assert(max_levels);
  //start on level one
  current_level = 1;	
  /*-----------------------------------------------------------------------------
   *  Scoreboard setup
   *-----------------------------------------------------------------------------*/
  score_setup(atoi(jnx_hash_get(configuration,"MAXSCORE")));
  /*-----------------------------------------------------------------------------
   *  Load weapon textures
   *-----------------------------------------------------------------------------*/
  weapon_setup();
  /*-----------------------------------------------------------------------------
   *  Load ingame music
   *-----------------------------------------------------------------------------*/
  audio_control_setup(configuration);
  play_music(TITLEMUSIC);
  if(game_ui_setup(main_window,main_view) != 0)
  {
    return 1;
  }
  /*-----------------------------------------------------------------------------
   *  Set game state to running
   *-----------------------------------------------------------------------------*/
  current_game_state = GAMESTART;
  return 0;
}