feat: add names to dragons

This commit is contained in:
Gerard Gascón 2025-04-08 23:38:27 +02:00
parent f07b28d2dc
commit ca4959af32
10 changed files with 91 additions and 15 deletions

View file

@ -10,9 +10,9 @@ func _init(dragon: PackedScene, viewport: Viewport, window: Window) -> void:
_dragon_template = dragon
func instantiate(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D) -> Node:
func instantiate(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String) -> Node:
var relative_position: Vector2i = _calculate_relative_position(position)
return _instantiate_dragon(relative_position, hat, shirt, shoes)
return _instantiate_dragon(relative_position, hat, shirt, shoes, dragon_name)
func _calculate_window_scale() -> Vector2:
@ -27,7 +27,7 @@ func _calculate_relative_position(position: Vector2) -> Vector2i:
return Vector2i(Vector2(position) * scale)
func _instantiate_dragon(relative_position: Vector2i, hat: Texture2D, shirt: Texture2D, shoes: Texture2D) -> Node:
func _instantiate_dragon(relative_position: Vector2i, hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String) -> Node:
var dragon: Dragon = _dragon_template.instantiate()
var window_position: Vector2i = DisplayServer.window_get_position()
@ -35,6 +35,7 @@ func _instantiate_dragon(relative_position: Vector2i, hat: Texture2D, shirt: Tex
dragon.position = window_position + relative_position - dragon.size / 2
dragon.dress(hat, shirt, shoes)
dragon.set_dragon_name(dragon_name)
var size: float = _calculate_window_scale().y
dragon.set_scale(size)