Browse Source

Aggiungi supporto per input da tastiera con codici ASCII nel gioco

master
Matteo Benedetto 1 year ago
parent
commit
4947b91ae2
  1. 14
      rats.py

14
rats.py

@ -78,9 +78,9 @@ class MiceMaze:
def key_pressed(self, key): def key_pressed(self, key):
print(key) print(key)
if key == "Q": if key == "Q" or key == 12:
self.engine.close() self.engine.close()
elif key == "Return": elif key == "Return" or key == 13:
self.new_rat() self.new_rat()
elif key == "D": elif key == "D":
if self.units: if self.units:
@ -90,15 +90,15 @@ class MiceMaze:
elif key == "F": elif key == "F":
self.full_screen = not self.full_screen self.full_screen = not self.full_screen
self.engine.full_screen(self.full_screen) self.engine.full_screen(self.full_screen)
elif key == "Up": elif key == "Up" or key == 8:
self.scroll_cursor(y=-1) self.scroll_cursor(y=-1)
elif key == "Down": elif key == "Down" or key == 9:
self.scroll_cursor(y=1) self.scroll_cursor(y=1)
elif key == "Left": elif key == "Left" or key == 10:
self.scroll_cursor(x=-1) self.scroll_cursor(x=-1)
elif key == "Right": elif key == "Right" or key == 11:
self.scroll_cursor(x=1) self.scroll_cursor(x=1)
elif key == "Space": elif key == "Space" or key == 1:
self.play_sound("PUTDOWN.WAV") self.play_sound("PUTDOWN.WAV")
self.spawn_bomb(self.pointer) self.spawn_bomb(self.pointer)

Loading…
Cancel
Save