Restructure tile size usage
This commit is contained in:
17
scripts/autoloads/battle_map_helper.gd
Normal file
17
scripts/autoloads/battle_map_helper.gd
Normal 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
|
||||
1
scripts/autoloads/battle_map_helper.gd.uid
Normal file
1
scripts/autoloads/battle_map_helper.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bt28d2xnvfjmf
|
||||
Reference in New Issue
Block a user