Start, defeat, win screen added

This commit is contained in:
Daydreel 2025-08-20 00:58:53 +02:00
parent 7e0e6b948a
commit 0ea3b1b96d
21 changed files with 192 additions and 53 deletions

Binary file not shown.

View file

@ -1,37 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://wn8v4d1ov3rg"
path="res://.godot/imported/SM_Cube.glb-3d6e772ea9c2777a633e09fa6af3c653.scn"
[deps]
source_file="res://Assets/Models/SM_Cube.glb"
dest_files=["res://.godot/imported/SM_Cube.glb-3d6e772ea9c2777a633e09fa6af3c653.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

View file

@ -49,3 +49,7 @@ signal money_received(_value : int)
#Emitter : world.gd
#Subscriber : cube.gd
signal money_spent(_value : int)
#Emitter : spawner.gd
#Subscriber : cube.gd
signal player_has_won()

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=17 format=3 uid="uid://ky0uewndeuwv"]
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://world.gd" id="1_fj7yv"]
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://Levels/world.gd" id="1_fj7yv"]
[ext_resource type="PackedScene" uid="uid://d1f6m15niwgt" path="res://Tiles/tile.tscn" id="3_aqk2v"]
[ext_resource type="PackedScene" uid="uid://d17sleiqkdoo2" path="res://Assets/GLB format/selection-a.glb" id="3_tlwt5"]
[ext_resource type="PackedScene" uid="uid://do7gm1gjhu1t5" path="res://Tiles/road.tscn" id="4_036b0"]

View file

@ -21,6 +21,7 @@ func _ready() -> void:
call_deferred("display_money_on_first_call")
EventBus.money_received.connect(_on_EventBus_money_received)
EventBus.money_spent.connect(_on_EventBus_money_spent)
EventBus.player_has_won.connect(_on_EventBus_player_has_won)
#Because I can't connect properly on first frame and send money info
func display_money_on_first_call() -> void:
@ -31,8 +32,12 @@ func take_damage(damage : int) -> void:
health -= damage
func win():
get_tree().change_scene_to_file("res://UI/win_screen.tscn")
func death():
print("GAME OVER")
get_tree().change_scene_to_file("res://UI/defeat_screen.tscn")
func _on_EventBus_money_received(money_received : int):
money += money_received
@ -40,3 +45,7 @@ func _on_EventBus_money_received(money_received : int):
func _on_EventBus_money_spent(money_spent : int):
money -= money_spent
func _on_EventBus_player_has_won():
win()

View file

@ -1,23 +1,17 @@
[gd_scene load_steps=5 format=3 uid="uid://dpjfo15otkfru"]
[gd_scene load_steps=4 format=3 uid="uid://dpjfo15otkfru"]
[ext_resource type="Script" uid="uid://bjbmd8pcg5jr8" path="res://Tiles/cube.gd" id="1_wrmut"]
[ext_resource type="PackedScene" uid="uid://wn8v4d1ov3rg" path="res://Assets/Models/SM_Cube.glb" id="2_lacym"]
[ext_resource type="PackedScene" uid="uid://c6ceaa6x357bb" path="res://Assets/Meshes/SM_Cube.glb" id="2_lacym"]
[sub_resource type="BoxShape3D" id="BoxShape3D_ppsqf"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wrmut"]
albedo_color = Color(0.051971, 0.051971, 0.051971, 1)
[node name="TheCube" type="StaticBody3D"]
collision_layer = 8
collision_mask = 8
script = ExtResource("1_wrmut")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.473172, 0)
shape = SubResource("BoxShape3D_ppsqf")
[node name="CSGBox3D" type="CSGBox3D" parent="."]
material = SubResource("StandardMaterial3D_wrmut")
[node name="SM_Cube" parent="." instance=ExtResource("2_lacym")]
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0)
[node name="SM_Cube2" parent="." instance=ExtResource("2_lacym")]

5
UI/defeat_screen.gd Normal file
View file

@ -0,0 +1,5 @@
extends Control
class_name DefeatScreen
func _on_timer_timeout() -> void:
get_tree().change_scene_to_file("res://UI/start_menu.tscn")

1
UI/defeat_screen.gd.uid Normal file
View file

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

45
UI/defeat_screen.tscn Normal file
View file

@ -0,0 +1,45 @@
[gd_scene load_steps=3 format=3 uid="uid://yonrrq1fbs3b"]
[ext_resource type="Script" uid="uid://vjlwfv5wjs1n" path="res://UI/defeat_screen.gd" id="1_g253y"]
[sub_resource type="LabelSettings" id="LabelSettings_i0rmf"]
font_size = 70
[node name="DefeatScreen" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_g253y")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -11.5
offset_right = 20.0
offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
text = "Burned out !"
label_settings = SubResource("LabelSettings_i0rmf")
[node name="Timer" type="Timer" parent="."]
wait_time = 3.0
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

7
UI/level_button.gd Normal file
View file

@ -0,0 +1,7 @@
extends Button
class_name LevelButton
@export_file("*.tscn") var level : String
func _on_pressed() -> void:
get_tree().change_scene_to_file(level)

1
UI/level_button.gd.uid Normal file
View file

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

9
UI/level_button.tscn Normal file
View file

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://88elnilxithv"]
[ext_resource type="Script" uid="uid://cudalakmyqm04" path="res://UI/level_button.gd" id="1_k6cd2"]
[node name="Level1Button" type="Button"]
text = "Level 1"
script = ExtResource("1_k6cd2")
[connection signal="pressed" from="." to="." method="_on_pressed"]

45
UI/start_menu.tscn Normal file
View file

@ -0,0 +1,45 @@
[gd_scene load_steps=2 format=3 uid="uid://2xw1yn1tmlcy"]
[ext_resource type="PackedScene" uid="uid://88elnilxithv" path="res://UI/level_button.tscn" id="1_dl586"]
[node name="StartMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -94.5
offset_top = -20.0
offset_right = 94.5
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
text = "Pole Pixel Defense Force"
[node name="Level1Button" parent="VBoxContainer" instance=ExtResource("1_dl586")]
layout_mode = 2
level = "uid://ky0uewndeuwv"
[node name="QuitButton" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Quit"

5
UI/win_screen.gd Normal file
View file

@ -0,0 +1,5 @@
extends Control
class_name WinScreen
func _on_timer_timeout() -> void:
get_tree().change_scene_to_file("res://UI/start_menu.tscn")

1
UI/win_screen.gd.uid Normal file
View file

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

45
UI/win_screen.tscn Normal file
View file

@ -0,0 +1,45 @@
[gd_scene load_steps=3 format=3 uid="uid://c4ipdjq2xej6j"]
[ext_resource type="Script" uid="uid://camwpkoj31gvn" path="res://UI/win_screen.gd" id="1_t25dr"]
[sub_resource type="LabelSettings" id="LabelSettings_i0rmf"]
font_size = 70
[node name="WinScreen" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_t25dr")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -11.5
offset_right = 20.0
offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
text = "It's the week-end !"
label_settings = SubResource("LabelSettings_i0rmf")
[node name="Timer" type="Timer" parent="."]
wait_time = 3.0
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View file

@ -54,7 +54,7 @@ func attack():
func death() -> void:
is_alive = false
#Global.enemies_alive -= 1
GameManager.enemies_alive -= 1
EventBus.money_received.emit(money)
$Sprite3D.visible = false
var death_vfx : CPUParticles3D = death_vfx_packed.instantiate()

View file

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="Pole Pixel Defense Force"
run/main_scene="uid://ky0uewndeuwv"
run/main_scene="uid://2xw1yn1tmlcy"
config/features=PackedStringArray("4.4")
config/icon="res://icon.svg"

View file

@ -10,7 +10,10 @@ var can_spawn : bool = false
var wave_on_going : bool = false
func spawn_next_wave() -> void:
if waves.is_empty():
EventBus.player_has_won.emit()
return
current_wave = waves.pop_front()
$SpawnTimer.start(current_wave.wait_time_before_next_wave)
@ -34,13 +37,15 @@ func spawn_manager() -> void:
if !can_spawn:
return
#Send next troop
if !current_wave.troops.is_empty() and enemies_to_spawn == 0:
current_troop = current_wave.troops.pop_front()
enemies_to_spawn = current_troop.number_to_spawn
if enemies_to_spawn > 0:
spawn()
print(GameManager.enemies_alive)
if GameManager.enemies_alive > 0:
wave_on_going = true
else: