newlon/scripts/utility/field_params.gd
2025-08-03 18:34:54 +05:00

23 lines
695 B
GDScript

extends Node
## Utility class for field parameters and connected functions
class_name FieldParams
## Tile size
const TILE : Vector2 = Vector2(50,60)
## Rows count of field
const ROWS : int = 5
## Columns count of field
const COLUMNS : int = 9
## Field rectangle. Origin is set in-game
static var field_rect : Rect2 = Rect2(0,0,COLUMNS*TILE.x,ROWS*TILE.y)
## Converts vector position into int index. Hash somewhat
static func indexify(position : Vector2) -> int:
var tiled_position = (position/TILE).floor()
return int(tiled_position.x) + int(tiled_position.y * COLUMNS)
static func deindexify(index : int) -> Vector2:
return Vector2(index % COLUMNS * TILE.x, index / COLUMNS * TILE.y)