Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, engine, background_color=(0, 0, 0), **kwargs):
super().__init__(engine=engine,
background_color=background_color,
**kwargs)
Player(self, Vector(750, 750))
def __init__(self, scene, target=None):
super().__init__(scene.groups["player"])
self.image = image.load(path.join(path.dirname(__file__),
"player.png"))
self.rect = self.image.get_rect()
self.position = Vector(*self.rect.center)
self.scene = scene
self.target = target
self.speed = 60
self.reach = hypot(0.5 * self.image.get_height(), 0.5 * self.image.get_width())
def respond(self):
mouse_buttons = mouse.get_pressed()
mouse_position = mouse.get_pos()
if mouse_buttons[0] and not self.button_pressed:
self.button_pressed = True
target = EmptyTarget(Vector(*mouse_position))
for sprite in self.targets.sprites():
if sprite.rect.collidepoint(mouse_position):
target = sprite
break
self.player.target = target
if not mouse_buttons[0] and self.button_pressed:
self.button_pressed = False
def __init__(self, scene, target: TargetABC=None):
super().__init__(scene.groups["player"])
self.image = image.load(path.join(path.dirname(__file__),
"player.png"))
self.rect = self.image.get_rect()
self.position = Vector(*self.rect.center)
self.scene = scene
self._target = target
self.speed = 120
self.reach = hypot(0.5 * self.image.get_height(),
0.5 * self.image.get_width())
def __init__(self, engine, background_color=(0, 0, 0), **kwargs):
super().__init__(engine=engine,
background_color=background_color,
**kwargs)
chest = ClosedChest(self, Vector(750, 750))
player = Player(self, chest)
self.groups["terrain"].empty()
self.controller = Controller(player, self.groups["interact"])