98 lines
2.4 KiB
GDScript
98 lines
2.4 KiB
GDScript
extends Node
|
|
|
|
|
|
const DESCRIPTIONS := [
|
|
# sweet mode
|
|
{
|
|
"enemies": "*slower enemies",
|
|
"lives": "*unlimited lives",
|
|
"description": "*Difficulty for\n beginners",
|
|
},
|
|
# salty mode
|
|
{
|
|
"enemies": "*normal enemies",
|
|
"lives": "*unlimited lives",
|
|
"description": "*Difficulty for\n skilled players",
|
|
},
|
|
# spicy mode
|
|
{
|
|
"enemies": "*normal enemies",
|
|
"lives": "*limited lives",
|
|
"description": "*Difficulty for\n retro players",
|
|
},
|
|
# pungent mode
|
|
{
|
|
"enemies": "*faster enemies",
|
|
"lives": "*limited lives",
|
|
"description": "*Difficulty for\n insane players",
|
|
},
|
|
]
|
|
|
|
var file: Save.SaveFile = null
|
|
var difficulty: int = Game.Difficulty.SPICY
|
|
|
|
onready var face: Sprite = $"%Face"
|
|
onready var chosen_name: Label = $"%ChosenName"
|
|
onready var enemies: Label = $"%Enemies"
|
|
onready var lives: Label = $"%Lives"
|
|
onready var description: Label = $"%Description"
|
|
|
|
|
|
func _ready() -> void:
|
|
# escape to file select if no file is assigned
|
|
if not file:
|
|
yield(get_tree(), "idle_frame")
|
|
SceneManager.current_scene = load("res://menus/file_select.tscn").instance()
|
|
return
|
|
|
|
# pause so that player can not move around until difficulty chosen
|
|
get_tree().paused = true
|
|
# initialize name
|
|
chosen_name.text = ""
|
|
file.name = ""
|
|
# fade in
|
|
Fade.fade_in(0.4)
|
|
# focus the difficulty
|
|
$"%Spicy".call_deferred("grab_focus")
|
|
|
|
|
|
func _set_difficulty(value: int) -> void:
|
|
difficulty = posmod(value, 4)
|
|
file.difficulty = difficulty
|
|
face.frame = difficulty
|
|
enemies.text = DESCRIPTIONS[difficulty].enemies
|
|
lives.text = DESCRIPTIONS[difficulty].lives
|
|
description.text = DESCRIPTIONS[difficulty].description
|
|
|
|
|
|
|
|
func _difficulty_selected() -> void:
|
|
Fade.fade_out(0.4)
|
|
yield(Fade, "fade_finished")
|
|
$"%DifficultySelect".queue_free()
|
|
$"%NameEntry".visible = true
|
|
get_tree().paused = false
|
|
Game.use_lives = false
|
|
Fade.fade_in(0.4)
|
|
|
|
func _on_letter_chosen(letter: String) -> void:
|
|
if file.name.length() < 8:
|
|
file.name += letter
|
|
chosen_name.text = file.name
|
|
if file.name.length() > 0:
|
|
$"%ExitDoor".frame = 1
|
|
|
|
func _on_backspace():
|
|
# file.name.erase(file.name.length() - 1,1)
|
|
file.name = file.name.left(file.name.length() - 1)
|
|
chosen_name.text = file.name
|
|
print(file.name.length())
|
|
|
|
func _on_Exit_area_entered(area: Area2D) -> void:
|
|
if file.name.length() > 0:
|
|
get_tree().paused = true
|
|
file.save_to_file()
|
|
Fade.fade_out(0.4)
|
|
yield(Fade, "fade_finished")
|
|
get_tree().paused = false
|
|
SceneManager.current_scene = load("res://menus/file_select.tscn").instance()
|