Skip to content

Commit

Permalink
Create Win Overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
Hope-Parnell committed May 1, 2023
1 parent c99ad36 commit 6209b1f
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sick_Day_Delivery/Scenes/game_over.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func game_over(time):


func _on_play_again_pressed():
get_tree().reload_current_scene()
GlobalState.reset_state()
get_tree().reload_current_scene()


func _on_quit_pressed():
Expand Down
5 changes: 5 additions & 0 deletions Sick_Day_Delivery/Scenes/game_over.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.454902, 0.878431, 0.235294, 0.356863)
metadata/_edit_use_anchors_ = true

[node name="GameOver" type="Label" parent="Canvas"]
anchors_preset = 10
Expand All @@ -36,6 +37,7 @@ theme_override_font_sizes/font_size = 64
text = "Game Over"
horizontal_alignment = 1
vertical_alignment = 1
metadata/_edit_use_anchors_ = true

[node name="Message" type="Label" parent="Canvas"]
anchors_preset = 10
Expand All @@ -50,6 +52,7 @@ text = "Bacterium Killed: 0
Colonies Destroyed: 0
Elapsed Time: 0:00"
horizontal_alignment = 1
metadata/_edit_use_anchors_ = true

[node name="PlayAgain" type="Button" parent="Canvas"]
offset_left = 721.0
Expand All @@ -58,6 +61,7 @@ offset_right = 1173.0
offset_bottom = 653.0
theme_override_font_sizes/font_size = 64
text = "Play Again?"
metadata/_edit_use_anchors_ = true

[node name="Quit" type="Button" parent="Canvas"]
offset_left = 721.0
Expand All @@ -66,6 +70,7 @@ offset_right = 1173.0
offset_bottom = 821.0
theme_override_font_sizes/font_size = 64
text = "Quit"
metadata/_edit_use_anchors_ = true

[connection signal="pressed" from="Canvas/PlayAgain" to="." method="_on_play_again_pressed"]
[connection signal="pressed" from="Canvas/Quit" to="." method="_on_quit_pressed"]
5 changes: 4 additions & 1 deletion Sick_Day_Delivery/Scenes/main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=3 uid="uid://b4xi3mlkhu4ow"]
[gd_scene load_steps=11 format=3 uid="uid://b4xi3mlkhu4ow"]

[ext_resource type="PackedScene" uid="uid://bhh5dmfulsc0f" path="res://Scenes/body_map.tscn" id="1_6xrru"]
[ext_resource type="Script" path="res://Scripts/main.gd" id="1_mnr5t"]
Expand All @@ -9,6 +9,7 @@
[ext_resource type="PackedScene" uid="uid://by2kd0e26letn" path="res://Scenes/HUD.tscn" id="8_to7ic"]
[ext_resource type="PackedScene" uid="uid://ccvpanj0i8wfv" path="res://Scenes/pause_menu.tscn" id="9_y16aj"]
[ext_resource type="PackedScene" uid="uid://dd7jyka6e2eh0" path="res://Scenes/game_over.tscn" id="10_qc34m"]
[ext_resource type="PackedScene" uid="uid://cq5e6witw2k2u" path="res://Scenes/win.tscn" id="10_yous1"]

[node name="Node2D" type="Node2D"]
script = ExtResource("1_mnr5t")
Expand Down Expand Up @@ -66,3 +67,5 @@ position = Vector2(1554, 1541)
[node name="PauseMenu" parent="." instance=ExtResource("9_y16aj")]

[node name="GameOver" parent="." instance=ExtResource("10_qc34m")]

[node name="Win" parent="." instance=ExtResource("10_yous1")]
72 changes: 72 additions & 0 deletions Sick_Day_Delivery/Scenes/win.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[gd_scene load_steps=2 format=3 uid="uid://cq5e6witw2k2u"]

[ext_resource type="Script" path="res://Scripts/Win.gd" id="1_dknb4"]

[node name="Win" type="Control"]
process_mode = 3
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_dknb4")

[node name="Canvas" type="CanvasLayer" parent="."]

[node name="ColorRect" type="ColorRect" parent="Canvas"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.0901961, 0.894118, 1, 0.356863)
metadata/_edit_use_anchors_ = true

[node name="YouWin" type="Label" parent="Canvas"]
anchors_preset = 10
anchor_right = 1.0
offset_top = 159.0
offset_right = -826.0
offset_bottom = 250.0
grow_horizontal = 2
scale = Vector2(1.74971, 1.70331)
theme_override_font_sizes/font_size = 64
text = "You Win!"
horizontal_alignment = 1
vertical_alignment = 1
metadata/_edit_use_anchors_ = true

[node name="Message" type="Label" parent="Canvas"]
anchors_preset = 10
anchor_right = 1.0
offset_top = 354.0
offset_bottom = 627.0
grow_horizontal = 2
theme_override_font_sizes/font_size = 64
text = "Bacterium Killed: 0
Colonies Destroyed: 0
Elapsed Time: 0:00"
horizontal_alignment = 1
metadata/_edit_use_anchors_ = true

[node name="PlayAgain" type="Button" parent="Canvas"]
offset_left = 723.0
offset_top = 682.0
offset_right = 1175.0
offset_bottom = 809.0
theme_override_font_sizes/font_size = 64
text = "Play Again?"
metadata/_edit_use_anchors_ = true

[node name="Quit" type="Button" parent="Canvas"]
offset_left = 723.0
offset_top = 850.0
offset_right = 1175.0
offset_bottom = 977.0
theme_override_font_sizes/font_size = 64
text = "Quit"
metadata/_edit_use_anchors_ = true

[connection signal="pressed" from="Canvas/PlayAgain" to="." method="_on_play_again_pressed"]
[connection signal="pressed" from="Canvas/Quit" to="." method="_on_quit_pressed"]
29 changes: 29 additions & 0 deletions Sick_Day_Delivery/Scripts/Win.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extends Control

@export var quit_scene : PackedScene
# Called when the node enters the scene tree for the first time.
func _ready():
$Canvas.visible = false


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

func win(time):
$Canvas/Message.text = "Bacterium Killed: %d\nColonies Destroyed: %d\nElapsed Time: %s" %[GlobalState.enemies_destroyed, GlobalState.colonies_destroyed, time]
$Canvas.visible = true
get_tree().paused = true


func _on_play_again_pressed():
GlobalState.reset_state()
get_tree().paused = false
get_tree().reload_current_scene()


func _on_quit_pressed():
if OS.get_name() == "Web":
get_tree().change_scene_to_packed(quit_scene)
else:
get_tree().quit()
14 changes: 10 additions & 4 deletions Sick_Day_Delivery/Scripts/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ func _ready():
$PauseMenu.process_mode = Node.PROCESS_MODE_ALWAYS
$PlayerCell.process_mode = Node.PROCESS_MODE_INHERIT
$HUD.process_mode = Node.PROCESS_MODE_INHERIT
$GameOver.process_mode = Node.PROCESS_MODE_INHERIT

func _on_global_state_on_game_over():
print("game over 😭")
game_over()
game_end()
$GameOver.game_over($HUD/Time/TimeAlive.text)

func _process(delta):
if Input.is_action_just_pressed("game_over"):
game_over()
game_end()
$GameOver.game_over($HUD/Time/TimeAlive.text)
if Input.is_action_just_pressed("win"):
$PauseMenu.process_mode = Node.PROCESS_MODE_DISABLED
$Win.win($HUD/Time/TimeAlive.text)

func game_over():
func game_end():
$PauseMenu.process_mode = Node.PROCESS_MODE_DISABLED
$PlayerCell.process_mode = Node.PROCESS_MODE_DISABLED
$HUD.process_mode = Node.PROCESS_MODE_DISABLED
$GameOver.game_over($HUD/Time/TimeAlive.text)
$HUD.visible = false
5 changes: 5 additions & 0 deletions Sick_Day_Delivery/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ game_over={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194312,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
win={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194327,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}

[rendering]

Expand Down

0 comments on commit 6209b1f

Please sign in to comment.