title screen

This commit is contained in:
Michael Campbell 2026-03-04 14:52:35 -05:00
parent 2fd199612b
commit d464e0499b
12 changed files with 147 additions and 7 deletions

View file

@ -1,5 +1,6 @@
[gd_scene format=3 uid="uid://f2gxwphgniru"]
[ext_resource type="Script" uid="uid://vfvpb7ptujn0" path="res://levels/level.gd" id="1_63c5o"]
[ext_resource type="PackedScene" uid="uid://cv5p3w87nk0wn" path="res://player/player.tscn" id="1_wevqg"]
[ext_resource type="Script" uid="uid://bayj73ugmsbd" path="res://levels/enemy_spawner.gd" id="2_ew5uy"]
@ -11,6 +12,7 @@ geometry_source_geometry_mode = 1
agent_radius = 1.0
[node name="BaseLevel" type="Node3D" unique_id=815380624]
script = ExtResource("1_63c5o")
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="." unique_id=845356554]
visible = false

View file

@ -46,6 +46,7 @@ func _process(_delta: float) -> void:
doomed_point_idx = doomed_point_idx % MAX_CACHED_POINTS
func _on_timer_timeout() -> void:
if not Level.is_active(): return
if points.is_empty():
push_warning("tried to spawn enemy, but can't find a point!")
return

25
levels/level.gd Normal file
View file

@ -0,0 +1,25 @@
class_name Level
extends Node3D
signal level_started
static var level: Level
@export var active := false
var start_time_msec := 0
static func start_game() -> void:
if level:
level.active = true
level.level_started.emit()
level.start_time_msec = Time.get_ticks_msec()
static func is_active() -> bool:
if level:
return level.active
else:
return false
func _ready() -> void:
level = self

1
levels/level.gd.uid Normal file
View file

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

File diff suppressed because one or more lines are too long

View file

@ -119,6 +119,7 @@ func _process_cam_shake(delta: float) -> void:
%Camera3D.position += v * .5
func _process(delta: float) -> void:
if not Level.is_active(): return
match state:
State.NORMAL: _process_movement(delta)
State.DASHING: _process_dash()
@ -146,4 +147,4 @@ func damage(damager: Node3D) -> void:
if health == 0:
pass
#get_tree().reload_current_scene()
get_tree().reload_current_scene()

View file

@ -1,6 +1,7 @@
[gd_scene format=3 uid="uid://cv5p3w87nk0wn"]
[ext_resource type="Script" uid="uid://dhin7ux2njfja" path="res://player/player.gd" id="1_4flbx"]
[ext_resource type="Script" uid="uid://fe3m1ax0w2lh" path="res://player/player_hud.gd" id="2_g6k8r"]
[ext_resource type="Script" uid="uid://cjdxibg3pnans" path="res://player/score_label.gd" id="2_onrkg"]
[ext_resource type="Script" uid="uid://fv1n5noqdfg2" path="res://player/guns/basic_gun.gd" id="3_g1dw6"]
[ext_resource type="Script" uid="uid://b87cyvu2m5b1k" path="res://player/guns/mini_gun.gd" id="4_yw30f"]
@ -48,16 +49,17 @@ unique_name_in_owner = true
visible = false
mesh = SubResource("SphereMesh_4flbx")
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1676328708]
[node name="PlayerHUD" type="CanvasLayer" parent="." unique_id=1676328708]
script = ExtResource("2_g6k8r")
[node name="ScoreLabel" type="Label" parent="CanvasLayer" unique_id=1108751125]
[node name="ScoreLabel" type="Label" parent="PlayerHUD" unique_id=1108751125]
offset_right = 40.0
offset_bottom = 23.0
theme_override_font_sizes/font_size = 48
text = "Score: %s"
script = ExtResource("2_onrkg")
[node name="HealthLabel" type="Label" parent="CanvasLayer" unique_id=1653322479]
[node name="HealthLabel" type="Label" parent="PlayerHUD" unique_id=1653322479]
unique_name_in_owner = true
anchors_preset = 10
anchor_right = 1.0
@ -68,7 +70,7 @@ theme_override_font_sizes/font_size = 48
text = "Health: 2"
horizontal_alignment = 2
[node name="StaminaBar" type="ProgressBar" parent="CanvasLayer" unique_id=961689130]
[node name="StaminaBar" type="ProgressBar" parent="PlayerHUD" unique_id=961689130]
unique_name_in_owner = true
anchors_preset = 7
anchor_left = 0.5
@ -83,7 +85,7 @@ grow_vertical = 0
max_value = 1.0
show_percentage = false
[node name="Label" type="Label" parent="CanvasLayer/StaminaBar" unique_id=1238654404]
[node name="Label" type="Label" parent="PlayerHUD/StaminaBar" unique_id=1238654404]
layout_mode = 0
offset_left = 132.0
offset_top = -27.0
@ -91,7 +93,7 @@ offset_right = 196.0
offset_bottom = -4.0
text = "Stamina"
[node name="GunLabel" type="Label" parent="CanvasLayer" unique_id=220052210]
[node name="GunLabel" type="Label" parent="PlayerHUD" unique_id=220052210]
unique_name_in_owner = true
anchors_preset = 12
anchor_top = 1.0

4
player/player_hud.gd Normal file
View file

@ -0,0 +1,4 @@
extends CanvasLayer
func _process(_delta: float) -> void:
visible = Level.is_active()

1
player/player_hud.gd.uid Normal file
View file

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

View file

@ -0,0 +1,10 @@
extends Control
func _on_play_pressed() -> void:
Level.start_game()
queue_free()
func _on_quit_pressed() -> void:
get_tree().quit()

View file

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

View file

@ -0,0 +1,89 @@
[gd_scene format=3 uid="uid://c04ppsrjrkxb6"]
[ext_resource type="Script" uid="uid://cmhdeukt6fwh8" path="res://ui/title_screen/title_screen.gd" id="1_4kwlo"]
[sub_resource type="FontVariation" id="FontVariation_ffat2"]
variation_transform = Transform2D(1, -0.31, 0.37, 1.2, 0, 0)
spacing_glyph = 5
[sub_resource type="Theme" id="Theme_72buf"]
Label/constants/outline_size = 23
Label/font_sizes/font_size = 62
Label/fonts/font = SubResource("FontVariation_ffat2")
[node name="TitleScreen" type="Control" unique_id=786988901]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_4kwlo")
[node name="Play" type="Button" parent="." unique_id=1486558611]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -68.5
offset_top = 100.0
offset_right = 68.5
offset_bottom = 196.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/font_size = 64
text = "Play"
[node name="Title" type="Control" parent="." unique_id=511532633]
anchors_preset = 0
offset_left = 44.0
offset_top = 36.0
offset_right = 84.0
offset_bottom = 76.0
[node name="Road" type="Label" parent="Title" unique_id=1072273524]
layout_mode = 0
offset_right = 226.0
offset_bottom = 118.0
theme = SubResource("Theme_72buf")
text = "Road"
[node name="Rage" type="Label" parent="Title" unique_id=388165898]
layout_mode = 0
offset_left = 63.0
offset_top = 66.0
offset_right = 289.0
offset_bottom = 184.0
theme = SubResource("Theme_72buf")
text = "Rage"
[node name="Tank" type="Label" parent="Title" unique_id=1229189390]
layout_mode = 0
offset_left = 117.0
offset_top = 144.0
offset_right = 343.0
offset_bottom = 262.0
theme = SubResource("Theme_72buf")
text = "Tank"
[node name="Quit" type="Button" parent="." unique_id=1707190783]
custom_minimum_size = Vector2(136.595, 0)
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -40.5
offset_top = -97.0
offset_right = 40.5
offset_bottom = -40.0
grow_horizontal = 2
grow_vertical = 0
theme_override_font_sizes/font_size = 35
text = "Quit"
[connection signal="pressed" from="Play" to="." method="_on_play_pressed"]
[connection signal="pressed" from="Quit" to="." method="_on_quit_pressed"]