Compare commits
No commits in common. "366b2b2a9a8f44068690d0ba0b65527e87441901" and "413cefb933f940218af13ca32ddebd6c8e9f8641" have entirely different histories.
366b2b2a9a
...
413cefb933
@ -46,7 +46,6 @@ class FightingCharacter(GameObject):
|
|||||||
self.jump_sound: SoundComponent = None # type: ignore[assignment]
|
self.jump_sound: SoundComponent = None # type: ignore[assignment]
|
||||||
self.hit_sound: SoundComponent = None # type: ignore[assignment]
|
self.hit_sound: SoundComponent = None # type: ignore[assignment]
|
||||||
self.die_sound: SoundComponent = None # type: ignore[assignment]
|
self.die_sound: SoundComponent = None # type: ignore[assignment]
|
||||||
self.guitar_hero_components: None
|
|
||||||
self.fall_through = False
|
self.fall_through = False
|
||||||
self.fall_through_timer = 0.0
|
self.fall_through_timer = 0.0
|
||||||
self.fall_through_duration = 0.2
|
self.fall_through_duration = 0.2
|
||||||
@ -96,17 +95,6 @@ class FightingCharacter(GameObject):
|
|||||||
self.hit_sound = self.sounds.add_component("hit", SoundComponent, "assets/sounds/hit.wav")
|
self.hit_sound = self.sounds.add_component("hit", SoundComponent, "assets/sounds/hit.wav")
|
||||||
self.die_sound = self.sounds.add_component("die", SoundComponent, "assets/sounds/die.wav")
|
self.die_sound = self.sounds.add_component("die", SoundComponent, "assets/sounds/die.wav")
|
||||||
|
|
||||||
# TODO, james add more buttons
|
|
||||||
guitar_hero_key_bindings = {
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_UP: "assets/sounds/nes_harp/nes_harp_A4.wav",
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_DOWN: "assets/sounds/nes_harp/nes_harp_C4.wav",
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_LEFT: "assets/sounds/nes_harp/nes_harp_D4.wav",
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_RIGHT: "assets/sounds/nes_harp/nes_harp_G4.wav",
|
|
||||||
}
|
|
||||||
self.guitar_hero_components = {}
|
|
||||||
for key_press, wav_file in guitar_hero_key_bindings.items():
|
|
||||||
self.guitar_hero_components[key_press] = self.sounds.add_component(key_press, SoundComponent, wav_file)
|
|
||||||
|
|
||||||
self.animation = self.add_component(AnimationController(self.body))
|
self.animation = self.add_component(AnimationController(self.body))
|
||||||
if self.player_number == 1:
|
if self.player_number == 1:
|
||||||
self.animation.add_animation_from_files("run",
|
self.animation.add_animation_from_files("run",
|
||||||
@ -200,20 +188,6 @@ class FightingCharacter(GameObject):
|
|||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Add more buttons here
|
|
||||||
gamepad_buttons = [
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_UP,
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
|
|
||||||
rl.GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
|
|
||||||
]
|
|
||||||
for button in gamepad_buttons:
|
|
||||||
if rl.is_gamepad_button_pressed(self.gamepad, button):
|
|
||||||
self.guitar_hero_components[button].play()
|
|
||||||
|
|
||||||
|
|
||||||
return
|
|
||||||
deadzone = 0.1
|
deadzone = 0.1
|
||||||
jump_pressed = rl.is_key_pressed(rl.KEY_W) or rl.is_gamepad_button_pressed(self.gamepad, rl.GAMEPAD_BUTTON_RIGHT_FACE_DOWN)
|
jump_pressed = rl.is_key_pressed(rl.KEY_W) or rl.is_gamepad_button_pressed(self.gamepad, rl.GAMEPAD_BUTTON_RIGHT_FACE_DOWN)
|
||||||
jump_held = rl.is_key_down(rl.KEY_W) or rl.is_gamepad_button_down(self.gamepad, rl.GAMEPAD_BUTTON_RIGHT_FACE_DOWN)
|
jump_held = rl.is_key_down(rl.KEY_W) or rl.is_gamepad_button_down(self.gamepad, rl.GAMEPAD_BUTTON_RIGHT_FACE_DOWN)
|
||||||
@ -302,7 +276,6 @@ class FightingCharacter(GameObject):
|
|||||||
Returns:
|
Returns:
|
||||||
True to enable contact, False to disable it.
|
True to enable contact, False to disable it.
|
||||||
"""
|
"""
|
||||||
return True
|
|
||||||
normal = contact.worldManifold.normal
|
normal = contact.worldManifold.normal
|
||||||
other = None
|
other = None
|
||||||
sign = 0.0
|
sign = 0.0
|
||||||
@ -402,7 +375,7 @@ class FightingScene(Scene):
|
|||||||
self.physics.world.contactListener = FightingContactListener(self)
|
self.physics.world.contactListener = FightingContactListener(self)
|
||||||
|
|
||||||
player_entities = self.level.get_entities_by_name("Start")
|
player_entities = self.level.get_entities_by_name("Start")
|
||||||
for i, player_entity in enumerate(player_entities[:1]):
|
for i, player_entity in enumerate(player_entities[:4]):
|
||||||
params = CharacterParams()
|
params = CharacterParams()
|
||||||
params.position = self.level.convert_to_pixels(player_entity.getPosition())
|
params.position = self.level.convert_to_pixels(player_entity.getPosition())
|
||||||
params.width = 16
|
params.width = 16
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user