From 3f5a10f0909e4dccd9bac9a54d981c3b5005ff7f Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Thu, 12 Jan 2023 17:48:07 -0600 Subject: [PATCH] controller axis movement --- creeper_adventure/creeper.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/creeper_adventure/creeper.py b/creeper_adventure/creeper.py index 4700c70..08d2acb 100755 --- a/creeper_adventure/creeper.py +++ b/creeper_adventure/creeper.py @@ -579,6 +579,28 @@ class Creeper(Game): if abs(joystick.get_axis(1)) > 0.2: self.y += joystick.get_axis(1) * 10 + if abs(joystick.get_axis(3)) > 0.2 and abs(joystick.get_axis(4)) > 0.2: + pygame.mouse.set_pos( + ( + pygame.mouse.get_pos()[0] + joystick.get_axis(3) * 32, + pygame.mouse.get_pos()[1] + joystick.get_axis(4) * 32, + ) + ) + elif abs(joystick.get_axis(3)) > 0.2: + pygame.mouse.set_pos( + ( + pygame.mouse.get_pos()[0] + joystick.get_axis(3) * 32, + pygame.mouse.get_pos()[1], + ) + ) + elif abs(joystick.get_axis(4)) > 0.2: + pygame.mouse.set_pos( + ( + pygame.mouse.get_pos()[0], + pygame.mouse.get_pos()[1] + joystick.get_axis(4) * 32, + ) + ) + def inventory_keys(self): keys = self.keys if not self.joysticks: