Small Godot Wild Jam game
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Complete gameover and reset logic

+179 -10
+1
.gitignore
··· 17 17 .DS_Store 18 18 19 19 Movies/ 20 + .vscode/
+5
Scenes/Endings/game_over.gd
··· 1 + extends CanvasLayer 2 + 3 + 4 + func _on_button_pressed() -> void: 5 + get_tree().reload_current_scene()
+1
Scenes/Endings/game_over.gd.uid
··· 1 + uid://c64tmhriw2asv
+58
Scenes/Endings/game_over.tscn
··· 1 + [gd_scene load_steps=3 format=3 uid="uid://dsjdsgahl2jrg"] 2 + 3 + [ext_resource type="Script" uid="uid://c64tmhriw2asv" path="res://Scenes/Endings/game_over.gd" id="1_0x08w"] 4 + [ext_resource type="FontFile" uid="uid://da2t6lyf41wty" path="res://Assets/fonts/open-sans/open-sans-bold.ttf" id="1_u1ybo"] 5 + 6 + [node name="GameOver" type="CanvasLayer"] 7 + process_mode = 3 8 + layer = 50 9 + script = ExtResource("1_0x08w") 10 + 11 + [node name="ColorRect" type="ColorRect" parent="."] 12 + anchors_preset = 15 13 + anchor_right = 1.0 14 + anchor_bottom = 1.0 15 + grow_horizontal = 2 16 + grow_vertical = 2 17 + color = Color(0.290196, 0.0431373, 0.0901961, 0.705882) 18 + 19 + [node name="CenterContainer" type="CenterContainer" parent="."] 20 + anchors_preset = 15 21 + anchor_right = 1.0 22 + anchor_bottom = 1.0 23 + grow_horizontal = 2 24 + grow_vertical = 2 25 + 26 + [node name="ColorRect" type="ColorRect" parent="CenterContainer"] 27 + custom_minimum_size = Vector2(1700, 900) 28 + layout_mode = 2 29 + color = Color(0.260506, 0.260506, 0.260506, 0.501961) 30 + 31 + [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] 32 + layout_mode = 2 33 + 34 + [node name="Label" type="Label" parent="CenterContainer/VBoxContainer"] 35 + layout_mode = 2 36 + theme_override_fonts/font = ExtResource("1_u1ybo") 37 + theme_override_font_sizes/font_size = 201 38 + text = "GAME OVER" 39 + horizontal_alignment = 1 40 + vertical_alignment = 1 41 + 42 + [node name="Label2" type="Label" parent="CenterContainer/VBoxContainer"] 43 + layout_mode = 2 44 + theme_override_font_sizes/font_size = 31 45 + text = "The people of this town have all succumbed to sickness, injury and Absence... 46 + 47 + There are enough souls left for a final ritual to go back and try again, are you willing to make that sacrafice?" 48 + horizontal_alignment = 1 49 + vertical_alignment = 1 50 + 51 + [node name="Button" type="Button" parent="CenterContainer/VBoxContainer"] 52 + layout_mode = 2 53 + size_flags_horizontal = 4 54 + size_flags_vertical = 4 55 + theme_override_font_sizes/font_size = 61 56 + text = "Retry?" 57 + 58 + [connection signal="pressed" from="CenterContainer/VBoxContainer/Button" to="." method="_on_button_pressed"]
+58
Scenes/Endings/victory.tscn
··· 1 + [gd_scene load_steps=3 format=3 uid="uid://bxnijq8dhysth"] 2 + 3 + [ext_resource type="Script" uid="uid://c64tmhriw2asv" path="res://Scenes/Endings/game_over.gd" id="1_ildbe"] 4 + [ext_resource type="FontFile" uid="uid://da2t6lyf41wty" path="res://Assets/fonts/open-sans/open-sans-bold.ttf" id="2_vay72"] 5 + 6 + [node name="Victory" type="CanvasLayer"] 7 + process_mode = 3 8 + layer = 50 9 + script = ExtResource("1_ildbe") 10 + 11 + [node name="ColorRect" type="ColorRect" parent="."] 12 + anchors_preset = 15 13 + anchor_right = 1.0 14 + anchor_bottom = 1.0 15 + grow_horizontal = 2 16 + grow_vertical = 2 17 + color = Color(0.168627, 0.662745, 0.403922, 0.705882) 18 + 19 + [node name="CenterContainer" type="CenterContainer" parent="."] 20 + anchors_preset = 15 21 + anchor_right = 1.0 22 + anchor_bottom = 1.0 23 + grow_horizontal = 2 24 + grow_vertical = 2 25 + 26 + [node name="ColorRect" type="ColorRect" parent="CenterContainer"] 27 + custom_minimum_size = Vector2(1700, 900) 28 + layout_mode = 2 29 + color = Color(0.260506, 0.260506, 0.260506, 0.501961) 30 + 31 + [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] 32 + layout_mode = 2 33 + 34 + [node name="Label" type="Label" parent="CenterContainer/VBoxContainer"] 35 + layout_mode = 2 36 + theme_override_fonts/font = ExtResource("2_vay72") 37 + theme_override_font_sizes/font_size = 201 38 + text = "VICTORY" 39 + horizontal_alignment = 1 40 + vertical_alignment = 1 41 + 42 + [node name="Label2" type="Label" parent="CenterContainer/VBoxContainer"] 43 + layout_mode = 2 44 + theme_override_font_sizes/font_size = 31 45 + text = "You have driven out all of the Absence in the town folk and saved many lives! 46 + 47 + You deserve a long rest, though if you want to try again there are many souls in town for the reset ritual" 48 + horizontal_alignment = 1 49 + vertical_alignment = 1 50 + 51 + [node name="Button" type="Button" parent="CenterContainer/VBoxContainer"] 52 + layout_mode = 2 53 + size_flags_horizontal = 4 54 + size_flags_vertical = 4 55 + theme_override_font_sizes/font_size = 61 56 + text = "Retry?" 57 + 58 + [connection signal="pressed" from="CenterContainer/VBoxContainer/Button" to="." method="_on_button_pressed"]
+20
Scenes/gameplay/gameplay.gd
··· 17 17 @onready var sfx_sick: AudioStreamPlayer = $Audio/SfxSick 18 18 @onready var sfx_error: AudioStreamPlayer = $Audio/SfxError 19 19 20 + @onready var game_over: CanvasLayer = $GameOver 21 + @onready var victory: CanvasLayer = $Victory 22 + 23 + var is_game_over: bool = false 20 24 21 25 #endregion 22 26 ··· 46 50 SignalBus.play_cured.connect(play_cured) 47 51 SignalBus.play_sick.connect(play_sick) 48 52 SignalBus.play_error.connect(play_error) 53 + 54 + SignalBus.updated_scores.connect(_handle_game_end) 49 55 56 + func _handle_game_end() -> void: 57 + if is_game_over: 58 + return 59 + 60 + if Global.people_cured >= Global.CURED_CITIZENS_FOR_VICTORY: 61 + is_game_over = true 62 + Global.people_cured = Global.CURED_CITIZENS_FOR_VICTORY # to stop any accidental overshot 63 + victory.visible = true 64 + get_tree().paused = true 65 + elif Global.people_sick >= Global.population_total: 66 + is_game_over = true 67 + Global.people_sick = Global.population_total # to stop any accidental overshot 68 + game_over.visible = true 69 + get_tree().paused = true 50 70 51 71 func _on_event_pin_clicked(house_name: String, target_location: Vector2, house_type: Global.HouseType): 52 72 var new_dialogue_container = DIALOGUE_CONTAINER.instantiate()
+9 -1
Scenes/gameplay/gameplay.tscn
··· 1 - [gd_scene load_steps=45 format=4 uid="uid://4fyoq8npekf0"] 1 + [gd_scene load_steps=47 format=4 uid="uid://4fyoq8npekf0"] 2 2 3 3 [ext_resource type="PackedScene" uid="uid://barl4q1kugrmm" path="res://Scenes/gameplay/pause-layer/pause-layer.tscn" id="2"] 4 4 [ext_resource type="PackedScene" uid="uid://dargaogktwt8h" path="res://Scenes/tutorial_layer/tutorial_layer.tscn" id="2_b51cm"] 5 + [ext_resource type="PackedScene" uid="uid://dsjdsgahl2jrg" path="res://Scenes/Endings/game_over.tscn" id="2_k4mi4"] 6 + [ext_resource type="PackedScene" uid="uid://bxnijq8dhysth" path="res://Scenes/Endings/victory.tscn" id="3_e25m7"] 5 7 [ext_resource type="PackedScene" uid="uid://chise44bjuof6" path="res://Scenes/houses/noble_house.tscn" id="4_1f1h4"] 6 8 [ext_resource type="Script" uid="uid://bhgboyg8ipyan" path="res://addons/TopDownCamera2D/top_down_camera_2d.gd" id="4_1f1us"] 7 9 [ext_resource type="Texture2D" uid="uid://c5gj7o2qp5ksm" path="res://Assets/sprites/town_assets/horizontal_wall.png" id="4_yl1gb"] ··· 79 81 80 82 [node name="Gameplay" type="Node"] 81 83 script = ExtResource("5") 84 + 85 + [node name="GameOver" parent="." instance=ExtResource("2_k4mi4")] 86 + visible = false 87 + 88 + [node name="Victory" parent="." instance=ExtResource("3_e25m7")] 89 + visible = false 82 90 83 91 [node name="TutorialLayer" parent="." instance=ExtResource("2_b51cm")] 84 92 layer = 100
+3 -3
Scenes/ui/ui.gd
··· 13 13 14 14 15 15 func _ready() -> void: 16 - cured_people.max_value = 20 # Change to cured people to win 16 + cured_people.max_value = Global.CURED_CITIZENS_FOR_VICTORY # Change to cured people to win 17 17 sick_people.max_value = Global.population_total 18 18 19 19 update_ui_metrics() ··· 21 21 22 22 func update_ui_metrics(): 23 23 # Access and set the Global variables to the UI metrics 24 - sick_people.value = Global.people_sick + Global.STARTER_SICK_COUNTER 25 - sick_people_counter.text = str(Global.people_sick + Global.STARTER_SICK_COUNTER) 24 + sick_people.value = Global.people_sick 25 + sick_people_counter.text = str(Global.people_sick) 26 26 27 27 cured_people.value = Global.people_cured 28 28 cured_people_counter.text = str(Global.people_cured)
+22 -6
Scripts/global.gd
··· 1 1 extends Node 2 2 3 3 #region DEV OPTIONS 4 - const PAUSE_ON_EVENT: bool = true # Pauses the game while the player is making decisions 4 + const PAUSE_ON_EVENT: bool = false # Pauses the game while the player is making decisions 5 + const APPLY_MULT_TO_FAILED_CHOICE: bool = true # Pauses the game while the player is making decisions 5 6 #endregion 6 7 7 8 #region Varaibles ··· 9 10 var is_currently_in_decision: bool = false 10 11 @onready var rng := RandomNumberGenerator.new() 11 12 12 - var population_total: int = 150 13 + const population_total: int = 120 13 14 14 15 var people_cured: int = 0: 15 16 get: ··· 17 18 set(value): 18 19 people_cured = value 19 20 SignalBus.update_ui_metrics.emit() 21 + SignalBus.updated_scores.emit() 20 22 21 23 var people_sick: int = 0: 22 24 get: ··· 24 26 set(value): 25 27 people_sick = value 26 28 SignalBus.update_ui_metrics.emit() 29 + SignalBus.updated_scores.emit() 27 30 28 31 var available_doctors: int = 2: 29 32 get: ··· 41 44 enum UnitType {DOCTOR, PRIEST} 42 45 enum HouseType {PEASANT, NOBLE} 43 46 47 + const CURED_CITIZENS_FOR_VICTORY: int = 20 44 48 const STARTER_SICK_COUNTER: int = 15 45 49 46 50 var target_location: Vector2 ··· 51 55 return (available_doctors + available_priests > 0) 52 56 53 57 func handle_choice_result(result: bool, house_type: HouseType) -> void: 54 - if result: 55 - var mult: int = 1 56 - if house_type == HouseType.NOBLE: 58 + var mult: int = 1 59 + if house_type == HouseType.NOBLE: 57 60 mult = 2 61 + 62 + if result: 58 63 people_cured += 1 * mult 59 64 people_sick -= 3 * mult 60 65 #SignalBus.play_cured.emit() 61 66 else: 62 - people_sick += 2 67 + var incr_value := 2 68 + if APPLY_MULT_TO_FAILED_CHOICE: 69 + incr_value = incr_value * mult 70 + people_sick += incr_value 63 71 #SignalBus.play_sick.emit() 64 72 65 73 func _init() -> void: 66 74 Console.register_custom_command("debug", _toggle_debug_mode) 67 75 Console.register_custom_command("fps", _get_fps) 68 76 #Console.register_custom_command("spawn_doctor", _spawn_unit) 77 + 78 + people_sick = STARTER_SICK_COUNTER 79 + 80 + # In reality all these values should be moved to gameplay but it's not necesary for what is effectively a demo 81 + func reset() -> void: 82 + people_cured = 0 83 + people_sick = STARTER_SICK_COUNTER 84 + is_currently_in_decision = false 69 85 70 86 func get_target_location() -> Vector2: 71 87 return target_location
+2
Scripts/signal_bus.gd
··· 10 10 signal play_cured 11 11 signal play_sick 12 12 signal play_error 13 + 14 + signal updated_scores