Plant spawn

This commit is contained in:
Rendo 2025-08-03 18:34:54 +05:00
commit 941912d7f1
25 changed files with 281 additions and 40 deletions

View file

@ -0,0 +1,23 @@
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)

View file

@ -0,0 +1 @@
uid://dnsvj0t3oe3ke