Roughly reorganized UI into canvas layers in the game scene for Jennie.

This commit is contained in:
Henry 2026-05-09 11:47:45 +01:00
parent f8fdeff2d6
commit 7939e77dff
11 changed files with 187 additions and 31 deletions

42
scenes/elevator_panel.gd Normal file
View file

@ -0,0 +1,42 @@
extends Control
# I HAVE NO IDEA WHAT I'M DOIN!!!
# Original version
var current_floor := 10
var saved_count := 0
var doors_closing := false
func _ready():
$PanelMargin/PanelColumn/CloseButton.pressed.connect(_on_close_pressed)
# 10 floors is probably a lot but will make testing easier.
#$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: 10"
func _unhandled_input(event):
if event is InputEventKey and event.pressed and event.keycode == KEY_SPACE:
_on_close_pressed()
func _on_close_pressed():
# don't let 'em spam the button
if doors_closing:
return
var screen = $ElevatorPanel/PanelMargin/PanelColumn/Screen
var success = screen.attempt_hack()
if success:
doors_closing = true
saved_count += 1
current_floor -= 1
$StatsMargin/StatsColumn/SavedLabel.text = "SAVED: " + str(saved_count)
$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: " + str(current_floor)
if current_floor <= 1:
screen.show_win()
else:
screen.show_countdown()
var tween = create_tween()
tween.tween_callback(func():
screen.reset_hack()
doors_closing = false
).set_delay(2.0)
else:
print("MISSED! AI is faster now!")

View file

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

View file

@ -0,0 +1,68 @@
[gd_scene format=3 uid="uid://nca1hcujxru0"]
[ext_resource type="Script" uid="uid://k1n4iyxp4iww" path="res://scenes/elevator_panel.gd" id="1_1gr6t"]
[ext_resource type="Script" uid="uid://kltqwef8yx3r" path="res://scenes/screen.gd" id="1_3gei6"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2snw"]
bg_color = Color(0.039215688, 0.16470589, 0.039215688, 1)
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
[node name="ElevatorPanel" type="PanelContainer" unique_id=574176994]
custom_minimum_size = Vector2(250, 0)
anchors_preset = 11
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -8.0
grow_horizontal = 0
grow_vertical = 2
script = ExtResource("1_1gr6t")
[node name="PanelMargin" type="MarginContainer" parent="." unique_id=1575963889]
layout_mode = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="PanelColumn" type="VBoxContainer" parent="PanelMargin" unique_id=434338875]
layout_mode = 2
[node name="Screen" type="Panel" parent="PanelMargin/PanelColumn" unique_id=1395085208]
custom_minimum_size = Vector2(200, 200)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_n2snw")
script = ExtResource("1_3gei6")
[node name="TargetZone" type="ColorRect" parent="PanelMargin/PanelColumn/Screen" unique_id=1482369006]
custom_minimum_size = Vector2(40, 160)
layout_mode = 0
offset_left = 88.0
offset_top = 18.0
offset_right = 128.0
offset_bottom = 178.0
color = Color(0.101960786, 0.3529412, 0.101960786, 1)
[node name="SweepLine" type="ColorRect" parent="PanelMargin/PanelColumn/Screen" unique_id=6530953]
custom_minimum_size = Vector2(4, 160)
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
color = Color(1, 0, 0, 1)
[node name="AIFace" type="Label" parent="PanelMargin/PanelColumn/Screen" unique_id=975263237]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
theme_override_font_sizes/font_size = 32
text = ">:)"
[node name="CloseButton" type="Button" parent="PanelMargin/PanelColumn" unique_id=554485629]
custom_minimum_size = Vector2(0, 60)
layout_mode = 2
theme_override_font_sizes/font_size = 28
text = "CLOSE"

14
scenes/game.tscn Normal file
View file

@ -0,0 +1,14 @@
[gd_scene format=3 uid="uid://b4llhxe3hjbgv"]
[ext_resource type="PackedScene" uid="uid://bnv1xxgceqbrc" path="res://scenes/world.tscn" id="1_uwrxv"]
[ext_resource type="PackedScene" uid="uid://cbvi51vvpt7mu" path="res://scenes/hud.tscn" id="2_yqjtg"]
[node name="Game" type="Node3D" unique_id=1456297160]
[node name="World" parent="." unique_id=831374579 instance=ExtResource("1_uwrxv")]
[node name="CanvasHud" type="CanvasLayer" parent="." unique_id=369977201]
[node name="HUD" parent="CanvasHud" unique_id=769131693 instance=ExtResource("2_yqjtg")]
[node name="CanvasPanel" type="CanvasLayer" parent="." unique_id=667193210]

41
scenes/hud.gd Normal file
View file

@ -0,0 +1,41 @@
extends MarginContainer
# I HAVE NO IDEA WHAT I'M DOIN!!!
var current_floor := 10
var saved_count := 0
var doors_closing := false
func _ready():
#$ElevatorPanel/PanelMargin/PanelColumn/CloseButton.pressed.connect(_on_close_pressed)
# 10 floors is probably a lot but will make testing easier.
$StatsColumn/FloorLabel.text = "FLOOR: 10"
func _unhandled_input(event):
if event is InputEventKey and event.pressed and event.keycode == KEY_SPACE:
_on_close_pressed()
func _on_close_pressed():
# don't let 'em spam the button
if doors_closing:
return
var screen = $ElevatorPanel/PanelMargin/PanelColumn/Screen
var success = screen.attempt_hack()
if success:
doors_closing = true
saved_count += 1
current_floor -= 1
$StatsMargin/StatsColumn/SavedLabel.text = "SAVED: " + str(saved_count)
$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: " + str(current_floor)
if current_floor <= 1:
screen.show_win()
else:
screen.show_countdown()
var tween = create_tween()
tween.tween_callback(func():
screen.reset_hack()
doors_closing = false
).set_delay(2.0)
else:
print("MISSED! AI is faster now!")

1
scenes/hud.gd.uid Normal file
View file

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

28
scenes/hud.tscn Normal file
View file

@ -0,0 +1,28 @@
[gd_scene format=3 uid="uid://cbvi51vvpt7mu"]
[ext_resource type="Script" uid="uid://fpaw3u5yjtbk" path="res://scenes/hud.gd" id="1_64ctp"]
[node name="HUD" type="MarginContainer" unique_id=769131693]
offset_right = 40.0
offset_bottom = 40.0
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
script = ExtResource("1_64ctp")
[node name="StatsColumn" type="VBoxContainer" parent="." unique_id=1476756270]
layout_mode = 2
[node name="PeopleLabel" type="Label" parent="StatsColumn" unique_id=1174457387]
layout_mode = 2
theme_override_font_sizes/font_size = 24
text = "PEOPLE: 0"
[node name="SavedLabel" type="Label" parent="StatsColumn" unique_id=969002022]
layout_mode = 2
theme_override_font_sizes/font_size = 24
text = "SAVED: 0"
[node name="FloorLabel" type="Label" parent="StatsColumn" unique_id=67147411]
layout_mode = 2
theme_override_font_sizes/font_size = 24
text = "FLOOR: 0"

96
scenes/hud_old.tscn Normal file
View file

@ -0,0 +1,96 @@
[gd_scene format=3 uid="uid://d4j36ro8y55ep"]
[ext_resource type="Script" uid="uid://kltqwef8yx3r" path="res://scenes/screen.gd" id="1_37p78"]
[ext_resource type="Script" uid="uid://k1n4iyxp4iww" path="res://scenes/elevator_panel.gd" id="1_64ctp"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2snw"]
bg_color = Color(0.039215688, 0.16470589, 0.039215688, 1)
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
[node name="StatsMargin" type="MarginContainer" unique_id=428486326]
offset_right = 40.0
offset_bottom = 40.0
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
[node name="StatsColumn" type="VBoxContainer" parent="." unique_id=365054136]
layout_mode = 2
[node name="PeopleLabel" type="Label" parent="StatsColumn" unique_id=203661849]
layout_mode = 2
theme_override_font_sizes/font_size = 24
text = "PEOPLE: 0"
[node name="SavedLabel" type="Label" parent="StatsColumn" unique_id=830917509]
layout_mode = 2
theme_override_font_sizes/font_size = 24
text = "SAVED: 0"
[node name="FloorLabel" type="Label" parent="StatsColumn" unique_id=320822205]
layout_mode = 2
theme_override_font_sizes/font_size = 24
text = "FLOOR: 0"
[node name="HUD" type="Control" parent="." unique_id=1519812318]
layout_mode = 2
script = ExtResource("1_64ctp")
[node name="ElevatorPanel" type="PanelContainer" parent="HUD" unique_id=528786554]
custom_minimum_size = Vector2(250, 0)
layout_mode = 1
anchors_preset = 11
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -8.0
grow_horizontal = 0
grow_vertical = 2
[node name="PanelMargin" type="MarginContainer" parent="HUD/ElevatorPanel" unique_id=277992523]
layout_mode = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="PanelColumn" type="VBoxContainer" parent="HUD/ElevatorPanel/PanelMargin" unique_id=617812367]
layout_mode = 2
[node name="Screen" type="Panel" parent="HUD/ElevatorPanel/PanelMargin/PanelColumn" unique_id=1525784323]
custom_minimum_size = Vector2(200, 200)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_n2snw")
script = ExtResource("1_37p78")
[node name="TargetZone" type="ColorRect" parent="HUD/ElevatorPanel/PanelMargin/PanelColumn/Screen" unique_id=1945539908]
custom_minimum_size = Vector2(40, 160)
layout_mode = 0
offset_left = 88.0
offset_top = 18.0
offset_right = 128.0
offset_bottom = 178.0
color = Color(0.101960786, 0.3529412, 0.101960786, 1)
[node name="SweepLine" type="ColorRect" parent="HUD/ElevatorPanel/PanelMargin/PanelColumn/Screen" unique_id=1798423613]
custom_minimum_size = Vector2(4, 160)
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
color = Color(1, 0, 0, 1)
[node name="AIFace" type="Label" parent="HUD/ElevatorPanel/PanelMargin/PanelColumn/Screen" unique_id=1410806030]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
theme_override_font_sizes/font_size = 32
text = ">:)"
[node name="CloseButton" type="Button" parent="HUD/ElevatorPanel/PanelMargin/PanelColumn" unique_id=427545014]
custom_minimum_size = Vector2(0, 60)
layout_mode = 2
theme_override_font_sizes/font_size = 28
text = "CLOSE"

99
scenes/screen.gd Normal file
View file

@ -0,0 +1,99 @@
extends Panel
var sweep_speed := 150.0
var sweep_direction := 1
var sweep_x := 0.0
var is_hacked := true
var style_box: StyleBoxFlat
var base_color: Color
var target_shrink := 4.0
var target_min_width := 8.0
signal hack_defeated
signal hack_failed
func _ready():
style_box = get_theme_stylebox("panel").duplicate()
add_theme_stylebox_override("panel", style_box)
base_color = style_box.bg_color
var tz = $TargetZone
tz.position = Vector2((size.x - tz.size.x) / 2, 20)
tz.size = Vector2(40, size.y - 40)
var sl = $SweepLine
sl.position = Vector2(0, 20)
sl.size = Vector2(4, size.y - 40)
sweep_x = 0.0
var face = $AIFace
face.position = Vector2(0, 0)
face.size = Vector2(size.x, 30)
face.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
func _process(delta):
if not is_hacked:
return
sweep_x += sweep_speed * sweep_direction * delta
if sweep_x >= size.x:
sweep_direction = -1
elif sweep_x <= 0:
sweep_direction = 1
$SweepLine.position.x = sweep_x
func flash(color: Color):
style_box.bg_color = color
var tween = create_tween()
tween.tween_property(style_box, "bg_color", base_color, 0.3)
func reset_hack():
is_hacked = true
sweep_x = 0.0
sweep_direction = 1
$SweepLine.visible = true
$SweepLine.position.x = 0
$AIFace.text = ">:)"
var tz = $TargetZone
tz.size.x = max(tz.size.x - target_shrink, target_min_width)
tz.position.x = (size.x - tz.size.x) / 2
# messtastic
func show_countdown():
var tween = create_tween()
$AIFace.text = "3"
tween.tween_callback(func(): $AIFace.text = "2").set_delay(0.6)
tween.tween_callback(func(): $AIFace.text = "1").set_delay(0.6)
tween.tween_callback(func(): $AIFace.text = "CLOSED").set_delay(0.6)
func show_win():
is_hacked = false
$SweepLine.visible = false
$TargetZone.visible = false
$AIFace.text = "ESCAPED"
flash(Color.GREEN)
# target zones
func attempt_hack() -> bool:
var tz = $TargetZone
var tz_left = tz.position.x
var tz_right = tz.position.x + tz.size.x
if sweep_x >= tz_left and sweep_x <= tz_right:
is_hacked = false
$AIFace.text = ">:("
$SweepLine.visible = false
flash(Color.GREEN)
hack_defeated.emit()
return true
else:
sweep_speed += 20.0
$AIFace.text = ":D"
flash(Color.RED)
hack_failed.emit()
return false

1
scenes/screen.gd.uid Normal file
View file

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

View file

@ -1,4 +1,13 @@
extends Area3D
extends CharacterBody3D
var speed: int = 100
var clumsiness: int = 0
var speed: int = 10
var clumsiness: int = 0
func start(xform):
transform = xform
velocity = (-xform.basis.z * speed).rotated(Vector3.UP, randf_range(-PI/4, PI/4))
func _physics_process(delta):
velocity.z -= 10 * delta
move_and_slide()