add death sound and refactor jump sound
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
extends Area2D
|
||||
|
||||
@onready var timer: Timer = $Timer
|
||||
@onready var death: AudioStreamPlayer2D = $Death
|
||||
|
||||
func _on_body_entered(player_body: Node2D) -> void:
|
||||
print("You died.")
|
||||
death.play()
|
||||
Engine.time_scale = 0.5
|
||||
player_body.get_node(NodeTypes.COLLISION_SHAPE_2D).queue_free()
|
||||
var player_character_body = player_body as CharacterBody2D
|
||||
|
||||
@@ -5,7 +5,7 @@ extends CharacterBody2D
|
||||
@export var jump_velocity = -400.0
|
||||
|
||||
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var jump_sound: AudioStreamPlayer2D = $JumpSound
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
@@ -14,7 +14,7 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
animation_player.play("jump")
|
||||
jump_sound.play()
|
||||
velocity.y = jump_velocity
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
|
||||
Reference in New Issue
Block a user