project_teddy/scripts/global.gd
2023-02-21 12:53:13 -07:00

55 lines
2.3 KiB
GDScript

extends Node
var mouseSensitivity = 0.01 # Unless otherwise changed by user in settings
var playingGame = false # Should be true while in a map, set by menus
var menuOpen = false # Whether or not the in-game menu is active
var fatigue = 100 # Makes it so you can't run forever, you have limited energy
var playerHealth = 100 # If zero, the player dies. Bullets cause damage
var playerDead = false # Defined by Global.player_dead()
var playerAlive = true # Gets set to false by death.tscn then to true after the death timer is up
var playerPleaseRespawn = false # When true, this executes the apporiate commands to respawn the player. Controlled by death.tscn
var playerYDeath = -20 # The point in which the player will die from falling off the map, defined in map scripts
var playerName # Defined in the settings-file.gd script
var deathShield = 0 # Makes you unkillable for a specified amount of time. Used to prevent the kill screen from appearing twice as well
var goScene # This is used for the sceneChangerConfirm window. Initalized by a different script prior to sceneChangerConfirm
var consoleOpen = false # This specifies whether or not the console is open
var consoleCommand # Defined by console.gd
var consoleOutput # Defined by console.gd
var godMode = false # Defined by console.gd
var selfTeddy # Defined as soon as the player script is initalized
var multiplayerCurrent = false
func _process(delta):
if godMode:
pass
elif Input.is_action_pressed("sprint"):
if fatigue > 0:
fatigue = fatigue - 10 * delta
elif not Input.is_action_pressed("sprint"):
if fatigue < 100:
fatigue = fatigue + 2 * delta
if playerAlive:
deathShield = deathShield - 10 * delta # Make player not killable until the value falls below 0
func player_dead():
playerDead = true
if deathShield <= 0:
deathShield = 50
if playerAlive:
print("Player be deaddddd brooooooo")
var scene_trs =load("res://scenes/death.tscn")
var scene=scene_trs.instantiate()
add_child(scene)
func reset_variables():
print("Variables were reset by something")
fatigue = 100
playerHealth = 100
playerDead = false
playerAlive = true
playerPleaseRespawn = false
func add_player_character(mapNode):
var player_character = preload("res://scenes/Teddy.tscn").instantiate()
mapNode.add_child(player_character)
player_character.position.y = 1