Skip to content

Commit 8c64751

Browse files
committed
Add controller exiting with B button
1 parent 1780ab7 commit 8c64751

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

game/iter_fractal_viewer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ def setup_ui(self):
6666
self.has_controller = True
6767

6868
def on_button_press(self, controller, button_name):
69-
if button_name == "a" and self.has_controller:
69+
if button_name == "a":
7070
self.zoom_start_position = self.cursor_sprite.center_x, self.cursor_sprite.center_y
7171
self.dragging_with_controller = True
72+
elif button_name == "b":
73+
self.main_exit()
7274

7375
def on_button_release(self, controller, button_name):
7476
if button_name == "a" and self.dragging_with_controller:

game/sierpinsky_carpet.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ def on_show_view(self):
3737
self.sprite_list.append(self.cursor_sprite)
3838
self.has_controller = True
3939

40-
def on_stick_motion(self, controller, name, vector):
41-
if name == "leftstick":
42-
self.cursor_sprite.center_x += vector.x * 5
43-
self.cursor_sprite.center_y += vector.y * 5
44-
45-
def main_exit(self):
46-
from menus.main import Main
47-
self.window.show_view(Main(self.pypresence_client))
48-
4940
def setup_ui(self):
5041
self.anchor = self.add_widget(arcade.gui.UIAnchorLayout(size_hint=(1, 1)))
5142

@@ -85,6 +76,17 @@ def on_mouse_press(self, x: int, y: int, button: int, modifiers: int) -> bool |
8576
def on_button_press(self, controller, name):
8677
if name == "a":
8778
self.on_mouse_press(self.cursor_sprite.left, self.cursor_sprite.bottom, arcade.MOUSE_BUTTON_LEFT, 0)
79+
elif name == "b":
80+
self.main_exit()
81+
82+
def on_stick_motion(self, controller, name, vector):
83+
if name == "leftstick":
84+
self.cursor_sprite.center_x += vector.x * 5
85+
self.cursor_sprite.center_y += vector.y * 5
86+
87+
def main_exit(self):
88+
from menus.main import Main
89+
self.window.show_view(Main(self.pypresence_client))
8890

8991
def on_draw(self):
9092
self.window.clear()

0 commit comments

Comments
 (0)