Plant spawn
This commit is contained in:
parent
32453f2e9d
commit
941912d7f1
25 changed files with 281 additions and 40 deletions
23
scripts/utility/field_params.gd
Normal file
23
scripts/utility/field_params.gd
Normal 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)
|
||||
1
scripts/utility/field_params.gd.uid
Normal file
1
scripts/utility/field_params.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dnsvj0t3oe3ke
|
||||
Loading…
Add table
Add a link
Reference in a new issue