main menu progress

This commit is contained in:
vandomej 2025-10-05 21:39:27 -07:00
parent 926b4f192f
commit 6cd6db088b
8 changed files with 117 additions and 16 deletions

43
main_menu.gd Normal file
View file

@ -0,0 +1,43 @@
extends Node
@onready var menu_text = $Title
@onready var control_ui = $Vignette
@onready var root = self
signal main_menu_interacted
var input_received = false
func _input(event):
if input_received:
return
if event is InputEventKey or event is InputEventMouseButton:
input_received = true
control_ui.visible = false
replace_with_falling_body(menu_text)
emit_signal("main_menu_interacted")
func replace_with_falling_body(node: Node2D):
var global_pos = node.global_position
var body := RigidBody2D.new()
body.gravity_scale = 1
body.position = global_pos
body.global_position = global_pos
var shape := CollisionShape2D.new()
var rect_shape := RectangleShape2D.new()
rect_shape.extents = Vector2(20, 20)
shape.shape = rect_shape
body.add_child(shape)
var parent = node.get_parent()
parent.remove_child(node)
body.add_child(node)
node.position = Vector2.ZERO
root.add_child(body)
var x_force = randf_range(-300.0, 300.0)
var y_force = randf_range(400.0, -100.0)
body.apply_impulse(Vector2(x_force, y_force))

1
main_menu.gd.uid Normal file
View file

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

View file

@ -1,8 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://q1x5v4q6uxsj"] [gd_scene load_steps=6 format=3 uid="uid://q1x5v4q6uxsj"]
[ext_resource type="Texture2D" uid="uid://dsfng5b065eyp" path="res://assets/background/full_bg_example.png" id="1_06t4h"] [ext_resource type="Texture2D" uid="uid://dsfng5b065eyp" path="res://assets/background/full_bg_example.png" id="1_06t4h"]
[ext_resource type="Script" uid="uid://bhpge7t5uk4gv" path="res://main_menu.gd" id="1_glbon"]
[ext_resource type="Theme" uid="uid://d2rlcffg7nguy" path="res://menus.tres" id="2_jix8l"] [ext_resource type="Theme" uid="uid://d2rlcffg7nguy" path="res://menus.tres" id="2_jix8l"]
[ext_resource type="Texture2D" uid="uid://cyheahpjvgaec" path="res://assets/menus/main/main.png" id="3_glbon"] [ext_resource type="Texture2D" uid="uid://cyheahpjvgaec" path="res://assets/menus/main/main.png" id="3_glbon"]
[ext_resource type="AudioStream" uid="uid://dx1yvtemmpktm" path="res://mainmenu.ogg" id="4_jix8l"]
[node name="MainMenu" type="Control"] [node name="MainMenu" type="Control"]
layout_mode = 3 layout_mode = 3
@ -11,6 +13,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_glbon")
[node name="Background" type="Sprite2D" parent="."] [node name="Background" type="Sprite2D" parent="."]
position = Vector2(640, 360) position = Vector2(640, 360)
@ -41,17 +44,12 @@ grow_vertical = 2
theme = ExtResource("2_jix8l") theme = ExtResource("2_jix8l")
text = "Press any key to start" text = "Press any key to start"
[node name="Title" type="TextureRect" parent="."] [node name="Title" type="Sprite2D" parent="."]
layout_mode = 1 position = Vector2(635, 400)
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -450.0
offset_top = -145.0
offset_right = 450.0
offset_bottom = 145.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("3_glbon") texture = ExtResource("3_glbon")
[node name="MenuMusic" type="AudioStreamPlayer" parent="."]
unique_name_in_owner = true
stream = ExtResource("4_jix8l")
volume_db = -14.0
autoplay = true

BIN
mainmenu.ogg Normal file

Binary file not shown.

19
mainmenu.ogg.import Normal file
View file

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dx1yvtemmpktm"
path="res://.godot/imported/mainmenu.ogg-aa713911500d6936271f6784f44af7da.oggvorbisstr"
[deps]
source_file="res://mainmenu.ogg"
dest_files=["res://.godot/imported/mainmenu.ogg-aa713911500d6936271f6784f44af7da.oggvorbisstr"]
[params]
loop=true
loop_offset=0.0
bpm=0.0
beat_count=0
bar_beats=4

View file

@ -11,7 +11,7 @@ config_version=5
[application] [application]
config/name="ld58" config/name="ld58"
run/main_scene="uid://dt4nq0nkmjiit" run/main_scene="uid://q1x5v4q6uxsj"
config/features=PackedStringArray("4.5", "Forward Plus") config/features=PackedStringArray("4.5", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
@ -19,6 +19,10 @@ config/icon="res://icon.svg"
general/text_to_speech=true general/text_to_speech=true
[autoload]
World="*res://world.gd"
[display] [display]
window/size/viewport_width=1280 window/size/viewport_width=1280

35
world.gd Normal file
View file

@ -0,0 +1,35 @@
extends Node3D
enum GameState { MAIN_MENU, GAME, LOSS, SUCCESS }
var current_game_state: GameState = GameState.MAIN_MENU
var manager
func _ready():
$MainMenu.main_menu_interacted.connect(_on_main_menu_interacted)
func transition():
if current_game_state == GameState.MAIN_MENU:
current_game_state = GameState.GAME
%MenuMusic.stop()
%BackGroundMusic.play()
elif current_game_state == GameState.GAME:
current_game_state = GameState.LOSS
manager.queue_free()
%BackGroundMusic.stop()
%TheEndSound.play()
$ScrollingBackgroundEngine.end_it()
elif current_game_state == GameState.LOSS:
current_game_state = GameState.GAME
%MenuMusic.stop()
%BackGroundMusic.play()
func _on_main_menu_interacted():
transition()
add_child(manager)
manager.failed.connect(_on_loss)
func _on_loss():
transition()
func _reload_self():
get_tree().reload_current_scene()

1
world.gd.uid Normal file
View file

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