Added Main Menu

This commit is contained in:
Florian 2025-09-17 19:25:22 +02:00
parent b9e8da7a7c
commit accf24ea08
27 changed files with 205 additions and 15 deletions

13
building_generator.tscn Normal file
View file

@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://ceg7ahpj5x12g"]
[ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="1_cwnke"]
[node name="Building Generator" type="Node"]
script = ExtResource("1_cwnke")
initial_buildings = 10
[node name="Timer" type="Timer" parent="."]
wait_time = 2.5
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View file

@ -16,9 +16,12 @@ func _ready() -> void:
await get_tree().create_timer(0).timeout
if get_node_or_null("EnemyList") != null:
for enemy in $EnemyList.get_children():
var enemies = $EnemyList.get_children()
$EnemyList.reparent(get_tree().get_root().get_node("main"), false)
for enemy in enemies:
var oldpos = enemy.position;
enemy.reparent(get_tree().get_root().get_node("main"))
enemy.position = get_world_position(oldpos)
if(enemy.has_method("init_at_horizontal_distortion")):
enemy.init_at_horizontal_distortion(enemy.position.length() / grid.ground_radius)

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Ghost 1.png-43131954ed622829dc5453ddf6a96b4c.
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Ghost 2.png-67077adaa01a71a5c0b85fac254bdf8e.
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Ghost 3.png-18da238556f83c92715d2db31a14d159.
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Ghost 4.png-45ba6df3ef207a5eff72f5f0036139d6.
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Ghost 5.png-08f0125e59cfd0173a5d36d75efeae60.
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -11,9 +11,11 @@ var aggro_range = 900
var chase_range = 1400
func _ready() -> void:
player = get_tree().get_root().get_node("main/Player")
player = get_tree().get_root().get_node_or_null("main/Player")
func _physics_process(delta: float) -> void:
if !is_instance_valid(player):
return
var dist = (position - player.position).length()
if(dist > chase_range):

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://ddn025xnjngko"]
[gd_scene load_steps=6 format=3 uid="uid://ddn025xnjngko"]
[ext_resource type="Script" uid="uid://bkcip66at5sug" path="res://items/bow.gd" id="1_xppub"]
[ext_resource type="PackedScene" uid="uid://dfva4dhflxglr" path="res://items/arrow.tscn" id="2_0id2q"]
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_gllxn"]
[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="4_0id2q"]
[sub_resource type="CircleShape2D" id="CircleShape2D_gllxn"]
@ -13,6 +14,8 @@ script = ExtResource("1_xppub")
arrow_scene = ExtResource("2_0id2q")
sprite = ExtResource("2_gllxn")
[node name="EarthAligner" parent="." instance=ExtResource("4_0id2q")]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(3.1, 3.1)
shape = SubResource("CircleShape2D_gllxn")

View file

@ -1,8 +1,8 @@
class_name Item extends Area2D
@onready var player = get_tree().get_root().get_node("main/Player")
@onready var player = get_tree().get_root().get_node_or_null("main/Player")
func _physics_process(delta: float) -> void:
if(overlaps_body(player)):
func _physics_process(_delta: float) -> void:
if(is_instance_valid(player) and overlaps_body(player)):
if(self.has_method("collect") and collect()):
set_deferred("monitoring", false)
set_deferred("monitorable", false)
@ -14,3 +14,4 @@ func collect_animation():
func collect():
push_error("Please specify item collection behavior")
return false

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://ewe36lqcjojk"]
[gd_scene load_steps=5 format=3 uid="uid://ewe36lqcjojk"]
[ext_resource type="Script" uid="uid://bbwsc2a2hd0ow" path="res://items/updash.gd" id="1_ghbl6"]
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_ptc3l"]
[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="3_ktv3s"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ghbl6"]
@ -17,3 +18,5 @@ shape = SubResource("CircleShape2D_ghbl6")
modulate = Color(1, 0, 1, 1)
scale = Vector2(0.45, 0.45)
texture = ExtResource("1_ptc3l")
[node name="EarthAligner" parent="." instance=ExtResource("3_ktv3s")]

View file

@ -1,7 +1,6 @@
[gd_scene load_steps=9 format=3 uid="uid://cxo6bq26huau7"]
[gd_scene load_steps=8 format=3 uid="uid://cxo6bq26huau7"]
[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"]
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"]
[ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://world/earth.tscn" id="3_lquwl"]
[ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="4_1bvp3"]
[ext_resource type="PackedScene" uid="uid://73g8y37skebh" path="res://item_ui/item_ui.tscn" id="6_4c57u"]
@ -13,7 +12,6 @@
[node name="Earth" parent="." instance=ExtResource("3_lquwl")]
unique_name_in_owner = true
script = ExtResource("2_lquwl")
[node name="Player" parent="." instance=ExtResource("2_1bvp3")]
unique_name_in_owner = true

6
main_menu/main_menu.gd Normal file
View file

@ -0,0 +1,6 @@
extends Node
func _on_button_start_pressed() -> void:
get_tree().change_scene_to_file("res://main.tscn")

View file

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

73
main_menu/main_menu.tscn Normal file
View file

@ -0,0 +1,73 @@
[gd_scene load_steps=9 format=3 uid="uid://dpkr8yoobtej6"]
[ext_resource type="Script" uid="uid://bg4qx85we014d" path="res://main_menu/main_menu.gd" id="1_bws42"]
[ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://world/earth.tscn" id="1_oa53l"]
[ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="2_d3a7t"]
[ext_resource type="Theme" uid="uid://dwlus1hjwtch4" path="res://large_theme.tres" id="3_3shxk"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d3a7t"]
bg_color = Color(0, 0.7529412, 0, 1)
draw_center = false
corner_radius_top_left = 350
corner_radius_top_right = 350
corner_radius_bottom_right = 350
corner_radius_bottom_left = 350
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_3shxk"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_bws42"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_3f7m4"]
[node name="main" type="Node"]
script = ExtResource("1_bws42")
[node name="Earth" parent="." instance=ExtResource("1_oa53l")]
unique_name_in_owner = true
[node name="Camera2D" type="Camera2D" parent="."]
zoom = Vector2(0.12, 0.12)
[node name="Building Generator" type="Node" parent="."]
script = ExtResource("2_d3a7t")
initial_buildings = 250
initial_spawn_protection = false
[node name="Timer" type="Timer" parent="Building Generator"]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Control" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="PanelContainer" type="PanelContainer" parent="CanvasLayer/Control"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -350.0
offset_top = -350.0
offset_right = 350.0
offset_bottom = 350.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_3shxk")
theme_override_styles/panel = SubResource("StyleBoxFlat_d3a7t")
[node name="ButtonStart" type="Button" parent="CanvasLayer/Control/PanelContainer"]
layout_mode = 2
theme_type_variation = &"FlatButton"
theme_override_styles/pressed = SubResource("StyleBoxEmpty_3shxk")
theme_override_styles/hover = SubResource("StyleBoxEmpty_bws42")
theme_override_styles/focus = SubResource("StyleBoxEmpty_3f7m4")
text = "Play Again"
[connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"]
[connection signal="pressed" from="CanvasLayer/Control/PanelContainer/ButtonStart" to="." method="_on_button_start_pressed"]

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Heart Grey.png-6b86b8edc4802c3a483d9a14eb7ce1
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Heart.png-33902e9ff8206d83f93ea6d088b4a1bc.ct
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Heart_cut Grey.png-b4b9be15b5a8a36395d31eba43
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Heart_cut.png-f11ef12fc6c55a0077b5ba659ce17ad
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="The Dark Side of Earth"
run/main_scene="uid://cxo6bq26huau7"
run/main_scene="uid://dpkr8yoobtej6"
config/features=PackedStringArray("4.5", "Forward Plus")
config/icon="res://icon.svg"

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Background Prototype Layer 1.png-47bb54b6d20a
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Background Prototype Layer 2.png-ab86220f0fff
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Background Prototype Layer 3.png-5a49ea16a5dc
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Background Prototype Layer 4.png-ee5791549e67
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Background prototype.png-82410769bb8789c49aff
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View file

@ -1,7 +1,8 @@
extends Node
class_name BuildingGenerator extends Node
@onready var grid : Grid = %Earth.get_grid()
@export var initial_buildings : int;
@export var initial_spawn_protection = true
func random_oppostite_collumn() -> int:
var playerpos = %Player.position
@ -19,7 +20,7 @@ func random_collumn() -> int:
func _ready():
for i in range(initial_buildings):
var collumn = random_collumn()
if 43 <= collumn and collumn <= 49:
if initial_spawn_protection and 43 <= collumn and collumn <= 49:
continue
var building = randomize_building()
grid.add_building_to_collumn(building, collumn)

View file

@ -1,5 +1,6 @@
[gd_scene load_steps=6 format=3 uid="uid://jjoyj1ldafkf"]
[gd_scene load_steps=7 format=3 uid="uid://jjoyj1ldafkf"]
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="1_wxnww"]
[ext_resource type="Script" uid="uid://b5fhsy1xlreco" path="res://world/draw_circle.gd" id="2_2bhor"]
[ext_resource type="Script" uid="uid://m3vyyfk8gnma" path="res://world/grid.gd" id="3_2bhor"]
[ext_resource type="PackedScene" uid="uid://djawvtdwp423v" path="res://buildings/building.tscn" id="3_nihcy"]
@ -9,6 +10,7 @@
radius = 3000.0
[node name="Earth" type="Node2D"]
script = ExtResource("1_wxnww")
[node name="Ground" type="StaticBody2D" parent="."]