aboutsummaryrefslogtreecommitdiffstats
path: root/godot/scripts/LevelLoader.gd
blob: 2aec587c03caf7bb614bca9c849920d10639ddb7 (plain) (blame)
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
55
extends Node

const NUM_LEVELS = 9

# player node
var player: Spatial = null

# level control
var current_level_id = 0
var levels = []

# stroke control
var current_strokes = 0
var strokes_per_level = []

# Called when the node enters the scene tree for the first time.
func _ready():
	for i in range(NUM_LEVELS):
		levels.append(get_node("/root/Game/Level%d" % (i+1)))
		
	current_strokes = 0
	levels[0].show()
	
	player = get_node("/root/Game/PlayerRoot")


# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass

func load_next_level():
	levels[current_level_id].hide()
	current_level_id = current_level_id + 1
	
	if current_level_id >= NUM_LEVELS:
		# TODO load main menu
		return 
	
	# load next level
	levels[current_level_id].show()
	
	# save current strokes and reset 
	strokes_per_level.append(current_strokes)
	current_strokes = 0
	
	# TODO teleport player back
	

func add_stroke():
	current_strokes += 1
	

func revoke_stroke():
	current_strokes -= 1