Using tilemaplayer as grid

This commit is contained in:
gdz
2025-12-22 17:35:13 +01:00
parent 67b6198412
commit 6e1a9eff35
10 changed files with 147 additions and 22 deletions

View File

@@ -31,17 +31,24 @@ var cell := Vector2.ZERO:
# a signal, and start the cooldown timer that will limit the rate
# at which the cursor moves when we keep the direction key held
# down
position = grid.calculateMapPosition(cell)
# global_position = grid.calculateMapPosition(cell)
global_position = GroundLayer.map_to_local(cell)
print("Position is ", position)
emit_signal("moved", cell)
_timer.start()
@onready var _timer: Timer = $Timer
@onready var Map: Node = $"../../Map"
@onready var GroundLayer: TileMapLayer = $"../../Map/Ground"
func _ready() -> void:
# Map = get_parent().get_parent().get_node("Map")
# GroundLayer = Map.get_node("Ground")
#
_timer.wait_time = ui_cooldown
position = grid.calculateMapPosition(cell)
#position = grid.calculateMapPosition(cell)
position = GroundLayer.map_to_local(cell)
func _unhandled_input(event: InputEvent) -> void: