def handle_keys(): global playerx, playery global fov_recompute # fullscreen and enter key = libtcod.console_check_for_keypress() if key.vk == libtcod.KEY_ENTER and key.lalt: # alt+enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True # movement if game_state == 'playing': if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) fov_recompute = True else: return 'didnt-take-turn'
def handle_keys(): #key = libtcod.console_check_for_keypress() #real-time key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) fov_recompute = True
def handle_keys(): """ Handless the movement of the player. The function console_wait_for_keypress blocks all actions until the player makes a move. """ global fov_recompute #blocks the game and awaits input key = libtcod.console_wait_for_keypress(True) # handle setting keys, in this case handle escape or alt+enter # to toggle fullscreen if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' if game_state == 'playing': #handle player movement if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(1, 0) else: return 'didnt-take-turn'
def handle_keys(): global playerx, playery key = libtcod.console_wait_for_keypress(True) #fullscreen toggle if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) #exit game elif key.vk == libtcod.KEY_ESCAPE: return True #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): playery -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): playerx += 1
def handle_keys(): global playerx, playery key = libtcod.console_check_for_keypress() #real-time #key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): playery -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): playerx += 1
def keyboard_input(player, con): global fog_of_war key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ESCAPE: return True if key.vk == libtcod.KEY_SPACE: fog_of_war = not fog_of_war erase_map(con) if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) if libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) if libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) if libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) return False
def handle_keys(): game.fov_recompute = False key = libtcod.console_wait_for_keypress(True) # Alt+Enter: toggle fullscreen if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) # Escape to exit game elif key.vk == libtcod.KEY_ESCAPE: return 'exit' # movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): try_move(game.player_one, (0, -1)) game.fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): try_move(game.player_one, (0, 1)) game.fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): try_move(game.player_one, (-1, 0)) game.fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): try_move(game.player_one, (1, 0)) game.fov_recompute = True else: return 'no-action'
def handle_keys(): global fov_recompute global game_state global player_action key = libtcod.console_wait_for_keypress(True) #turn-based movement if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' #exit game if game_state == 'playing': # marker used to differentiate between like pausing so that you can't move while paused or dead char # movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(1, 0) else: return 'didnt-take-turn'
def handle_keys(self): key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return "exit" #exit game elif key.vk == libtcod.KEY_F1: if self.game_state == "not-playing": self.game_state = "playing" return "exit-debug-screen" self.game_state = "not-playing" return "debug-screen" if self.game_state != "playing": return if libtcod.console_is_key_pressed(libtcod.KEY_UP): self.move_player(0,-1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): self.move_player(0,1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): self.move_player(-1,0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): self.move_player(1,0) else: return "didn't-move"
def handle_keys(): key = libtcod.console_check_for_keypress() #real-time #key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game if libtcod.console_is_key_pressed(libtcod.KEY_SPACE): shoot() #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) player.char = '^' elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) player.char = 'v' elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) player.char = '<' elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) player.char = '>'
def handle_keys(): dx=0 dy=0 key = libtcod.console_wait_for_keypress(True); if libtcod.console_is_key_pressed(libtcod.KEY_UP): dy=-1 if not map[player.x+dx][player.y+dy].blocked: player.move(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): dy=1 if not map[player.x+dx][player.y+dy].blocked: player.move(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): dx=-1 if not map[player.x+dx][player.y+dy].blocked: player.move(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): dx=1 if not map[player.x+dx][player.y+dy].blocked: player.move(1, 0) if key.vk == libtcod.KEY_ESCAPE: return True
def handle_keys(): global dirx, diry key = libtcod.console_check_for_keypress() #real-time if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP) and diry == 0: dirx = 0 diry = -1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN) and diry == 0: dirx = 0 diry = 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT) and dirx == 0: dirx = -1 diry = 0 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT) and dirx == 0: dirx = 1 diry = 0
def handle_keys(): global playerx, playery key = libtcod.console_wait_for_keypress(True) # Alt + Enter: toggle fullscreen if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) # Escape: exit the game elif key.vk == libtcod.KEY_ESCAPE: return True # Movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0)
def handle_keys(): global player_x, player_y, m, turns #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): if libtcod.map_is_walkable(m, player_x, player_y - 1): player_y -= 1 turns += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): if libtcod.map_is_walkable(m, player_x, player_y + 1): player_y += 1 turns += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): if libtcod.map_is_walkable(m, player_x - 1, player_y): player_x -= 1 turns += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): if libtcod.map_is_walkable(m, player_x + 1, player_y): player_x += 1 turns += 1 key = libtcod.Key() mouse = libtcod.Mouse() libtcod.sys_check_for_event(libtcod.EVENT_ANY, key, mouse) if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_SPACE: end(player_x, player_y, mouse.cx, mouse.cy) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game
def handle_keys(): global playerx, playery key = libtcod.console_wait_for_keypress(True) #key = libtcod.console_check_for_keypress() #alt-enter fullscreens if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) #escape exits game elif key.vk == libtcod.KEY_ESCAPE: return True #movement key handling if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0)
def handle_keys(): global playerx, playery #key = libtcod.console_check_for_keypress() #real-time key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game # Movement keys by arrows. if libtcod.console_is_key_pressed(libtcod.KEY_UP): #north player.move(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): #south player.move (0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): #west player.move (-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): #east player.move (1, 0)
def handle_keys(key,currentArea): shouldQuit = False currentArea = copy.deepcopy(currentArea) p = currentArea.entities[0] if key.vk == libtcod.KEY_ESCAPE: shouldQuit = True #exit game if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) newX = p.x newY = p.y #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): newY -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): newY += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): newX -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): newX += 1 else: k = chr(key.c) if not bump(newX,newY,p.id,currentArea): currentArea.map[p.y][p.x] = currentArea.map[p.y][p.x]._replace(changed = True) currentArea.entities[0] = p._replace(x = newX,y = newY) return [shouldQuit,currentArea]
def input(): global recompute_field_of_view # key = libtcod.console_check_for_keypress() #real-time key = tcod.console_wait_for_keypress(True) # turn-based if key.vk == tcod.KEY_ENTER and key.lalt: # Alt+Enter: toggle fullscreen tcod.console_set_fullscreen(not tcod.console_is_fullscreen()) elif key.vk == tcod.KEY_ESCAPE: return True # exit game # movement keys if tcod.console_is_key_pressed(tcod.KEY_UP): engine.frogue.move(0, -1) render.recompute_field_of_view = True elif tcod.console_is_key_pressed(tcod.KEY_DOWN): engine.frogue.move(0, 1) render.recompute_field_of_view = True elif tcod.console_is_key_pressed(tcod.KEY_LEFT): engine.frogue.move(-1, 0) render.recompute_field_of_view = True elif tcod.console_is_key_pressed(tcod.KEY_RIGHT): engine.frogue.move(1, 0) render.recompute_field_of_view = True
def handle_keys(self): key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ESCAPE: return 'exit' elif key.vk == libtcod.KEY_ENTER and libtcod.KEY_ALT: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_CONTROL and ord('s'): libtcod.sys_save_screenshot() move = False if self.mode == 'playing': if libtcod.console_is_key_pressed(libtcod.KEY_UP): self.move_player((0, -1)) move = True return 'move' elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): self.move_player((0, 1)) move = True return 'move' elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): self.move_player((-1, 0)) move = True return 'move' elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): self.move_player((1, 0)) move = True return 'move' if move: return 'move' else: return "didnt-take-turn"
def handle_keys(): global playerx, playery #key = libtcod.console_check_for_keypress() #real-time key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): playery -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): playerx += 1
def handle_keys(state): """Handles key inputs from the PLAYER. UP/DOWN/LEFT/RIGHT keys will move the PLAYER in their respective directions. Fullscreen mode is toggled with LAlt+ENTER; Game exit is triggered with ESCAPE. Accesses and modifies PLAYER, ZONE, and the FOV_RECOMPUTE flag. """ # Fullscreen and Exit keys; # Use "True" arg for turn-based; omit for real-time if settings.TURN_BASED is True: key = libtcod.console_wait_for_keypress(True) else: key = libtcod.console_check_for_keypress() if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' # Exit game if state["status"] == 'playing': # Movement Keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(state, 0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(state, 0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(state, -1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(state, 1, 0) else: print 'Hero takes no action' return 'no_action'
def handle_keys(): global fov_recompute key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) fov_recompute = True key_char = chr(key.c) if key_char == 'e': if npc.x == player.x and npc.y == player.y: print('x&y+1 : ', npc.x + 1, npc.y + 1) print('x&y-1 : ', npc.x - 1, npc.y - 1)
def handle_inputs(): global player_x, player_y # Window key = libtcod.console_wait_for_keypress(True) # Block! if key.vk == libtcod.KEY_ENTER and key.lalt: # Toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: # Exit return True # Movement if libtcod.console_is_key_pressed(libtcod.KEY_UP): config.player.move(0, -1) config.recompute_fov_flag = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): config.player.move(0, 1) config.recompute_fov_flag = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): config.player.move(-1, 0) config.recompute_fov_flag = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): config.player.move(1, 0) config.recompute_fov_flag = True return False
def handle_keys(): global key global fov_recompute # here we set the globals for the players position plus handle movement #use check for keypress for realtime if key.vk == libtcod.KEY_ENTER and key.lalt: #alt enter for fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' #exit game if game_state == 'playing': if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(1, 0) fov_recompute = True else: return 'didnt-take-turn'
def handle_keys(): global player global fov_recompute # REAL TIME PLAY key = tcod.console_check_for_keypress() if key.vk == tcod.KEY_ENTER and key.lalt: tcod.console_set_fullscreen(not tcod.console_is_fullscreen()) elif key.vk == tcod.KEY_ESCAPE: return 'exit' if game_state == 'playing': if player.wait > 0: player.wait -= 1 return if tcod.console_is_key_pressed(tcod.KEY_UP): player_move_or_attack(0, -1) elif tcod.console_is_key_pressed(tcod.KEY_DOWN): player_move_or_attack(0, 1) elif tcod.console_is_key_pressed(tcod.KEY_LEFT): player_move_or_attack(-1, 0) elif tcod.console_is_key_pressed(tcod.KEY_RIGHT): player_move_or_attack(1, 0) else: return 'didnt-take-turn'
def handle_keys(): global playerx, playery key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ENTER and key.lalt: # Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True # exit game # movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP) and playery != 1: playery -= 1 elif libtcod.console_is_key_pressed( libtcod.KEY_DOWN) and playery != SCREEN_HEIGHT - 22: playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT) and playerx != 1: playerx -= 1 elif libtcod.console_is_key_pressed( libtcod.KEY_RIGHT) and playerx != SCREEN_WIDTH - 22: playerx += 1
def handle_keys(): global fov_recompute # key = libtcod.console_check_for_keypress() #real-time key = libtcod.console_wait_for_keypress(True) # turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: # Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True # exit game # movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) fov_recompute = True
def handle_keys(): key = libtcod.console_check_for_keypress() #real-time #key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' #exit game if game_state == 'playing': #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(1, 0) else: return 'didnt-take-turn' # change to 'playing' if real time
def handle_keys(): key = libtcod.console_check_for_keypress(True) if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' if game_state == 'playing': #Movement Keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move_attack(0, -1, game_map, objects) fov_recompute_set() elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move_attack(0, 1, game_map, objects) fov_recompute_set() elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move_attack(-1, 0, game_map, objects) fov_recompute_set() elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move_attack(1, 0, game_map, objects) fov_recompute_set() else: return 'didnt-take-turn'
def return_key(): key_pressed = "null" key = libtcod.console_wait_for_keypress(True) #Check All The Arrow Keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): key_pressed = "KEY_UP" elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): key_pressed = "KEY_DOWN" elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): key_pressed = "KEY_RIGHT" elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): key_pressed = "KEY_LEFT" #Check for Character Keys key_char = chr(key.c) if key_char == 'k': key_pressed = "k" elif key_char =='i': key_pressed = "i" elif key_char == '1': key_pressed = '1' return key_pressed
def update(self): key = libtcod.console_wait_for_keypress(True) if libtcod.console_is_key_pressed(libtcod.KEY_ESCAPE): if self.menu_stack == []: return True self.current_menu = self.menu_stack[-1] self.menu_choice = util.generic_index(lambda x: x[0] == self.stack[-1], self.current_menu) self.menu_stack = self.menu_stack[:-1] self.stack = self.stack[:-1] elif libtcod.console_is_key_pressed(libtcod.KEY_UP): if not self.menu_choice == 0: self.menu_choice -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): if not self.menu_choice == (len(self.current_menu) - 1): self.menu_choice += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_ENTER): choice = self.current_menu[self.menu_choice] if type(choice) is list: self.menu_choice = 0 self.menu_stack.append(self.current_menu) self.current_menu = choice[1:] self.stack.append(choice[0]) else: self.stack.append(choice) resolve_case(self, self.stack)
def handle_keys(): global playerx, playery #this is blocking, console_check_for_keypress() is nonblocking key = libtcod.console_wait_for_keypress(True) #exit if key.vk == libtcod.KEY_ESCAPE: return True #Alt+Enter: toggle fullscreen elif key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) #movement keys # checked this way so you can just hold it down elif libtcod.console_is_key_pressed(libtcod.KEY_UP): playery -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): playerx += 1
def handle_keys(): global playerx, playery global fov_recompute key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt + Enter: Toggle Fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: #Exit the game return True #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) fov_recompute = True #playery -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) fov_recompute = True #playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) fov_recompute = True #playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) fov_recompute = True
def handle_input(key, player): if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return "E" #exit game move_x = move_y = 0 #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): move_y -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): move_y += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): move_x -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): move_x += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DELETE): print "waiting!" move_x += 0 move_y += 0 else: return "U" # Useless keypress return [move_x, move_y]
def handle_keys(): global fov_recompute #key = libtcod.console_check_for_keypress() #real-time key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #exit game # Movement keys by arrows. # New for module 4: fov_recompute will force a recalculation every movement. if libtcod.console_is_key_pressed(libtcod.KEY_UP): #north player.move(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): #south player.move (0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): #west player.move (-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): #east player.move (1, 0) fov_recompute = True
def handle_keys(): #key = libtcod.console_check_for_keypress() #real-time key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' #exit game if game_state == 'playing': #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(1, 0) else: return 'didnt-take-turn'
def handleKeys(self, key): if libtcod.console_is_key_pressed(libtcod.KEY_UP): self.player.moveAttack(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): self.player.moveAttack(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): self.player.moveAttack(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): self.player.moveAttack(1, 0)
def handle_keys(self): global playerx, playery ##static variables ## character controler if libtcod.console_is_key_pressed(libtcod.KEY_UP): self.move(0,-1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): self.move(0,1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): self.move(-1,0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): self.move(1,0)
def handle_keys(): global fov_recompute global key #libtcod.sys_wait_for_event(1, key, None, True) key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ENTER and key.lalt: # Alt + Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' # exit game if game_state == 'playing': # movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(1, 0) fov_recompute = True else: # other keys key_char = chr(key.c) if key_char == 'g': # pick up an item for object in objects: if object.x == player.x and object.y == player.y and object.item: object.item.pick_up() break if key_char == 'i': chosen_item = inventory_menu('Press the key next to an item to use it, or any other to cancel\n') if chosen_item is not None: chosen_item.use() if key_char == 'd': chosen_item = inventory_menu('Drop which item?') if chosen_item is not None: chosen_item.drop() return 'didnt-take-turn'
def handle_keys(): key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ESCAPE: return True if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0)
def handle_keys(): global playerx, playery # movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): playery -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): playerx += 1
def handleKeys(): global playerScore, exity, exitx, player, PlayerID global levelChange levelChange = False key = libtcod.console_wait_for_keypress(True) # turn-based playery, playerx = player.Y, player.X if key.vk == libtcod.KEY_ESCAPE: # When player exits save some stats postScore(playerScore) sqlcon.setPlayerStats(player.HPMax, player.Hp, player.Attack, player.Defence, PlayerID) # TODO Make this vvv to be in the setPlayerStats function !!! sqlcon.sqlPost( "UPDATE player SET PositionY=%s, PositionX=%s WHERE User_ID=%s" % (player.Y, player.X, PlayerID)) return True # exit game # movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): playery -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): playery += 1 elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): playerx -= 1 elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): playerx += 1 # key to move to another level if libtcod.console_is_key_pressed(libtcod.KEY_SPACE): if player.Y == exity and player.X == exitx: global LevelID levelChange = True LevelID += 1 postScore(playerScore) sqlcon.setPlayerStats(player.HPMax, player.Hp, player.Attack, player.Defence, PlayerID) changeLevel(LevelID) handleCollisionWithObjects(playerx, playery)
def handle_keys(self): key = libtcod.console_check_for_keypress() # real-time if self.gui_wait == 0 and self.game_ui.cursor != None: for input, action in self.CONSOLE_KEY_ACTIONS.items(): if libtcod.console_is_key_pressed(input): action(self) self.game_ui.game_view.lock_cursor_to_view(self.game_ui.camera, self.game_ui.cursor) self.game_object.update_cursor_cartesian(self.game_ui.cursor) self.game_object.update_cursor_coordinates(self.game_ui.cursor) self.game_ui.cycle() self.game_object.cycle() if self.gui_wait > 0: self.gui_wait -= 1 if key.vk == libtcod.KEY_ESCAPE and self.game_object.game_map != None: self.game_object.unload_map(self.game_ui) elif key.vk == libtcod.KEY_ESCAPE and self.game_object.game_map == None: return True # Exit game if key.vk == libtcod.KEY_CHAR: action = self.CHAR_KEY_ACTIONS.get(key.c) if action: action(self)
def input_vk(self): if not libtcod.console_is_key_pressed(self.key.vk): return cpos = self.cursor_pos ans = ord(self.keyInput) # returning a result if (ans == K_ENTER): self.set_result(self.text) if (ans == K_ESCAPE): self.set_result(self.default) # deleting if (ans == K_BACKSPACE): self.render_text = True self.putCursor(cpos - 1) self.delete() elif (ans == K_DELETE): self.render_text = True self.delete() # moving elif (ans == K_LEFT): self.move(cpos - 1) elif (ans == K_RIGHT): self.move(cpos + 1) # insert mode elif (ans == K_INSERT): self.insert_mode = not self.insert_mode
def handle_keys(): global player_x, player_y key = tcod.console_check_for_keypress() if key.vk == tcod.KEY_ENTER and tcod.KEY_ALT: tcod.console_set_fullscreen(not tcod.console_is_fullscreen()) elif key.vk == tcod.KEY_ESCAPE: return True if tcod.console_is_key_pressed(tcod.KEY_UP): player_y = player_y - 1 elif tcod.console_is_key_pressed(tcod.KEY_DOWN): player_y = player_y + 1 elif tcod.console_is_key_pressed(tcod.KEY_LEFT): player_x = player_x - 1 elif tcod.console_is_key_pressed(tcod.KEY_RIGHT): player_x = player_x + 1
def handleInput(self): key = rl.Key() # Set up the variables for mouse and key input. mouse = rl.Mouse() rl.sys_check_for_event(rl.EVENT_KEY_PRESS|rl.EVENT_MOUSE,key,mouse) # Update the key and mouse variables if a key or mouse button was pressed. if key.vk == rl.KEY_ENTER or key.vk == rl.KEY_KPENTER or mouse.lbutton_pressed: if len(self.moveBoxes) == 0 or self.animPhase > 0: # Don't do anything if the menu isn't open or a animation is playing. return None command = None if mouse.lbutton_pressed: # If the mouse was clicked, attempt to retrieve a result. self.handleCommand(self.moveBoxes[len(self.moveBoxes)-1].handleClick(mouse)) if (key.vk == rl.KEY_ENTER or key.vk == rl.KEY_KPENTER) and command == None: # If a key was pressed and a mouse click did not occur or yield any results: self.handleCommand(self.moveBoxes[len(self.moveBoxes)-1].forward()) # Retrieve the selected option, then send it to a separate function for processing. return None elif key.vk == rl.KEY_DOWN or key.vk == rl.KEY_KP2: if len(self.moveBoxes) > 0: self.moveBoxes[len(self.moveBoxes)-1].goDown() # Go down one item. return None elif key.vk == rl.KEY_UP or key.vk == rl.KEY_KP8: if len(self.moveBoxes) > 0: self.moveBoxes[len(self.moveBoxes)-1].goUp() # Go up one item. return None elif key.vk == rl.KEY_ESCAPE or mouse.rbutton_pressed: # Remove the latest move box, if there are more than one. if len(self.moveBoxes) > 1: self.moveBoxes.pop() elif key.vk == rl.KEY_F4 and rl.console_is_key_pressed(rl.KEY_ALT): raise SystemExit # Pressing Alt+F4 is against the laws of the game and is punishable with exile. return None else: # Let the box handle any other input. if len(self.moveBoxes) == 0 or self.animPhase > 0: # Don't do anything if the menu isn't open or a animation is playing. return None self.moveBoxes[len(self.moveBoxes)-1].miscInput(key) return None
def HandleInput(self, key, mouse): if not self.rect.Contains(mouse.cx, mouse.cy): return if libtcod.console_is_key_pressed(libtcod.KEY_SPACE) and (mouse.dx, mouse.dy) != (0, 0): focus = self.Scene.MainWindow.Focus self.Scene.MainWindow.Focus = focus[0]-mouse.dcx, focus[1]-mouse.dcy
def handle_keys(): global p key = tcod.console_wait_for_keypress(True) if key.vk == tcod.KEY_ENTER and tcod.KEY_ALT: tcod.console_set_fullscreen(not tcod.console_is_fullscreen()) elif key.vk == tcod.KEY_ESCAPE: return True if tcod.console_is_key_pressed(tcod.KEY_UP): p.move(0, -1) elif tcod.console_is_key_pressed(tcod.KEY_DOWN): p.move(0, 1) elif tcod.console_is_key_pressed(tcod.KEY_LEFT): p.move(-1, 0) elif tcod.console_is_key_pressed(tcod.KEY_RIGHT): p.move(1, 0)
def handleKeys(self): #key = l.console_check_for_keypress() #THIS DOESN'T BLOCK key = l.console_wait_for_keypress(True) #THIS BLOCKS if key.vk == l.KEY_ENTER and key.lalt: #Alt + Enter Full Screening l.console_set_full_screen(not l.console_is_fullscreen()) elif(key.vk == l.KEY_ESCAPE): self.state = 0 return 'exit' if(self.state): if(l.console_is_key_pressed(l.KEY_UP)): self.playerMove(0,-1) elif(l.console_is_key_pressed(l.KEY_DOWN)): self.playerMove(0,1) elif(l.console_is_key_pressed(l.KEY_LEFT)): self.playerMove(-1,0) elif(l.console_is_key_pressed(l.KEY_RIGHT)): self.playerMove(1,0) else: pass
def handle_keys(): global fov_recompute key = libtcod.console_check_for_keypress() if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' #exit game if game_state == 'playing': #if player.wait > 0: #player.wait -= 1 #else: #Movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0) fov_recompute = True else: key_char = chr(key.c) if key_char == 'g': for object in objects: if object.x == player.x and object.y == player.y and object.item: object.item.pick_up() break elif key_char == 'i': chosen_item = inventory_menu( 'Press the key next to an item to use it, or any other key to cancel\n' ) if chosen_item is not None: chosen_item.use() elif key_char == 'd': chosen_item = inventory_menu( 'Press the key next to an item to drop it, or any other key to cancel\n' ) if chosen_item is not None: chosen_item.drop()
def handle_keys(): #key = TCOD.console_check_for_keypress() key = TCOD.console_wait_for_keypress(True) if key.vk == TCOD.KEY_ENTER and key.lalt: TCOD.console_set_fullscreen(not TCOD.console_is_fullscreen()) elif key.vk == TCOD.KEY_ESCAPE: return True if TCOD.console_is_key_pressed(TCOD.KEY_UP ): player.move(0, -1) elif TCOD.console_is_key_pressed(TCOD.KEY_DOWN ): player.move(0, 1) elif TCOD.console_is_key_pressed(TCOD.KEY_LEFT ): player.move(-1, 0) elif TCOD.console_is_key_pressed(TCOD.KEY_RIGHT): player.move(1, 0)
def handle_keys(): key = libtcod.console_check_for_keypress() if key.vk == libtcod.KEY_ENTER and key.lalt: # Alt+Enter: Toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True #Escape: Exits the game # Movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0)
def handle_keys(): #key = libtcod.console_check_for_keypress() # real-time key = libtcod.console_wait_for_keypress(True) # turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return True if libtcod.console_is_key_pressed(libtcod.KEY_UP): player.move(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player.move(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player.move(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player.move(1, 0)
def handle_keys(): #key = TCOD.console_check_for_keypress() key = TCOD.console_wait_for_keypress(True) if key.vk == TCOD.KEY_ENTER and key.lalt: TCOD.console_set_fullscreen(not TCOD.console_is_fullscreen()) elif key.vk == TCOD.KEY_ESCAPE: return True if TCOD.console_is_key_pressed(TCOD.KEY_UP): player.move(0, -1) elif TCOD.console_is_key_pressed(TCOD.KEY_DOWN): player.move(0, 1) elif TCOD.console_is_key_pressed(TCOD.KEY_LEFT): player.move(-1, 0) elif TCOD.console_is_key_pressed(TCOD.KEY_RIGHT): player.move(1, 0)
def handle_keys(): #key = libtcod.console_check_for_keypress() #real-time key = libtcod.console_wait_for_keypress(True) #turn-based if key.vk == libtcod.KEY_ENTER and key.lalt: #Alt+Enter: toggle fullscreen libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' #exit game if key.vk == libtcod.KEY_SPACE: if player.fighter.hp < 1: message('You are dead. Stop trying. Really.') return player.fighter.hp = player.fighter.hp + 1 #print 'You Rested to gain Health!' message('You Rested to gain Health!', libtcod.white) if player.fighter.hp > player.fighter.max_hp: player.fighter.hp = player.fighter.max_hp #print 'But your HP was Full!' message('But your HP was full!', libtcod.white) return 'Rested' if key.vk == libtcod.KEY_TAB: message('Current XP '+str (player.fighter.xp), libtcod.white) message('Power '+str (player.fighter.power), libtcod.white) message('Defense '+str (player.fighter.defense), libtcod.white) if game_state == 'playing': #movement keys if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0, -1) elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0, 1) elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1, 0) elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(1, 0) else: return 'didnt-take-turn'
def handle_keys(): global keys global player global fov_recompute # key = libtcod.console_check_for_keypress() # Fullscreen and exit keys if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) elif key.vk == libtcod.KEY_ESCAPE: return 'exit' # Movement keys if game_state == 'playing': if player.wait > 0: player.wait -= 1 return if libtcod.console_is_key_pressed(libtcod.KEY_UP): player_move_or_attack(0,-1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN): player_move_or_attack(0,+1) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT): player_move_or_attack(-1,0) fov_recompute = True elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT): player_move_or_attack(+1,0) fov_recompute = True else: key_char = chr(key.c) if key_char == 'g': #pick up an item for object in objects: #look for an item in the players tile if object.x == player.x and object.y == player.y and object.item: object.item.pick_up() break if key_char == 'i': # show the inventory chosen_item = inventory_menu('Press the key next to an item to use it, or any other to cancel. \n') if chosen_item is not None: chosen_item.use() return 'didnt-take-turn'