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 moveBy(self, vector, dur): # Re-position the shadow if the last movement is still present if self.cmDestPos is not None: self.position = self.cmDestPos # Now reset and re-setup self.resetMovementVars() # Calculate starting and finishing points for this movement self.cmStartPos = self.position self.cmDestPos = (self.position[0] + vector[0],\ self.position[1] + vector[1]) self.cmDestTime = dur self.cmCurTime = 0 # Set the facing of the sprite self.direction = get_direction_from_point_to_point(\ self.currentsprite.rect.center, self.cmDestPos) # Enable moving status self.moving = True
def _faceObject(self, player, obj): directionstring = get_direction_from_point_to_point(\ player.currentsprite.rect.center, obj.rect.center) direction = string_to_direction(directionstring) player.setDirection(direction)