def render(self, screen, active=True):
     # If this overlay is active and the global property
     # for flashlight movement is enabled, determine a new
     # direction for the flashlight if necessary.
     if active and get_property(FLASHLIGHT_MOVEMENT_ENABLED):
         # Determine direction
         mpos = pygame.mouse.get_pos()
         newdir = get_direction_from_point_to_point(SCREEN_CENTER, mpos)
         # If this is a new direction, change it and the Surface
         if newdir is not self.currentdir:
             self.currentdir = newdir
             self.updateSurf()
     # Render
     Overlay.render(self, screen)
 def _pauseUntilClick(self):
     # Set global property that enables the extra behaviour of InputController
     set_property(CURRENTLY_PAUSING_FOR_CLICK, True)
     self.waiting = True
     clicked = False
     while not clicked:
         if self.interrupted:
             raise Storage.Break()
         pygame.time.wait(self.timestep)
         # InputController re-sets this flag, so
         # this loop will notice when it changed
         if not get_property(CURRENTLY_PAUSING_FOR_CLICK):
             clicked = True
     self.waiting = False
# CS 386
 def handle(self, event):
     # TickEvent: Update player sprites, handle collision detection,
     # check for player-script collision, process other logic...
     if isinstance(event, TickEvent):
         # Update entities
         self.gh.player.update()
         self.gh.shadow.update(event.object)
         if self.gh.player.moving:
             if (self.gh.currentmap is not None):
                 # Player-Map collision detection
                 coll_result = self.gh.currentmap.isWalkable(self.gh.player, self.gh.player.facing)
                 self.gh.player.move(coll_result, event.object)
                 # Player-Script collision detection
                 script_result = self.gh.currentmap.checkForScriptToggle(self.gh.player)
                 if script_result is not None:
                     ScriptEngine.run(script_result)
     # FullscreenToggleRequestEvent
     elif isinstance(event, FullscreenToggleRequestEvent):
         # Order the Game menu to check if that's possible
         self.gh.fullscreenToggleRequest()
     # QuitEvent: Shutdown the Engine objects (killing running interaction threads)
     elif isinstance(event, QuitEvent):
         # Shutdown the engine objects
         ScriptEngine.shutdown()
         ObjectEngine.shutdown()
     # MouseMotionEvent: Order the map to check if the moved mouse has highlighted a clickable object
     elif isinstance(event, MouseMotionEvent):
         # Check for enabled highlighting
         if get_property(MOUSE_HIGHLIGHT_ENABLED):
             # Check for object highlighting
             obj = self.gh.currentmap.checkForObjectHighlight(event.object)
             self.gh.evManager.post(ObjectHighlightedEvent(obj))
     # MovementRequestEvent: Order the player to start moving and point him in the desired direction
     elif isinstance(event, MovementRequestEvent):
         if get_property(PLAYER_MOVEMENT_ENABLED):
             # Player has started moving
             self.gh.player.startMoving()
             self.gh.player.setDirection(event.object)
     # MovementDoneEvent: Order the player to stop moving
     elif isinstance(event, MovementDoneEvent):
         self.gh.player.stopMoving()
     # ObjectInteractionEvent: Order the Object Engine to interact with the event's object
     elif isinstance(event, ObjectInteractionEvent):
         ObjectEngine.interact(event.object)
     # InventoryToggleEvent: Order the opening of the inventory dialog
     elif isinstance(event, InventoryToggleEvent):
         # Open inventory if no script or object execution is running right now
         if get_property(INVENTORY_OPEN_ENABLED):
             # Stop the player
             self.gh.player.stopMoving()
             # Play a sound for inventory toggling
             GlobalServices.getAudioDevice().play(SOUND, "journal_open", VOLUME_SOUND)
             # Change game state
             self.gh.state = STATE_GAME_INVENTORY
             self.gh.evManager.post(GameStateChangedEvent(self.gh.state))
     elif isinstance(event, GameMenuToggleEvent):
         if get_property(GAME_MENU_OPEN_ENABLED):
             # Open game menu! First, stop the player
             self.gh.player.stopMoving()
             # Change game state
             self.gh.state = STATE_GAME_MENU
             self.gh.evManager.post(GameStateChangedEvent(self.gh.state))
     # SaveEvent: Initialize the save process
     elif isinstance(event, SaveEvent):
         if get_property(SAVE_ENABLED):
             # Save the state (the True parameter orders the TextRenderer to display a message as well)
             self.gh.save(True)
     # MapChangeRequestEvent: When the user has triggered a teleport to another map,
     # the ScriptEngine posts this event to the EventManager
     elif isinstance(event, MapChangeRequestEvent):
         # Stop moving the player
         self.gh.player.stopMoving()
         # Unpack event information
         map_object = event.object[0]
         destination = event.object[1]
         # Init loading with the map and save the dest position
         self.gh.teleport_destination = destination
         self.gh.initMapLoading(map_object)
     # MainMenuSwitchRequestEvent: After the game is finished
     elif isinstance(event, MainMenuSwitchRequestEvent):
         self.gh.switchToMainMenu()