Skip to content

Commit 0abb786

Browse files
committed
Update dual stick shooter example for Pyglet 3
1 parent 0275949 commit 0abb786

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

arcade/examples/dual_stick_shooter.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ def dump_obj(obj):
3636

3737
def dump_controller(controller):
3838
print(f"========== {controller}")
39-
print(f"Left X {controller.leftx}")
40-
print(f"Left Y {controller.lefty}")
39+
print(f"Left X,Y {controller.leftstick[0]},{controller.leftstick[1]}")
4140
print(f"Left Trigger {controller.lefttrigger}")
42-
print(f"Right X {controller.rightx}")
43-
print(f"Right Y {controller.righty}")
41+
print(f"Right X,Y {controller.rightstick[0]},{controller.rightstick[1]}")
4442
print(f"Right Trigger {controller.righttrigger}")
4543
print("========== Extra controller")
4644
dump_obj(controller)
@@ -58,11 +56,11 @@ def dump_controller_state(ticks, controller):
5856
num_fmts = ["{:5.2f}"] * 6
5957
fmt_str += " ".join(num_fmts)
6058
print(fmt_str.format(ticks,
61-
controller.leftx,
62-
controller.lefty,
59+
controller.leftstick[0],
60+
controller.leftstick[1],
6361
controller.lefttrigger,
64-
controller.rightx,
65-
controller.righty,
62+
controller.rightstick[0],
63+
controller.rightstick[0],
6664
controller.righttrigger,
6765
))
6866

@@ -202,8 +200,10 @@ def on_update(self, delta_time):
202200

203201
if self.controller:
204202
# Controller input - movement
203+
left_position = self.controller.leftstick
204+
right_position = self.controller.rightstick
205205
move_x, move_y, move_angle = get_stick_position(
206-
self.controller.leftx, self.controller.lefty
206+
left_position[0], left_position[1]
207207
)
208208
if move_angle:
209209
self.player.change_x = move_x * MOVEMENT_SPEED
@@ -215,7 +215,7 @@ def on_update(self, delta_time):
215215

216216
# Controller input - shooting
217217
shoot_x, shoot_y, shoot_angle = get_stick_position(
218-
self.controller.rightx, self.controller.righty
218+
right_position[0], right_position[1]
219219
)
220220
if shoot_angle:
221221
self.spawn_bullet(shoot_angle)

0 commit comments

Comments
 (0)