-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.gd
47 lines (35 loc) · 1.27 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
extends Node3D
class_name Main
@onready var screens:Control = $screens
# Called when the node enters the scene tree for the first time.
func _ready():
g.player = preload("res://entities/Player.tscn").instantiate()
add_child(g.player)
g.main = self
#Input.mouse_mode = Input.MOUSE_MODE_CONFINED_HIDDEN
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
$debug.text = g.debug_text
func _physics_process(_delta):
if g.screens and g.enable_controls:
g.enable_controls = false
if not g.screens and not g.enable_controls:
g.enable_controls = true
func _input(ev:InputEvent):
var ev_mouse:InputEventMouseMotion = ev as InputEventMouseMotion
if ev_mouse:
if Input.mouse_mode != Input.MOUSE_MODE_VISIBLE:
#TODO fix for web
get_viewport().warp_mouse(Vector2(0.5, 0.5))
if ev.is_action_pressed("back"):
if g.in_game:
var pause_screen:PauseScreen = g.main.get_node("PauseScreen")
if not g.screens:
pause_screen = preload("res://UI/PauseScreen.tscn").instantiate()
screens.add_child(pause_screen)
else:
if g.screens:
g.screens[-1].queue_free()
if ev.is_action_pressed("win"):
var win_screen:WinScreen = preload("res://UI/WinScreen.tscn").instantiate()
screens.add_child(win_screen)