Alice Gaudon 11 months ago
parent
commit
61bba2b17a
  1. BIN
      images/icon.png
  2. 2
      scripts/DialogueAction.gd
  3. 17
      scripts/Globals.gd
  4. 6
      scripts/MusicPlayer.gd
  5. 5
      scripts/credits.gd
  6. 1
      scripts/main_menu.gd

BIN
images/icon.png

Before

Width: 64  |  Height: 64  |  Size: 3.2 KiB

After

Width: 16  |  Height: 16  |  Size: 164 B

2
scripts/DialogueAction.gd

@ -16,7 +16,7 @@ func start() -> void:
func load_dialogue(file_path) -> Array:
var file = File.new()
assert (file.file_exists(file_path))
# assert (file.file_exists(file_path))
file.open(file_path, file.READ)
var dialogue = parse_json(file.get_as_text())

17
scripts/Globals.gd

@ -3,3 +3,20 @@ extends Node
var ui_accept_tip = false
var ui_interact_flatfish_tip = false
var did_already_play_once = false
func save_game():
var file = File.new()
file.open('user://globals.save', File.WRITE)
file.store_line('1' if did_already_play_once else '0')
file.close()
print('saved')
func load_game():
var file = File.new()
if not file.file_exists("user://savegame.save"):
return
file.open('user://globals.save', File.READ)
var d = file.get_line()
did_already_play_once = true if d == '1' else false
print('loaded')

6
scripts/MusicPlayer.gd

@ -9,9 +9,9 @@ var previous_tracks : Array
func play(music, offset=0, duration=1):
print('Play music: ' + music)
var path = "res://sounds/" + music + ".ogg"
if !File.new().file_exists(path):
path = "res://sounds/" + music
assert(File.new().file_exists(path))
# if !File.new().file_exists(path):
# path = "res://sounds/" + music
# assert(File.new().file_exists(path))
var stream = load(path)
target_track = get_free_track()

5
scripts/credits.gd

@ -1,7 +1,10 @@
extends Node2D
func _ready():
Globals.did_already_play_once = true
Globals.save_game()
func _input(event):
if event.is_action_pressed("ui_accept"):
Globals.did_already_play_once = true
get_tree().change_scene("res://scenes/main_menu.tscn")

1
scripts/main_menu.gd

@ -4,5 +4,6 @@ onready var music_player = get_node('/root/MusicPlayer') as MusicPlayer
func _ready():
music_player.play('main_title')
Globals.load_game()
if Globals.did_already_play_once:
$UI/Buttons/AnotherChoiceButton.show()
Loading…
Cancel
Save