Refactor keybindings configuration and remove obsolete JSON files
This commit is contained in:
+6
-2
@@ -74,7 +74,7 @@ class GameWindow:
|
||||
|
||||
# Audio system initialization
|
||||
self._init_audio_system()
|
||||
|
||||
self.audio = True
|
||||
# Input devices
|
||||
self.load_joystick()
|
||||
|
||||
@@ -279,7 +279,7 @@ class GameWindow:
|
||||
self.renderer.copy(self.ammo_background, dstrect=sdl2.SDL_Rect(position[0] - 5, position[1] - 2, text_width + 10, text_height + 4))
|
||||
self.renderer.copy(self.ammo_sprite, dstrect=sdl2.SDL_Rect(position[0], position[1], text_width, text_height))
|
||||
self.renderer.copy(assets["BMP_BOMB0"], dstrect=sdl2.SDL_Rect(position[0]+25, position[1], 20, 20))
|
||||
self.renderer.copy(assets["mine"], dstrect=sdl2.SDL_Rect(position[0]+80, position[1], 20, 20))
|
||||
self.renderer.copy(assets["BMP_POISON"], dstrect=sdl2.SDL_Rect(position[0]+80, position[1], 20, 20))
|
||||
self.renderer.copy(assets["BMP_NUCLEAR"], dstrect=sdl2.SDL_Rect(position[0]+130, position[1], 20, 20))
|
||||
# ======================
|
||||
# VIEW & NAVIGATION
|
||||
@@ -319,6 +319,8 @@ class GameWindow:
|
||||
|
||||
def play_sound(self, sound_file, tag="base"):
|
||||
"""Play a sound file on the specified audio channel"""
|
||||
if not self.audio:
|
||||
return
|
||||
sound_path = os.path.join("sound", sound_file)
|
||||
rw = sdl2.SDL_RWFromFile(byteify(sound_path, "utf-8"), b"rb")
|
||||
if not rw:
|
||||
@@ -383,10 +385,12 @@ class GameWindow:
|
||||
# print in file keycode
|
||||
keycode = event.key.keysym.sym
|
||||
key = sdl2.SDL_GetKeyName(event.key.keysym.sym).decode('utf-8')
|
||||
key = key.replace(" ", "_")
|
||||
# Check for Right Ctrl key to trigger white flash
|
||||
self.trigger(f"keydown_{key}")
|
||||
elif event.type == sdl2.SDL_KEYUP:
|
||||
key = sdl2.SDL_GetKeyName(event.key.keysym.sym).decode('utf-8')
|
||||
key = key.replace(" ", "_")
|
||||
self.trigger(f"keyup_{key}")
|
||||
elif event.type == sdl2.SDL_MOUSEMOTION:
|
||||
self.trigger(f"mousemove_{event.motion.x}, {event.motion.y}")
|
||||
|
||||
Reference in New Issue
Block a user