blob: e5cf08eaa9e25f9614b134c9708c494cc1d3fde4 (
plain)
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
|
extends Node
class_name GameLoop
@export var turns : int
@export var label : Label
@export_file var level : String
var current_turns : int = 0
var prev_turn : int = -1
# Called when the node enters the scene tree for the first time.
func _ready():
GlobalVariables.gameloop = self
current_turns = 0
func _process(_delta):
if current_turns >= turns:
label.text = "FINISHED!"
if prev_turn != current_turns:
prev_turn = current_turns
label.text = "Turns Left: " + str(turns - current_turns)
if current_turns != 0: GlobalVariables.ai.step()
if Input.is_action_just_pressed("reset"):
get_tree().change_scene_to_file(level)
|