summaryrefslogtreecommitdiff
path: root/Levels/Level.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Levels/Level.gd')
-rw-r--r--Levels/Level.gd29
1 files changed, 22 insertions, 7 deletions
diff --git a/Levels/Level.gd b/Levels/Level.gd
index 57288b2..34463b6 100644
--- a/Levels/Level.gd
+++ b/Levels/Level.gd
@@ -1,13 +1,6 @@
extends Node2D
-export var starting_position = Vector2(0, 0)
-export var camera_limit_left = 0
-export var camera_limit_top = 0
-export var camera_limit_right = 0
-export var camera_limit_bottom = 0
-
-
var idx = 0
var HUD = CanvasLayer.new()
@@ -21,6 +14,9 @@ func _ready():
self.HUD.add_child(self.LabelTimer)
self.HUD.add_child(self.LevelMap)
self.add_child(self.HUD)
+
+ var character = load("res://Characters/" + Network.player.character + ".tscn").instance()
+ self.set_player(character)
func _process(delta):
@@ -28,5 +24,24 @@ func _process(delta):
self.LabelTimer.text = "%.2fs" % self.timer
+func set_player(character: KinematicBody2D):
+ character.position.x = $Character.position.x
+ character.position.y = $Character.position.y
+ for child in $Character.get_children():
+ if not child is Camera2D:
+ $Character.remove_child(child)
+ $Character.replace_by(character)
+
+
+func respawn_player():
+ var instance_level = Global.get_instance_level(self.idx)
+ instance_level.timer = self.timer # timer continues playing
+ Global.change_scene_to_instance(instance_level)
+
+
func end_level():
Global.end_level(self)
+
+
+func cancel_level():
+ Global.cancel_level()