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

@@ -9,7 +9,6 @@ extends Node2D
@onready var fog_renderer: FogRenderer = %FogRenderer
const DEPLOYED_UNIT_SCENE = preload("res://prefabs/deployed_unit.tscn")
const TILE_SIZE := 100.0
const SOURCE_ID: int = 0
var _pending_layout: String
@@ -26,15 +25,6 @@ func _ready() -> void:
apply_layout(map_layout)
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
func draw_wall(coords: Vector2i) -> void:
draw_custom(coords, tile_set.wall_tile_coords)
@@ -73,7 +63,7 @@ func _apply_layout(layout: String) -> void:
func _apply_deploy(deployed: DeployedUnit, coords: Vector2i) -> void:
deployed.position = coords_to_world(coords)
deployed.position = BattleMapHelper.coords_to_world(coords)
add_child(deployed)
@@ -119,7 +109,7 @@ func draw_fog() -> void:
func get_map_rect() -> Rect2:
if not map_layout:
return Rect2()
return Rect2(Vector2.ZERO, Vector2(map_layout.size) * TILE_SIZE)
return Rect2(Vector2.ZERO, Vector2(map_layout.size) * BattleMapHelper.TILE_SIZE)
func load_from_layout() -> void: