playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): playerx += 1 ############################################# # Initialization & Main Loop ############################################# libtcod.console_set_custom_font('fonts/arial12x12.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'python/libtcod tutorial', False) libtcod.sys_set_fps(LIMIT_FPS) playerx = SCREEN_WIDTH/2 playery = SCREEN_HEIGHT/2 while not libtcod.console_is_window_closed(): libtcod.console_set_default_foreground(0, libtcod.white) libtcod.console_put_char(0, playerx, playery, '@', libtcod.BKGND_NONE) libtcod.console_flush() libtcod.console_put_char(0, playerx, playery, ' ', libtcod.BKGND_NONE) #handle keys and exit game if needed exit = handle_keys() if exit: break
def clear(self): #erase the character that represents this object libtcod.console_put_char(con, self.x, self.y, ' ', libtcod.BKGND_NONE)
def clear_map_char(self, x, y): cod.console_put_char(self.map_console, x, y, ' ', cod.BKGND_NONE)
def draw(self): #set the color and then draw the character that represents this object at its position libtcod.console_set_default_foreground(con, self.color) libtcod.console_put_char(con, self.x, self.y, self.char, libtcod.BKGND_NONE)
def put_map_char(self, char, x, y, fg_color=cod.white, bg_color=cod.BKGND_NONE): cod.console_set_default_foreground(self.map_console, fg_color) cod.console_put_char(self.map_console, x, y, char, bg_color)