-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.gd
54 lines (40 loc) · 1.18 KB
/
Main.gd
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
extends Node
onready var Menu = preload("res://Menu.tscn")
onready var Game = preload("res://Game.tscn")
var cur_scene
func _ready():
#if OS.is_debug_build() or get_tree().is_editor_hint():
# OS.current_screen = OS.get_screen_count() - 1
# OS.window_maximized = true
randomize()
open_menu()
func quit_game():
get_tree().quit(0)
func open_menu():
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
unload()
cur_scene = Menu.instance()
add_child(cur_scene)
cur_scene.connect("quit", self, "quit_game")
cur_scene.connect("start", self, "start_game")
func start_game():
unload()
cur_scene = Game.instance()
cur_scene.difficulty = Settings.SCORES_TABLE_NORMAL
cur_scene.startup_time_limit = 75.0
cur_scene.chunks_left = 20
add_child(cur_scene)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
cur_scene.connect("quit", self, "open_menu")
func unload():
if cur_scene:
call_deferred("remove_child", cur_scene)
cur_scene.queue_free()
cur_scene = null
func _input(event):
# ESC - open menu.
if event.is_action_pressed("fullscreen"):
get_tree().set_input_as_handled()
Settings.full_screen = not Settings.full_screen
OS.window_fullscreen = Settings.full_screen
Settings.save()