Main menu progress
This commit is contained in:
parent
3c725316b7
commit
5112a2b98a
5 changed files with 62 additions and 28 deletions
|
|
@ -137,7 +137,8 @@ texture_hover = ExtResource("16_d13ii")
|
|||
|
||||
[node name="CursorManager" parent="." instance=ExtResource("20_82xsv")]
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
[node name="BackgroundMusic" type="AudioStreamPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
stream = ExtResource("22_ryguw")
|
||||
volume_db = -14.0
|
||||
autoplay = true
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ config_version=5
|
|||
[application]
|
||||
|
||||
config/name="ld58"
|
||||
run/main_scene="uid://q1x5v4q6uxsj"
|
||||
run/main_scene="uid://bnb1i0y0fls7b"
|
||||
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
|
|
@ -19,10 +19,6 @@ config/icon="res://icon.svg"
|
|||
|
||||
general/text_to_speech=true
|
||||
|
||||
[autoload]
|
||||
|
||||
World="*res://world.gd"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1280
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://cabsfveh1oc6i" path="res://assets/menus/final score/morshu-happy-large.png" id="1_juxjb"]
|
||||
[ext_resource type="Texture2D" uid="uid://d24dlalqmr6r0" path="res://assets/menus/final score/morshu-anger-large.png" id="2_3r2db"]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
[node name="ScoreScreen" type="Node2D"]
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
|
|
|
|||
63
world.gd
63
world.gd
|
|
@ -1,35 +1,56 @@
|
|||
extends Node3D
|
||||
extends Control
|
||||
|
||||
enum GameState { MAIN_MENU, GAME, LOSS, SUCCESS }
|
||||
enum GameState { MAIN_MENU, GAME, LOSS, WIN }
|
||||
var current_game_state: GameState = GameState.MAIN_MENU
|
||||
var manager
|
||||
|
||||
var main_menu_scene = preload("res://main_menu.tscn")
|
||||
var game_scene = preload("res://main.tscn")
|
||||
var score_screen_scene = preload("res://score_screen.tscn")
|
||||
|
||||
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 transition(new_state: GameState):
|
||||
# Clean up current scene
|
||||
|
||||
if new_state == GameState.MAIN_MENU:
|
||||
var main_menu_instance = main_menu_scene.instantiate()
|
||||
add_child(main_menu_scene)
|
||||
elif new_state == GameState.GAME:
|
||||
var game_instance = game_scene.instantiate()
|
||||
add_child(game_instance)
|
||||
elif new_state == GameState.LOSS:
|
||||
var score_screen_instance = score_screen_scene.instantiate()
|
||||
add_child(score_screen_instance)
|
||||
score_screen_instance.win()
|
||||
elif new_state == GameState.WIN:
|
||||
pass
|
||||
|
||||
# Clean up old scene
|
||||
match (current_game_state):
|
||||
GameState.MAIN_MENU:
|
||||
var main_menu_instance = $MainMenu
|
||||
var main_menu_instance.destroy()
|
||||
GameState.GAME:
|
||||
var main_instance = $Main
|
||||
main_instance.destroy()
|
||||
GameState.LOSS:
|
||||
var score_screen_instance = $ScoreScreen
|
||||
score_screen_instance.destroy()
|
||||
GameState.WIN:
|
||||
var score_screen_instance = $ScoreScreen
|
||||
score_screen_instance.destroy()
|
||||
|
||||
current_game_state = new_state
|
||||
|
||||
func _on_main_menu_interacted():
|
||||
transition()
|
||||
transition(GameState.GAME)
|
||||
add_child(manager)
|
||||
manager.failed.connect(_on_loss)
|
||||
|
||||
func _on_loss():
|
||||
transition()
|
||||
transition(GameState.LOSS)
|
||||
|
||||
func _reload_self():
|
||||
get_tree().reload_current_scene()
|
||||
func _on_win():
|
||||
transition(GameState.WIN)
|
||||
|
|
|
|||
16
world.tscn
Normal file
16
world.tscn
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bnb1i0y0fls7b"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://q1x5v4q6uxsj" path="res://main_menu.tscn" id="1_f3sb7"]
|
||||
[ext_resource type="Script" uid="uid://btq5lp33qphwg" path="res://world.gd" id="1_fj7yv"]
|
||||
|
||||
[node name="World" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_fj7yv")
|
||||
|
||||
[node name="MainMenu" parent="." instance=ExtResource("1_f3sb7")]
|
||||
layout_mode = 1
|
||||
Loading…
Add table
Reference in a new issue