many small changes, and few big ones

This commit is contained in:
ChaoticByte 2024-10-16 20:23:53 +02:00
parent e8985f4e79
commit a3ca623258
No known key found for this signature in database
32 changed files with 391 additions and 247 deletions

5
main/menu/menu.gd Normal file
View file

@ -0,0 +1,5 @@
extends Node2D
func _physics_process(_delta: float) -> void:
if NodeRegistry.player.position.y > 1000:
LevelsCore.call_deferred("load_menu")

63
main/menu/menu.tscn Normal file
View file

@ -0,0 +1,63 @@
[gd_scene load_steps=4 format=3 uid="uid://bqmpoix37kutp"]
[ext_resource type="Script" path="res://main/menu/menu.gd" id="1_g2w4y"]
[ext_resource type="Script" path="res://core/polygon/polygon.gd" id="2_tdbfk"]
[ext_resource type="PackedScene" uid="uid://c40fli7qcma78" path="res://main/menu/slot/slot.tscn" id="3_rc4dm"]
[node name="Menu" type="Node2D"]
position = Vector2(0, -1)
script = ExtResource("1_g2w4y")
[node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="P" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(768, 1345, 768, 193, -272, 193, -272, 601, -304, 601, -304, 1345)
script = ExtResource("2_tdbfk")
[node name="P2" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-152, 41, 152, 41, 152, 57, -152, 57)
script = ExtResource("2_tdbfk")
[node name="SaveGameSlots" type="Node2D" parent="."]
position = Vector2(-448, 177)
[node name="Saves" type="Label" parent="SaveGameSlots" groups=["text_viewport"]]
offset_left = -192.0
offset_top = -176.0
offset_right = 80.0
offset_bottom = -112.0
theme_override_font_sizes/font_size = 32
text = "saves"
horizontal_alignment = 1
vertical_alignment = 2
[node name="Slot0" parent="SaveGameSlots" instance=ExtResource("3_rc4dm")]
slot_label = "0"
[node name="Slot1" parent="SaveGameSlots" instance=ExtResource("3_rc4dm")]
position = Vector2(0, 128)
slot_idx = 1
slot_label = "1"
[node name="Slot2" parent="SaveGameSlots" instance=ExtResource("3_rc4dm")]
position = Vector2(0, 256)
slot_idx = 2
slot_label = "2"
[node name="Slot3" parent="SaveGameSlots" instance=ExtResource("3_rc4dm")]
position = Vector2(0, 384)
slot_idx = 3
slot_label = "3"
[node name="Label" type="Label" parent="." groups=["text_viewport"]]
offset_left = -192.0
offset_top = -15.0
offset_right = 192.0
offset_bottom = 65.0
theme_override_font_sizes/font_size = 52
text = "rectangular"
horizontal_alignment = 1
vertical_alignment = 2
[node name="Marker2D" type="Marker2D" parent="."]
position = Vector2(0, 129)

31
main/menu/slot/slot.gd Normal file
View file

@ -0,0 +1,31 @@
extends Node2D
const COLOR_NORMAL = Color.DARK_SLATE_GRAY
const COLOR_USED = Color.WHITE
@export var slot_idx: int
@export var slot_label: String = ""
func update_color():
if Gamestate.is_slot_used(slot_idx):
$Platform/P.color = COLOR_USED
else:
$Platform/P.color = COLOR_NORMAL
func _ready() -> void:
$Label.text = str(slot_label)
update_color()
func _on_area_2d_load_body_entered(body: Node2D) -> void:
# load slot & start game
if body == NodeRegistry.player:
Gamestate.current_slot = slot_idx
Gamestate.load_slot()
LevelsCore.load_entrypoint(Gamestate.last_entrypoint)
func _on_area_2d_delete_body_entered(body: Node2D) -> void:
# reset slot on disk
if body == NodeRegistry.player:
Gamestate.reset_slot(slot_idx)
update_color()
NodeRegistry.player.position = self.global_position - Vector2(0, 32)

40
main/menu/slot/slot.tscn Normal file
View file

@ -0,0 +1,40 @@
[gd_scene load_steps=3 format=3 uid="uid://c40fli7qcma78"]
[ext_resource type="Script" path="res://main/menu/slot/slot.gd" id="1_3dgi0"]
[ext_resource type="Script" path="res://core/polygon/polygon.gd" id="3_3d6ht"]
[node name="Slot" type="Node2D"]
script = ExtResource("1_3dgi0")
[node name="Platform" type="StaticBody2D" parent="."]
[node name="P" type="CollisionPolygon2D" parent="Platform"]
polygon = PackedVector2Array(40, 16, -152, 16, -152, 48, -176, 48, -176, 16, -192, 16, -192, 56, 80, 56, 80, 16, 64, 16, 64, 48, 40, 48)
script = ExtResource("3_3d6ht")
[node name="Area2D_Load" type="Area2D" parent="."]
collision_layer = 255
collision_mask = 255
[node name="P" type="CollisionPolygon2D" parent="Area2D_Load"]
polygon = PackedVector2Array(40, 48, 64, 48, 64, 24, 40, 24)
script = ExtResource("3_3d6ht")
color = Color(0.301961, 1, 0, 1)
[node name="Area2D_Delete" type="Area2D" parent="."]
[node name="P" type="CollisionPolygon2D" parent="Area2D_Delete"]
polygon = PackedVector2Array(-176, 48, -152, 48, -152, 24, -176, 24)
script = ExtResource("3_3d6ht")
color = Color(1, 0, 0, 1)
[node name="Label" type="Label" parent="." groups=["text_viewport"]]
offset_left = -192.0
offset_top = -32.0
offset_right = 80.0
text = "_"
horizontal_alignment = 1
vertical_alignment = 1
[connection signal="body_entered" from="Area2D_Load" to="." method="_on_area_2d_load_body_entered"]
[connection signal="body_entered" from="Area2D_Delete" to="." method="_on_area_2d_delete_body_entered"]