aboutsummaryrefslogtreecommitdiffstats
path: root/godot
diff options
context:
space:
mode:
Diffstat (limited to 'godot')
-rw-r--r--godot/scenes/Game.gd47
-rw-r--r--godot/scripts/LevelLoader.gd55
2 files changed, 42 insertions, 60 deletions
diff --git a/godot/scenes/Game.gd b/godot/scenes/Game.gd
index 31e543d..29a5537 100644
--- a/godot/scenes/Game.gd
+++ b/godot/scenes/Game.gd
@@ -1,14 +1,23 @@
extends Spatial
+const NUM_LEVELS = 9
+const PAR = [1,2,3,4,5,6,7,8,9]
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
+# level control
+var current_level_id = 0
+var levels = []
+# stroke control
+var current_strokes = 0
+var strokes_per_level = [0,0,0,0,0,0,0,0,0]
# Called when the node enters the scene tree for the first time.
func _ready():
- pass # Replace with function body.
+ for i in range(NUM_LEVELS):
+ levels.append(get_node("/root/Game/Level%d" % (i+1)))
+
+ current_strokes = 0
+ levels[0].show()
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -20,7 +29,6 @@ func _process(delta):
-
func _on_QuitButton_pressed():
get_tree().quit()
@@ -29,3 +37,32 @@ func _on_ResumeButton_pressed():
$PausePopup.hide()
get_tree().paused = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+
+
+func load_next_level():
+ levels[current_level_id].hide()
+ current_level_id = current_level_id + 1
+
+ # save current strokes and reset
+ strokes_per_level[current_level_id] = current_strokes
+ current_strokes = 0
+
+ if current_level_id >= NUM_LEVELS:
+ # TODO load main menu
+ return
+
+ # load next level
+ levels[current_level_id].show()
+
+ $Scoreboard.update_values(strokes_per_level, PAR)
+ $Scoreboard.show()
+
+ # TODO teleport player back
+
+
+func add_stroke():
+ current_strokes += 1
+
+
+func revoke_stroke():
+ current_strokes -= 1
diff --git a/godot/scripts/LevelLoader.gd b/godot/scripts/LevelLoader.gd
deleted file mode 100644
index 2aec587..0000000
--- a/godot/scripts/LevelLoader.gd
+++ /dev/null
@@ -1,55 +0,0 @@
-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
-