コード例 #1
0
def handle_input(key, mouse, game_state, leveldata, con):
    # TODO remove con from params
    """ Handles user input. Returns True if the player has taken a turn """

    if key.vk == ltc.KEY_ENTER and key.lalt:
        # alt+enter toggles fullscreen
        ltc.console_set_fullscreen(not ltc.console_is_fullscreen())
        return False

    elif key.vk == ltc.KEY_F4 and key.lalt:
        # exit
        global should_exit
        should_exit = True
        return False

    elif chr(key.c) == 'i':
        item = guiutils.draw_inventory_menu(con, leveldata.player,
                                            SCREEN_WIDTH - 30, SCREEN_WIDTH,
                                            SCREEN_HEIGHT)
        # todo move this logic somewhere more appropriate
        if item and item.usable:
            item.usable.use(item, leveldata, leveldata.player)

    elif game_state is GS_PLAYING:
        # otherwise, player takes an action
        return rlplayer.handle_key(key, leveldata.player)
コード例 #2
0
ファイル: darkness.py プロジェクト: borntyping-sandbox/misc
	def input (self):
		""" Handle input

			Returns True if a turn was taken """
		key = libtcod.console_wait_for_keypress(True)

		if key.vk == libtcod.KEY_ENTER and key.lalt:
			return libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())

		# Try commands
		for k in self.commands:
			if key.vk == k:
				self.commands[k](self)
				return False

		# Try ingame commands
		try:
			for k in self.ingame_commands:
				if key.vk == k:
					self.ingame_commands[k](self)
					return True
		except CouldNotMove as e:
			self.log.debug(e)
			return False
コード例 #3
0
ファイル: input.py プロジェクト: phss/playground
 def handle(self, key):
   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
   return False
コード例 #4
0
 def _toggle_fullscreen(self):
     if libtcod.console_is_fullscreen():
         libtcod.console_set_fullscreen(False)
     else:
         libtcod.console_set_fullscreen(True)