first commit
This commit is contained in:
88
globals.gd
Normal file
88
globals.gd
Normal file
@@ -0,0 +1,88 @@
|
||||
extends Node
|
||||
|
||||
var jumpscareScreen = preload("res://jumpscare.tscn")
|
||||
var gameOverScreen = preload("res://shrek death screen.tscn")
|
||||
|
||||
var playerControlled = false
|
||||
|
||||
var gameRunning = false
|
||||
|
||||
var playerInitPos: Vector3
|
||||
|
||||
var playerInitRotation: Vector3
|
||||
|
||||
var playerPos: Vector3
|
||||
|
||||
var shrekInitPos: Vector3
|
||||
|
||||
var shrekInitRotation: Vector3
|
||||
|
||||
var shrekPos: Vector3
|
||||
|
||||
var huntMode = -1
|
||||
|
||||
var onionsFound = 0
|
||||
var onionsToFind = 8
|
||||
|
||||
var difficulty = 2
|
||||
|
||||
var task = 0
|
||||
|
||||
var runTo: Vector2
|
||||
|
||||
var dead = false
|
||||
|
||||
func reinit():
|
||||
dead = false
|
||||
onionsFound = 0
|
||||
huntMode = 0
|
||||
task = 0
|
||||
makePlayerControlled()
|
||||
|
||||
func foundOnion():
|
||||
onionsFound+=1
|
||||
if huntMode != 1:
|
||||
huntMode = 0
|
||||
if onionsFound >= onionsToFind:
|
||||
task = 1
|
||||
|
||||
func gameOver(_dead):
|
||||
dead = _dead
|
||||
gameRunning = false
|
||||
if dead:
|
||||
get_tree().change_scene_to_packed(jumpscareScreen)
|
||||
else:
|
||||
makeNotPlayerControlled()
|
||||
get_tree().change_scene_to_packed(gameOverScreen)
|
||||
|
||||
|
||||
func _notification(what):
|
||||
match what:
|
||||
NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
makeNotPlayerControlled()
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton:
|
||||
if gameRunning:
|
||||
makePlayerControlled()
|
||||
|
||||
func _ready():
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_released("fullscreen"):
|
||||
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
|
||||
func makePlayerControlled():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
playerControlled = true
|
||||
gameRunning = true
|
||||
|
||||
func makeNotPlayerControlled():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
playerControlled = false
|
||||
|
||||
Reference in New Issue
Block a user