-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.gd
More file actions
66 lines (57 loc) · 1.91 KB
/
Main.gd
File metadata and controls
66 lines (57 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extends Node2D
var initiateGame = false
var startUp = true
func _ready():
AudioPlayer.play_music_home()
func _on_start_pressed():
$Message.text = "Starting Game!"
Global.health = 50
Global.positionX = 100
Global.positionY = 650
Global.passedHalfway = false
Global.savedGame = false
SaveGame.saveGame()
initiateGame = true
await get_tree().create_timer(1.8).timeout
get_tree().change_scene_to_file("res://Views/Levels/LevelOne.tscn")
## A button to start the last loaded game (hopefully)
func _on_load_pressed():
SaveGame.loadGame()
if !Global.savedGame:
$Message.text = "No saved game available"
return
if Global.passedHalfway:
Global.passedHalfway = false
Global.overRide = true
initiateGame = true
await get_tree().create_timer(1.8).timeout
get_tree().change_scene_to_file("res://Views/Levels/LevelOne.tscn")
func _on_halfway_pressed():
SaveGame.loadGame()
if !Global.passedHalfway:
$Message.text = "You have yet to pass the halfway savepoint"
return
Global.passedHalfway = false
Global.positionX = 7288
Global.positionY = 558
initiateGame = true
await get_tree().create_timer(1.8).timeout
get_tree().change_scene_to_file("res://Views/Levels/LevelOne.tscn")
func _process(delta):
if initiateGame:
var characterAnim = get_node("MushroomRingBackground/DummyPlayer/AnimationPlayer")
var character = get_node("MushroomRingBackground/DummyPlayer/AnimatedSprite2D")
characterAnim.play("running")
if character.position.x > -1250:
character.position.x -= 750 * delta
if startUp and !Global.gameOver:
SaveGame.loadGame()
if !Global.passedHalfway:
$MushroomRingBackground/CenterContainer/VBoxContainer/Halfway.set_disabled(true)
if !Global.savedGame:
$MushroomRingBackground/CenterContainer/VBoxContainer/Load.set_disabled(true)
startUp = false
func _on_settings_pressed():
get_tree().change_scene_to_file("res://Views/Menus/AudioSettings.tscn")
func _on_quit_pressed():
get_tree().quit()