diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-01-09 23:30:27 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-01-09 23:30:27 +0100 |
commit | 485cd463b22e12394cd232812e2c3789ef37ab1c (patch) | |
tree | 5c455ec9c80b59a9f71ba5827b9902f2beb6df88 /Levels/Level.gd | |
parent | 7920e8758506cd46c58ea4889c9f4fb704abfd16 (diff) |
Adds a bunch of characters and fixes things
Diffstat (limited to 'Levels/Level.gd')
-rw-r--r-- | Levels/Level.gd | 29 |
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() |