added game over screen

main
Artur 2026-06-02 21:28:17 +02:00
parent c587fe9e4f
commit 4635bc499b
10 changed files with 111 additions and 8 deletions

View File

@ -114,8 +114,8 @@ script = ExtResource("1_beam00")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=100000001]
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_beam0")
animation = &"end"
frame_progress = 0.02647079
animation = &"start"
frame_progress = 0.6340464
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=100000002]
shape = SubResource("RectangleShape2D_beam0")

View File

@ -11,7 +11,7 @@
[sub_resource type="Resource" id="Resource_i8e30"]
script = ExtResource("2_ullxd")
drop = ExtResource("3_ullxd")
chance = 0.3
chance = 0.6
metadata/_custom_type_script = "uid://cjkaw7wqw4e30"
[sub_resource type="AtlasTexture" id="AtlasTexture_vx4o0"]

View File

@ -737,7 +737,7 @@ radius = 8.062258
[sub_resource type="Resource" id="Resource_chili_drop"]
script = ExtResource("dt_fslime")
drop = ExtResource("chili_fslime")
chance = 0.4
chance = 0.8
[node name="FireSlime" type="CharacterBody2D" unique_id=1827403107]
script = ExtResource("1_88j2t")

View File

@ -4,11 +4,51 @@ extends Node2D
@onready var _spawn_control = $SpawnControl
var _debug_menu_script = preload("res://scripts/debug_menu.gd")
var _game_over_scene = preload("res://scenes/game_over.tscn")
func _ready():
MusicManager.play(preload("res://assets/music&sfx/music/ashveil-355633.mp3"))
add_child(_debug_menu_script.new())
$Witch.died.connect(_on_witch_died)
func _process(_delta: float) -> void:
var t = int(_spawn_control.elapsed_time)
_timer_label.text = "%02d:%02d" % [t / 60, t % 60]
func _on_witch_died(killer) -> void:
var witch = $Witch
var player = $Player
$PauseMenu.process_mode = Node.PROCESS_MODE_DISABLED
get_tree().paused = true
var overlay_layer = CanvasLayer.new()
overlay_layer.layer = 10
overlay_layer.process_mode = Node.PROCESS_MODE_ALWAYS
add_child(overlay_layer)
var overlay = ColorRect.new()
overlay.color = Color(0, 0, 0, 0)
overlay.anchor_right = 1.0
overlay.anchor_bottom = 1.0
overlay.grow_horizontal = Control.GROW_DIRECTION_BOTH
overlay.grow_vertical = Control.GROW_DIRECTION_BOTH
overlay_layer.add_child(overlay)
var highlight_layer = CanvasLayer.new()
highlight_layer.layer = 11
highlight_layer.follow_viewport_enabled = true
highlight_layer.process_mode = Node.PROCESS_MODE_ALWAYS
add_child(highlight_layer)
witch.reparent(highlight_layer, true)
player.reparent(highlight_layer, true)
if is_instance_valid(killer):
killer.reparent(highlight_layer, true)
var tween = create_tween()
tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)
tween.tween_property(overlay, "color", Color(0, 0, 0, 0.85), 2.5)
await tween.finished
var game_over = _game_over_scene.instantiate()
add_child(game_over)

View File

@ -0,0 +1,52 @@
[gd_scene format=3]
[ext_resource type="Script" path="res://scripts/game_over.gd" id="1_go"]
[ext_resource type="FontFile" path="res://assets/fonts/slkscre.ttf" id="2_go"]
[node name="GameOver" type="CanvasLayer"]
layer = 12
process_mode = 3
script = ExtResource("1_go")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -200.0
offset_top = -120.0
offset_right = 200.0
offset_bottom = 120.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 40
alignment = 1
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_go")
theme_override_font_sizes/font_size = 64
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 2
theme_override_constants/shadow_offset_y = 2
text = "Game Over"
horizontal_alignment = 1
[node name="RetryButton" type="Button" parent="VBoxContainer"]
custom_minimum_size = Vector2(200, 45)
layout_mode = 2
theme_override_fonts/font = ExtResource("2_go")
theme_override_font_sizes/font_size = 32
text = "Retry"
[node name="MainMenuButton" type="Button" parent="VBoxContainer"]
custom_minimum_size = Vector2(200, 45)
layout_mode = 2
theme_override_fonts/font = ExtResource("2_go")
theme_override_font_sizes/font_size = 32
text = "Main Menu"
[connection signal="pressed" from="VBoxContainer/RetryButton" to="." method="_on_retry_pressed"]
[connection signal="pressed" from="VBoxContainer/MainMenuButton" to="." method="_on_main_menu_pressed"]

View File

@ -12,7 +12,7 @@
[sub_resource type="Resource" id="Resource_gstla"]
script = ExtResource("2_2npkn")
drop = ExtResource("3_fd6lc")
chance = 0.3
chance = 0.6
metadata/_custom_type_script = "uid://cjkaw7wqw4e30"
[sub_resource type="AtlasTexture" id="AtlasTexture_v5wyi"]

View File

@ -90,7 +90,7 @@ func _play_hurt() -> void:
func _process(delta: float) -> void:
if _touching_witch and not is_dying:
witch.take_damage(damage)
witch.take_damage(damage, self)
func _chase_witch() -> void:
var direction = Vector2(witch.global_position - global_position).normalized()

View File

@ -0,0 +1,9 @@
extends CanvasLayer
func _on_retry_pressed() -> void:
get_tree().paused = false
get_tree().reload_current_scene()
func _on_main_menu_pressed() -> void:
get_tree().paused = false
get_tree().change_scene_to_file("res://scenes/mainmenu.tscn")

View File

@ -0,0 +1 @@
uid://bjmulu6kv40cs

View File

@ -1,6 +1,7 @@
extends CharacterBody2D
signal health_changed(current_hp: int, max_hp: int)
signal died(attacker)
var camera
var is_casting = false
@ -119,7 +120,7 @@ func shoot_laser():
asp.play()
asp.finished.connect(asp.queue_free)
func take_damage(amount: int) -> void:
func take_damage(amount: int, attacker = null) -> void:
if is_invincible:
return
current_hp -= amount
@ -127,7 +128,7 @@ func take_damage(amount: int) -> void:
health_changed.emit(current_hp, max_hp)
_update_hp_bar()
if current_hp <= 0:
get_tree().call_deferred("reload_current_scene")
died.emit(attacker)
return
is_invincible = true
await get_tree().create_timer(0.5).timeout