Fixed Audio breaking the entire game
This commit is contained in:
parent
16d9639dd1
commit
0c0decb12b
8 changed files with 50 additions and 4 deletions
|
|
@ -12,8 +12,10 @@ var idle_dir_remaining = 0
|
||||||
var idle_move = true
|
var idle_move = true
|
||||||
var target_pos = Vector2.ZERO
|
var target_pos = Vector2.ZERO
|
||||||
var damage = 1
|
var damage = 1
|
||||||
|
var dead = false
|
||||||
signal grounded
|
signal grounded
|
||||||
|
|
||||||
|
|
||||||
func choose_next_move() -> String:
|
func choose_next_move() -> String:
|
||||||
if $EnemyHurtbox.hp < 2 * $EnemyHurtbox.max_hp / 3 and risen == 0:
|
if $EnemyHurtbox.hp < 2 * $EnemyHurtbox.max_hp / 3 and risen == 0:
|
||||||
risen += 1
|
risen += 1
|
||||||
|
|
@ -24,6 +26,7 @@ func choose_next_move() -> String:
|
||||||
return ["slam", "wave", "splash"].pick_random()
|
return ["slam", "wave", "splash"].pick_random()
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
if dead: return
|
||||||
up_direction = earthaligner.global_from_local(Vector2.UP)
|
up_direction = earthaligner.global_from_local(Vector2.UP)
|
||||||
if attack_ready:
|
if attack_ready:
|
||||||
attack_ready = false
|
attack_ready = false
|
||||||
|
|
@ -69,6 +72,7 @@ func slam():
|
||||||
attack_ready = true
|
attack_ready = true
|
||||||
|
|
||||||
func destroy_below():
|
func destroy_below():
|
||||||
|
if dead: return
|
||||||
for body in $DestructionChecker.get_overlapping_bodies():
|
for body in $DestructionChecker.get_overlapping_bodies():
|
||||||
if(body.has_method("destroy")): body.destroy()
|
if(body.has_method("destroy")): body.destroy()
|
||||||
|
|
||||||
|
|
@ -92,12 +96,15 @@ func splash():
|
||||||
await get_tree().create_timer(5).timeout
|
await get_tree().create_timer(5).timeout
|
||||||
attack_ready = true
|
attack_ready = true
|
||||||
|
|
||||||
func hurt(_dmg, _dir):
|
|
||||||
$AudioStreamPlayer2D.play()
|
|
||||||
|
|
||||||
func die():
|
func die():
|
||||||
|
dead = true
|
||||||
for child in get_children():
|
for child in get_children():
|
||||||
if not child is AudioStreamPlayer2D:
|
if not child is AudioStreamPlayer2D:
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
await $AudioStreamPlayer2D.finished
|
await $AudioStreamPlayer2D.finished
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
func _on_enemy_hurtbox_damage_taken() -> void:
|
||||||
|
if dead: return
|
||||||
|
$AudioStreamPlayer2D.play()
|
||||||
|
|
|
||||||
|
|
@ -61,4 +61,5 @@ shape = SubResource("RectangleShape2D_lnbgr")
|
||||||
|
|
||||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||||
|
|
||||||
|
[connection signal="damage_taken" from="EnemyHurtbox" to="." method="_on_enemy_hurtbox_damage_taken"]
|
||||||
[connection signal="died" from="EnemyHurtbox" to="." method="die"]
|
[connection signal="died" from="EnemyHurtbox" to="." method="die"]
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ var paused = false
|
||||||
var pause_time = 0.1
|
var pause_time = 0.1
|
||||||
var iframes = 0.2
|
var iframes = 0.2
|
||||||
var iframe_time = 0
|
var iframe_time = 0
|
||||||
|
var dead = false
|
||||||
|
|
||||||
var check_grounded_delay = 8
|
var check_grounded_delay = 8
|
||||||
|
|
||||||
|
|
@ -19,6 +20,7 @@ func _ready() -> void:
|
||||||
segment.segment_damaged.connect(hurt)
|
segment.segment_damaged.connect(hurt)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
if dead: return
|
||||||
iframe_time = max(0, iframe_time - delta)
|
iframe_time = max(0, iframe_time - delta)
|
||||||
if not paused:
|
if not paused:
|
||||||
angle -= TAU * delta * angular_speed * move_dir
|
angle -= TAU * delta * angular_speed * move_dir
|
||||||
|
|
@ -31,11 +33,13 @@ func _physics_process(delta: float) -> void:
|
||||||
var ratio = - move_dir * broadth / (2 * y)
|
var ratio = - move_dir * broadth / (2 * y)
|
||||||
var rot_angle = - 2 * asin(ratio)
|
var rot_angle = - 2 * asin(ratio)
|
||||||
position = position.rotated(rot_angle)
|
position = position.rotated(rot_angle)
|
||||||
|
if dead:
|
||||||
|
return
|
||||||
if(move_dir == 1 and angle < 1 or move_dir == -1 and angle > PI - 1):
|
if(move_dir == 1 and angle < 1 or move_dir == -1 and angle > PI - 1):
|
||||||
var y = position.length()
|
var y = position.length()
|
||||||
var ratio = - move_dir * broadth / (2 * y)
|
var ratio = - move_dir * broadth / (2 * y)
|
||||||
var rot_angle = - 2 * asin(ratio)
|
var rot_angle = - 2 * asin(ratio)
|
||||||
|
|
||||||
$RayCast2D.global_position = position.rotated(rot_angle)
|
$RayCast2D.global_position = position.rotated(rot_angle)
|
||||||
$RayCast2D.rotation = rot_angle
|
$RayCast2D.rotation = rot_angle
|
||||||
if(move_dir == 1 and angle < 0.5 or move_dir == -1 and angle > PI - 0.5):
|
if(move_dir == 1 and angle < 0.5 or move_dir == -1 and angle > PI - 0.5):
|
||||||
|
|
@ -44,9 +48,12 @@ func _physics_process(delta: float) -> void:
|
||||||
await get_tree().create_timer(pause_time).timeout
|
await get_tree().create_timer(pause_time).timeout
|
||||||
paused = false
|
paused = false
|
||||||
move_dir *= -1
|
move_dir *= -1
|
||||||
|
if dead:
|
||||||
|
return
|
||||||
for i in range(segment_count):
|
for i in range(segment_count):
|
||||||
var segment_pos_data = calculate_segment_location_and_rotation(i)
|
var segment_pos_data = calculate_segment_location_and_rotation(i)
|
||||||
|
if not is_instance_valid(segments[i]):
|
||||||
|
get_tree().get_root().print_tree_pretty()
|
||||||
segments[i].position = segment_pos_data.position
|
segments[i].position = segment_pos_data.position
|
||||||
segments[i].rotation = segment_pos_data.rotation
|
segments[i].rotation = segment_pos_data.rotation
|
||||||
if check_grounded_delay > 0:
|
if check_grounded_delay > 0:
|
||||||
|
|
@ -91,6 +98,7 @@ func hurt(damage : int, _dir):
|
||||||
hp -= damage
|
hp -= damage
|
||||||
$AudioStreamPlayer2D.play()
|
$AudioStreamPlayer2D.play()
|
||||||
if(hp<=0):
|
if(hp<=0):
|
||||||
|
dead = true
|
||||||
for child in get_children():
|
for child in get_children():
|
||||||
if not child is AudioStreamPlayer2D:
|
if not child is AudioStreamPlayer2D:
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/ItemShine.png-41425a3fac8f6530e2b2e4df0c18025
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/updash.png-ddc6856a4b101f20557ef85572ee190a.c
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/backslash.png-149a372aa6b01851fbdc2c6a7a2e54d
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/extrajump.png-5c34a7cf40e9d4d17063d874a102c41
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/platform.png-5334741150dcada29b5e7aa3769fe64f
|
||||||
compress/mode=0
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
process/fix_alpha_border=true
|
process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue