pull/10/head
Kenney 2023-10-16 13:53:33 +07:00
parent 025f5b50ed
commit 77a16e7baa
3 changed files with 2 additions and 12 deletions

@ -13,7 +13,6 @@ var destroyed := false
# When ready, save the initial position # When ready, save the initial position
func _ready(): func _ready():
target_position = position target_position = position
@ -26,10 +25,8 @@ func _process(delta):
position = target_position position = target_position
# Take damage from player # Take damage from player
func damage(amount): func damage(amount):
Audio.play("sounds/enemy_hurt.ogg") Audio.play("sounds/enemy_hurt.ogg")
@ -38,20 +35,16 @@ func damage(amount):
if health <= 0 and !destroyed: if health <= 0 and !destroyed:
destroy() destroy()
# Destroy the enemy when out of health # Destroy the enemy when out of health
func destroy(): func destroy():
Audio.play("sounds/enemy_destroy.ogg") Audio.play("sounds/enemy_destroy.ogg")
destroyed = true destroyed = true
queue_free() queue_free()
# Shoot when timer hits 0 # Shoot when timer hits 0
func _on_timer_timeout(): func _on_timer_timeout():
raycast.force_raycast_update() raycast.force_raycast_update()
@ -59,6 +52,7 @@ func _on_timer_timeout():
var collider = raycast.get_collider() var collider = raycast.get_collider()
if collider.has_method("damage"): # Raycast collides with player if collider.has_method("damage"): # Raycast collides with player
# Play muzzle flash animation(s) # Play muzzle flash animation(s)
muzzle_a.frame = 0 muzzle_a.frame = 0

@ -78,7 +78,7 @@ func _physics_process(delta):
camera.rotation.x = lerp_angle(camera.rotation.x, rotation_target.x, delta * 25) camera.rotation.x = lerp_angle(camera.rotation.x, rotation_target.x, delta * 25)
rotation.y = lerp_angle(rotation.y, rotation_target.y, delta * 25) rotation.y = lerp_angle(rotation.y, rotation_target.y, delta * 25)
container.position = lerp(container.position, container_offset - (applied_velocity / 30), delta * 10) container.position = lerp(container.position, container_offset - (basis.inverse() * applied_velocity / 30), delta * 10)
# Movement sound # Movement sound

@ -8,7 +8,6 @@ var bus = "master"
var available = [] # The available players. var available = [] # The available players.
var queue = [] # The queue of sounds to play. var queue = [] # The queue of sounds to play.
func _ready(): func _ready():
for i in num_players: for i in num_players:
var p = AudioStreamPlayer.new() var p = AudioStreamPlayer.new()
@ -20,16 +19,13 @@ func _ready():
p.finished.connect(_on_stream_finished.bind(p)) p.finished.connect(_on_stream_finished.bind(p))
p.bus = bus p.bus = bus
func _on_stream_finished(stream): func _on_stream_finished(stream):
available.append(stream) available.append(stream)
func play(sound_path): # Path (or multiple, separated by commas) func play(sound_path): # Path (or multiple, separated by commas)
var sounds = sound_path.split(",") var sounds = sound_path.split(",")
queue.append("res://" + sounds[randi() % sounds.size()].strip_edges()) queue.append("res://" + sounds[randi() % sounds.size()].strip_edges())
func _process(_delta): func _process(_delta):
if not queue.is_empty() and not available.is_empty(): if not queue.is_empty() and not available.is_empty():
available[0].stream = load(queue.pop_front()) available[0].stream = load(queue.pop_front())