diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-06-18 16:43:22 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-06-18 16:43:22 +0200 |
commit | 395c25b1fbe51f42decf402f97e51eabcc8c0a77 (patch) | |
tree | 72a17c71a39b53d328a76e111ae205d9538d64d0 /Levels/Level.gd | |
parent | 2686ec6d4af6b5437a5f5a5cac008f3d38295f78 (diff) |
Godot v3 -> v4
Diffstat (limited to 'Levels/Level.gd')
-rw-r--r-- | Levels/Level.gd | 31 |
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(): |