lose screen gui working well
This commit is contained in:
parent
d2dfb65d59
commit
bfaef2f33f
3 changed files with 68 additions and 8 deletions
|
|
@ -12,7 +12,7 @@ var tick_timer : float = 0
|
||||||
var room_started : bool = false
|
var room_started : bool = false
|
||||||
var current_tick = 0
|
var current_tick = 0
|
||||||
var failed : bool = false
|
var failed : bool = false
|
||||||
var fail_timer : float = 3
|
var fail_timer : float = 2
|
||||||
|
|
||||||
@export_group("Resources")
|
@export_group("Resources")
|
||||||
@export var pedestal_off_mat : Material
|
@export var pedestal_off_mat : Material
|
||||||
|
|
@ -43,17 +43,20 @@ func _process(delta):
|
||||||
start_room()
|
start_room()
|
||||||
|
|
||||||
if Input.is_action_just_pressed("reset"):
|
if Input.is_action_just_pressed("reset"):
|
||||||
|
gui.show_lose_screen("Reset Pressed", 3)
|
||||||
fail_room()
|
fail_room()
|
||||||
|
|
||||||
if room_started and current_tick < level_time+1:
|
if room_started and current_tick < level_time+1:
|
||||||
tick_timer += delta
|
tick_timer += delta
|
||||||
|
|
||||||
if tick_timer > level_tick: #advance tick
|
if tick_timer > level_tick: #advance tick
|
||||||
if current_tick == 11:
|
|
||||||
#fail_room()
|
|
||||||
pass
|
|
||||||
tick_timer = 0
|
tick_timer = 0
|
||||||
current_tick += 1
|
current_tick += 1
|
||||||
|
if current_tick == 11:
|
||||||
|
gui.show_lose_screen("Time Expired", 3)
|
||||||
|
fail_room()
|
||||||
|
pass
|
||||||
print("Tick: " + str(current_tick))
|
print("Tick: " + str(current_tick))
|
||||||
for i in pedestals.size():
|
for i in pedestals.size():
|
||||||
if i+1 == current_tick:
|
if i+1 == current_tick:
|
||||||
|
|
@ -71,10 +74,11 @@ func _process(delta):
|
||||||
chime_player.play()
|
chime_player.play()
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
|
gui.show_lose_screen("", fail_timer)
|
||||||
world_env.environment.background_color = Color.DIM_GRAY
|
world_env.environment.background_color = Color.DIM_GRAY
|
||||||
fail_timer -= delta
|
fail_timer -= delta
|
||||||
if fail_timer < 0:
|
if fail_timer < 0:
|
||||||
fail_timer = 3
|
fail_timer = 2
|
||||||
reset_room()
|
reset_room()
|
||||||
else:
|
else:
|
||||||
world_env.environment.background_color = Color.WHITE
|
world_env.environment.background_color = Color.WHITE
|
||||||
|
|
@ -128,6 +132,7 @@ func reset_room():
|
||||||
player.rotation_degrees = Vector3(0,0,0)
|
player.rotation_degrees = Vector3(0,0,0)
|
||||||
player.camera.rotation_degrees = Vector3(0,0,0)
|
player.camera.rotation_degrees = Vector3(0,0,0)
|
||||||
|
|
||||||
|
gui.hide_lose_screen()
|
||||||
|
|
||||||
tick_timer = 0
|
tick_timer = 0
|
||||||
room_started = false
|
room_started = false
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,26 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
@export_group("Node References")
|
@export_group("Node References")
|
||||||
|
@export var lose_panel : PanelContainer
|
||||||
|
@export var lose_label : Label
|
||||||
|
@export var reset_label : Label
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
lose_panel.visible = false
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func show_lose_screen(lose_text : String, reset_timer : float):
|
||||||
|
lose_panel.visible = true
|
||||||
|
if lose_text != "":
|
||||||
|
lose_label.text = lose_text
|
||||||
|
reset_label.text = "Resetting in: " + str(round(reset_timer*10)/10)
|
||||||
|
|
||||||
|
func hide_lose_screen():
|
||||||
|
lose_panel.visible = false
|
||||||
|
pass
|
||||||
|
|
|
||||||
46
gui.tscn
46
gui.tscn
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bnlexkofp68gv"]
|
[gd_scene load_steps=6 format=3 uid="uid://bnlexkofp68gv"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/gui.gd" id="1_7s0l7"]
|
[ext_resource type="Script" path="res://Scripts/gui.gd" id="1_7s0l7"]
|
||||||
[ext_resource type="Texture2D" uid="uid://buafet16thf3p" path="res://Assets/crosshair.png" id="1_mpwvh"]
|
[ext_resource type="Texture2D" uid="uid://buafet16thf3p" path="res://Assets/crosshair.png" id="1_mpwvh"]
|
||||||
|
|
@ -6,7 +6,14 @@
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_lrnc3"]
|
[sub_resource type="LabelSettings" id="LabelSettings_lrnc3"]
|
||||||
font_color = Color(1, 0, 0, 1)
|
font_color = Color(1, 0, 0, 1)
|
||||||
|
|
||||||
[node name="Gui" type="Control"]
|
[sub_resource type="LabelSettings" id="LabelSettings_v7sqr"]
|
||||||
|
font_size = 60
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_rdkfa"]
|
||||||
|
font_size = 30
|
||||||
|
font_color = Color(0.662452, 0.662452, 0.662452, 1)
|
||||||
|
|
||||||
|
[node name="Gui" type="Control" node_paths=PackedStringArray("lose_panel", "lose_label", "reset_label")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
@ -14,8 +21,12 @@ anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_7s0l7")
|
script = ExtResource("1_7s0l7")
|
||||||
|
lose_panel = NodePath("MarginContainer/PanelContainer")
|
||||||
|
lose_label = NodePath("MarginContainer/PanelContainer/VBoxContainer/LoseText")
|
||||||
|
reset_label = NodePath("MarginContainer/PanelContainer/VBoxContainer/LoseTimer")
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
|
visible = false
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
offset_bottom = 23.0
|
offset_bottom = 23.0
|
||||||
|
|
@ -36,3 +47,34 @@ custom_minimum_size = Vector2(10, 10)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
texture = ExtResource("1_mpwvh")
|
texture = ExtResource("1_mpwvh")
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_constants/margin_left = 200
|
||||||
|
theme_override_constants/margin_top = 150
|
||||||
|
theme_override_constants/margin_right = 200
|
||||||
|
theme_override_constants/margin_bottom = 150
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="LoseText" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Level Failed"
|
||||||
|
label_settings = SubResource("LabelSettings_v7sqr")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="LoseTimer" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Resetting in: 3.0"
|
||||||
|
label_settings = SubResource("LabelSettings_rdkfa")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue