summaryrefslogtreecommitdiff
path: root/Levels/Level.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Levels/Level.gd')
-rw-r--r--Levels/Level.gd31
1 files changed, 21 insertions, 10 deletions
diff --git a/Levels/Level.gd b/Levels/Level.gd
index 2e623e5..d7ea0c9 100644
--- a/Levels/Level.gd
+++ b/Levels/Level.gd
@@ -5,18 +5,15 @@ var idx = 0
var timer = 0
var HUD = CanvasLayer.new()
-var LabelTimer = preload("res://UI/HUD/Timer.tscn").instance()
-var LevelMap = preload("res://UI/HUD/LevelMap.tscn").instance()
-var CancelButton = preload("res://UI/HUD/CancelButton.tscn").instance()
+var LabelTimer = preload("res://UI/HUD/Timer.tscn").instantiate()
+var LevelMap = preload("res://UI/HUD/LevelMap.tscn").instantiate()
+var CancelButton = preload("res://UI/HUD/CancelButton.tscn").instantiate()
func _ready():
- self.HUD.add_child(self.LabelTimer)
- self.HUD.add_child(self.LevelMap)
- self.HUD.add_child(self.CancelButton)
- self.add_child(self.HUD)
+ self.set_hud()
- var character = load("res://Characters/" + Network.player.character + ".tscn").instance()
+ var character = load("res://Characters/" + Network.player.character + ".tscn").instantiate()
self.set_player(character)
@@ -26,11 +23,25 @@ func _process(delta):
func _input(event):
- if event is InputEventKey and event.scancode == KEY_ESCAPE:
+ if event is InputEventKey and event.keycode == KEY_ESCAPE:
Global.open_menu()
-func set_player(character: KinematicBody2D):
+func set_hud():
+ self.LabelTimer.position.x = 3
+
+ self.LevelMap.position.x = get_viewport_rect().end.x - self.LevelMap.size.x
+
+ self.CancelButton.position.x = get_viewport_rect().end.x - self.CancelButton.size.x
+ self.CancelButton.position.y = get_viewport_rect().end.y - self.CancelButton.size.y
+
+ self.HUD.add_child(self.LabelTimer)
+ self.HUD.add_child(self.LevelMap)
+ self.HUD.add_child(self.CancelButton)
+ self.add_child(self.HUD)
+
+
+func set_player(character: CharacterBody2D):
character.position.x = $Character.position.x
character.position.y = $Character.position.y
for child in $Character.get_children():