From 485cd463b22e12394cd232812e2c3789ef37ab1c Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 9 Jan 2021 23:30:27 +0100 Subject: Adds a bunch of characters and fixes things --- Levels/Level.gd | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'Levels/Level.gd') 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() -- cgit v1.2.3