Restructure tile size usage

This commit is contained in:
gamer147
2026-04-09 08:07:25 -04:00
parent 6b46d1c274
commit e356078a9f
10 changed files with 57 additions and 42 deletions

View File

@@ -0,0 +1,17 @@
extends Node
var TILE_SIZE: float:
get:
return BattleMapConstants.TILE_SIZE
func snap_to_grid(pos: Vector2) -> Vector2:
return Vector2(floorf(pos.x / TILE_SIZE), floorf(pos.y / TILE_SIZE)) * TILE_SIZE
func world_to_coords(pos: Vector2) -> Vector2i:
return Vector2i(snap_to_grid(pos) / TILE_SIZE)
func coords_to_world(coords: Vector2i) -> Vector2:
return Vector2(coords) * TILE_SIZE