Lot of cleanup
Reorganize project structure into scenes and scripts directories
- Move core game objects (player, enemy, projectile, cassette, phonebooth) to scenes/core/
- Move UI helpers (title, pause_screen, game_over, speech) to scenes/helpers/
- Move puzzle logic (phonephreak) to scenes/puzzles/
- Move global utilities to scripts/
- Consolidate levels in scenes/levels/ with new base_level structure
- Fix naming conventions (snake_case for scripts)
- Remove obsolete test and duplicate scenes
This commit is contained in:
1 parent
6c6bc2a21a
commit
de90af743c
51 files changed
+273
-752
No files matched your search
@@ -0,0 +1,21 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
GlobalData.death_counter = 3
|
||||
$".".queue_free()
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
|
||||
func _on_button_2_pressed() -> void:
|
||||
get_tree().quit()
|
||||
@@ -0,0 +1 @@
|
||||
uid://qtq5kw1cwxo3
|
||||
@@ -0,0 +1,49 @@
|
||||
[gd_scene format=3 uid="uid://dvujc88306mxp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://qtq5kw1cwxo3" path="res://scenes/helpers/game_over.gd" id="1_tbwuq"]
|
||||
[ext_resource type="FontFile" uid="uid://ddm6ojsaiq20b" path="res://assets/fonts/PixelOperator8-Bold.ttf" id="1_wqhvx"]
|
||||
[ext_resource type="FontFile" uid="uid://dkytywan8eapf" path="res://assets/fonts/PixelOperator8.ttf" id="2_tbwuq"]
|
||||
|
||||
[node name="game_over" type="Node2D" unique_id=1847116366]
|
||||
script = ExtResource("1_tbwuq")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=995002747]
|
||||
z_index = 12
|
||||
offset_left = -1264.0
|
||||
offset_top = -635.0
|
||||
offset_right = 1107.0
|
||||
offset_bottom = 534.0
|
||||
color = Color(14.806348, 0, 0, 0.34509805)
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=677546612]
|
||||
z_index = 13
|
||||
offset_left = -856.0
|
||||
offset_top = -334.0
|
||||
offset_right = 1019.0
|
||||
offset_bottom = -134.0
|
||||
theme_override_fonts/font = ExtResource("1_wqhvx")
|
||||
theme_override_font_sizes/font_size = 200
|
||||
text = "GAME OVER!"
|
||||
|
||||
[node name="Button" type="Button" parent="." unique_id=81464495]
|
||||
z_index = 13
|
||||
offset_left = -288.0
|
||||
offset_top = 28.0
|
||||
offset_right = 358.0
|
||||
offset_bottom = 137.0
|
||||
theme_override_fonts/font = ExtResource("2_tbwuq")
|
||||
theme_override_font_sizes/font_size = 100
|
||||
text = "Respawn"
|
||||
|
||||
[node name="Button2" type="Button" parent="." unique_id=1126403836]
|
||||
z_index = 13
|
||||
offset_left = -279.0
|
||||
offset_top = 205.0
|
||||
offset_right = 367.0
|
||||
offset_bottom = 314.0
|
||||
theme_override_fonts/font = ExtResource("2_tbwuq")
|
||||
theme_override_font_sizes/font_size = 100
|
||||
text = "Quit"
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]
|
||||
@@ -0,0 +1,19 @@
|
||||
extends CanvasLayer
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if !get_tree().paused or Input.is_action_just_pressed("pause"):
|
||||
queue_free()
|
||||
get_tree().paused = false
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
get_tree().paused = false
|
||||
queue_free()
|
||||
|
||||
func _on_button_2_pressed() -> void:
|
||||
get_tree().quit()
|
||||
@@ -0,0 +1 @@
|
||||
uid://duogtg7hc30a6
|
||||
@@ -0,0 +1,43 @@
|
||||
[gd_scene format=3 uid="uid://0qbm646wkcl2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://duogtg7hc30a6" path="res://scenes/helpers/pause_screen.gd" id="1_ugr0d"]
|
||||
[ext_resource type="FontFile" uid="uid://dkytywan8eapf" path="res://assets/fonts/PixelOperator8.ttf" id="2_m8jjm"]
|
||||
|
||||
[node name="pause_screen" type="CanvasLayer" unique_id=2146455338 groups=["pause_scene"]]
|
||||
process_mode = 2
|
||||
script = ExtResource("1_ugr0d")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=1229507916]
|
||||
offset_right = 2000.0
|
||||
offset_bottom = 1000.0
|
||||
color = Color(0, 0.7254902, 0, 0.28235295)
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=220159306]
|
||||
offset_left = 451.0
|
||||
offset_top = 236.0
|
||||
offset_right = 1501.0
|
||||
offset_bottom = 436.0
|
||||
theme_override_fonts/font = ExtResource("2_m8jjm")
|
||||
theme_override_font_sizes/font_size = 200
|
||||
text = "Paused"
|
||||
|
||||
[node name="Button" type="Button" parent="." unique_id=1467636182]
|
||||
offset_left = 701.0
|
||||
offset_top = 517.0
|
||||
offset_right = 1259.0
|
||||
offset_bottom = 626.0
|
||||
theme_override_fonts/font = ExtResource("2_m8jjm")
|
||||
theme_override_font_sizes/font_size = 100
|
||||
text = "resume"
|
||||
|
||||
[node name="Button2" type="Button" parent="." unique_id=814575465]
|
||||
offset_left = 713.0
|
||||
offset_top = 694.0
|
||||
offset_right = 1271.0
|
||||
offset_bottom = 803.0
|
||||
theme_override_fonts/font = ExtResource("2_m8jjm")
|
||||
theme_override_font_sizes/font_size = 100
|
||||
text = "quit"
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]
|
||||
@@ -0,0 +1,192 @@
|
||||
class_name SpeechBubbles
|
||||
extends CanvasLayer
|
||||
|
||||
signal bubble_dismissed(bubble: Bubble)
|
||||
|
||||
@export var max_width := 160.0 # max text width in px (excludes padding)
|
||||
@export var chars_per_sec := 0.0 # 0 = show text instantly
|
||||
@export var tail_size := Vector2(10, 8) # width, height
|
||||
@export var pad := 6
|
||||
@export var corner := 6
|
||||
@export var screen_margin := 4.0
|
||||
@export var fade_time := 0.12
|
||||
@export var bg_color := Color.WHITE
|
||||
@export var text_color := Color(0.1, 0.1, 0.15)
|
||||
|
||||
var _bubbles: Array[Bubble] = []
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────
|
||||
|
||||
## Show a bubble over `who`. duration 0 = stay until dismissed.
|
||||
## Replaces any bubble already on `who`. Returns the bubble handle.
|
||||
## Wait for it with: await speech.say(...).dismissed
|
||||
func say(text: String, who: Node2D, duration := 0.0) -> Bubble:
|
||||
var old := get_bubble(who)
|
||||
if old:
|
||||
old.dismiss(true)
|
||||
var b := Bubble.new()
|
||||
b.cfg = self
|
||||
b.target = who
|
||||
b.duration = duration
|
||||
b.dismissed.connect(_on_dismissed.bind(b))
|
||||
_bubbles.append(b)
|
||||
add_child(b)
|
||||
b.start(text)
|
||||
return b
|
||||
|
||||
## Dismiss one speaker's bubble, or all bubbles if `who` is null.
|
||||
func dismiss(who: Node2D = null, instant := false) -> void:
|
||||
for b in _bubbles.duplicate():
|
||||
if who == null or b.target == who:
|
||||
b.dismiss(instant)
|
||||
|
||||
func get_bubble(who: Node2D) -> Bubble:
|
||||
for b in _bubbles:
|
||||
if b.target == who:
|
||||
return b
|
||||
return null
|
||||
|
||||
## True if `who` has a bubble, or if any bubble exists when `who` is null.
|
||||
func is_speaking(who: Node2D = null) -> bool:
|
||||
return not _bubbles.is_empty() if who == null else get_bubble(who) != null
|
||||
|
||||
func _on_dismissed(b: Bubble) -> void:
|
||||
_bubbles.erase(b)
|
||||
bubble_dismissed.emit(b)
|
||||
|
||||
# ── One bubble ────────────────────────────────────────────────
|
||||
class Bubble extends RichTextLabel:
|
||||
signal shown # laid out and visible
|
||||
signal dismissed # fade-out starts (or instant removal)
|
||||
|
||||
var cfg: SpeechBubbles
|
||||
var target: Node2D
|
||||
var duration := 0.0
|
||||
var is_shown := false
|
||||
var _dead := false
|
||||
var _below := false
|
||||
var _tail_x := 0.0
|
||||
var _tween: Tween
|
||||
|
||||
func _ready() -> void:
|
||||
bbcode_enabled = true
|
||||
fit_content = false # we size the box ourselves
|
||||
scroll_active = false
|
||||
clip_contents = false # keeps the tail and shadow from being clipped
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
add_theme_color_override("default_color", cfg.text_color)
|
||||
var sb := StyleBoxFlat.new()
|
||||
sb.bg_color = cfg.bg_color
|
||||
sb.set_corner_radius_all(cfg.corner)
|
||||
sb.set_content_margin_all(cfg.pad)
|
||||
sb.shadow_color = Color(0, 0, 0, 0.25)
|
||||
sb.shadow_size = 3
|
||||
sb.shadow_offset = Vector2(0, 2)
|
||||
add_theme_stylebox_override("normal", sb)
|
||||
modulate.a = 0.0
|
||||
set_process(false)
|
||||
|
||||
func start(t: String) -> void:
|
||||
var pad2 := cfg.pad * 2.0
|
||||
autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
custom_minimum_size = Vector2.ZERO
|
||||
size = Vector2(cfg.max_width + pad2, 100) # sane width while the text is parsed
|
||||
text = t
|
||||
await get_tree().process_frame
|
||||
if _dead:
|
||||
return
|
||||
|
||||
var font := get_theme_font("normal_font")
|
||||
var fs := get_theme_font_size("normal_font_size")
|
||||
var plain := get_parsed_text()
|
||||
|
||||
# Width: natural text width, capped
|
||||
var natural := font.get_string_size(plain, HORIZONTAL_ALIGNMENT_LEFT, -1, fs).x
|
||||
var text_w := minf(natural + 2.0, cfg.max_width)
|
||||
|
||||
# Height: measured at the final wrap width
|
||||
var text_h := font.get_multiline_string_size(
|
||||
plain, HORIZONTAL_ALIGNMENT_LEFT, text_w, fs).y
|
||||
|
||||
autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
size = Vector2(text_w + pad2, ceilf(text_h) + pad2)
|
||||
|
||||
is_shown = true
|
||||
_place()
|
||||
set_process(true)
|
||||
|
||||
# Pop-in
|
||||
scale = Vector2(0.6, 0.6)
|
||||
var t_in := create_tween().set_parallel()
|
||||
t_in.tween_property(self, "scale", Vector2.ONE, 0.2).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
|
||||
t_in.tween_property(self, "modulate:a", 1.0, 0.1)
|
||||
|
||||
# Typewriter (optional)
|
||||
var type_time := 0.0
|
||||
if cfg.chars_per_sec > 0.0:
|
||||
type_time = get_total_character_count() / cfg.chars_per_sec
|
||||
visible_ratio = 0.0
|
||||
_tween = create_tween()
|
||||
_tween.tween_property(self, "visible_ratio", 1.0, type_time)
|
||||
shown.emit()
|
||||
|
||||
# Auto-dismiss: duration counts after typing finishes
|
||||
if duration > 0.0:
|
||||
await get_tree().create_timer(type_time + duration).timeout
|
||||
if not _dead:
|
||||
dismiss()
|
||||
|
||||
## Finish typing instantly.
|
||||
func complete() -> void:
|
||||
if _tween:
|
||||
_tween.kill()
|
||||
visible_ratio = 1.0
|
||||
|
||||
func dismiss(instant := false) -> void:
|
||||
if _dead:
|
||||
return
|
||||
_dead = true
|
||||
set_process(false)
|
||||
if _tween:
|
||||
_tween.kill()
|
||||
dismissed.emit()
|
||||
if instant or not is_shown:
|
||||
queue_free()
|
||||
return
|
||||
var t := create_tween().set_parallel()
|
||||
t.tween_property(self, "modulate:a", 0.0, cfg.fade_time)
|
||||
t.tween_property(self, "scale", Vector2(0.8, 0.8), cfg.fade_time)
|
||||
t.finished.connect(queue_free)
|
||||
|
||||
func _process(_dt: float) -> void:
|
||||
if not is_instance_valid(target): # speaker was freed
|
||||
dismiss(true)
|
||||
return
|
||||
_place()
|
||||
|
||||
func _place() -> void:
|
||||
var vp := get_viewport().get_visible_rect().size
|
||||
var a := target.get_global_transform_with_canvas().origin
|
||||
var m := cfg.screen_margin
|
||||
var ts := cfg.tail_size
|
||||
_below = a.y - size.y - ts.y < m
|
||||
var x := clampf(a.x - size.x * 0.5, m, maxf(m, vp.x - size.x - m))
|
||||
var y := a.y + ts.y if _below else a.y - size.y - ts.y
|
||||
position = Vector2(x, y)
|
||||
var tx := clampf(a.x - x, cfg.corner + ts.x, size.x - cfg.corner - ts.x)
|
||||
if not is_equal_approx(tx, _tail_x):
|
||||
_tail_x = tx
|
||||
queue_redraw()
|
||||
pivot_offset = Vector2(_tail_x, 0.0 if _below else size.y + ts.y)
|
||||
|
||||
func _draw() -> void:
|
||||
if not is_shown:
|
||||
return
|
||||
var hw := cfg.tail_size.x * 0.5
|
||||
var y0 := 0.0 if _below else size.y
|
||||
var d := -1.0 if _below else 1.0
|
||||
# base starts 1px inside the box so there's no seam
|
||||
draw_colored_polygon(PackedVector2Array([
|
||||
Vector2(_tail_x - hw, y0 - d),
|
||||
Vector2(_tail_x + hw, y0 - d),
|
||||
Vector2(_tail_x, y0 + d * cfg.tail_size.y)]), cfg.bg_color)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bnlmy8hecbg5c
|
||||
@@ -0,0 +1,10 @@
|
||||
[gd_scene format=3 uid="uid://b6n7uq6bhkwo3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bnlmy8hecbg5c" path="res://scenes/helpers/speech.gd" id="1_j5wli"]
|
||||
|
||||
[node name="Speech" type="CanvasLayer" unique_id=747748325]
|
||||
script = ExtResource("1_j5wli")
|
||||
|
||||
[node name="SpeechBubble" type="RichTextLabel" parent="." unique_id=6915822]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
@@ -0,0 +1,15 @@
|
||||
extends Control
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/levels/level%s.tscn" % GlobalData.level)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dcbdrv8y15dtu
|
||||
@@ -0,0 +1,41 @@
|
||||
[gd_scene format=3 uid="uid://btktv5aqpafau"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://dkytywan8eapf" path="res://assets/fonts/PixelOperator8.ttf" id="1_4ignj"]
|
||||
[ext_resource type="Script" uid="uid://dcbdrv8y15dtu" path="res://scenes/helpers/title.gd" id="1_wosw1"]
|
||||
|
||||
[node name="Title" type="Control" unique_id=715100706]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_wosw1")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=1504521213]
|
||||
layout_mode = 0
|
||||
offset_right = 2013.0
|
||||
offset_bottom = 1007.0
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=1433094765]
|
||||
layout_mode = 0
|
||||
offset_left = 491.0
|
||||
offset_top = 83.0
|
||||
offset_right = 1397.0
|
||||
offset_bottom = 334.0
|
||||
theme_override_fonts/font = ExtResource("1_4ignj")
|
||||
theme_override_font_sizes/font_size = 250
|
||||
text = "title"
|
||||
|
||||
[node name="Button" type="Button" parent="." unique_id=963162220]
|
||||
layout_mode = 0
|
||||
offset_left = 556.0
|
||||
offset_top = 536.0
|
||||
offset_right = 1389.0
|
||||
offset_bottom = 744.0
|
||||
theme_override_fonts/font = ExtResource("1_4ignj")
|
||||
theme_override_font_sizes/font_size = 150
|
||||
text = "start"
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
Reference in new issue
Block a user