Esempio n. 1
0
int TCODSystem::getFps() {
	return TCOD_sys_get_fps();
}
Esempio n. 2
0
int main( int argc, char *argv[] ) {
  char *font="tilesense/libtcod/fonts/courier12x12_aa_tc.png";
  int nb_char_horiz=0,nb_char_vertic=0;
  int font_flags=TCOD_FONT_TYPE_GREYSCALE|TCOD_FONT_LAYOUT_TCOD;
	TCOD_console_set_custom_font(font,font_flags,nb_char_horiz,nb_char_vertic);
	TCOD_console_init_root(80,40,"salamandeRL",false);
	
  Map room = initRoom();
  Object player = initPlayer(room);
  object_sense(player);
  
  TCOD_sys_set_fps(30);

  float elapsed = 0;
  char finished = 0;
	TCOD_key_t key = {TCODK_NONE,0};
	TCOD_console_set_foreground_color(NULL,TCOD_white);
	do {
	  key = TCOD_console_check_for_keypress(TCOD_KEY_PRESSED);
    if(key.vk != TCODK_NONE) {
      TCOD_console_clear(NULL);
    }
		
		TCOD_console_print_right(NULL,79,26,TCOD_BKGND_NONE,"last frame : %3d ms (%3d fps)", (int)(TCOD_sys_get_last_frame_length()*1000), TCOD_sys_get_fps());
		TCOD_console_print_right(NULL,79,27,TCOD_BKGND_NONE,"elapsed : %8dms %4.2fs", TCOD_sys_elapsed_milli(),TCOD_sys_elapsed_seconds());
		TCOD_console_print_left(NULL,0,27,TCOD_BKGND_NONE,"other stat stuff can go here");
		//map
    drawmap(room, player);
    TCOD_console_print_left(NULL, 
      object_position(player).x*2, object_position(player).y, 
      TCOD_BKGND_NONE,"@");
		//divider
		TCOD_console_print_left(NULL,0,28,TCOD_BKGND_NONE,
		  "--------------------------------------------------------------------------------"
		);
	  //text display
    TCOD_console_print_left(NULL,2,29,TCOD_BKGND_NONE,"we'll probably put text down here.");
		
		/* update the game screen */
		TCOD_console_flush();

    if(key.vk == TCODK_RIGHT) {
      map_turn_object(room, "@", 1);
    } else if(key.vk == TCODK_LEFT) {
      map_turn_object(room, "@", -1);
    } else if(key.vk == TCODK_CHAR) {
      switch(key.c) {
        case 'w':
          map_move_object(room, "@", (mapVec){0, -1, 0});
          break;
        case 'a':
          map_move_object(room, "@", (mapVec){-1, 0, 0});
          break;
        case 's':
          map_move_object(room, "@", (mapVec){0, 1, 0});
          break;
        case 'd':
          map_move_object(room, "@", (mapVec){1, 0, 0});
          break;
        case 'q':
          finished = 1;
          break;
        //next, handle chomping
        default:
          break;
  		}
    }

	} while (!finished && !TCOD_console_is_window_closed());
	return 0;
}