CellGrid class final

columns by rows cells, each there or gone: a Space Invaders shield, a wall of bricks, a field of crops.

Made to be worn away. A shield loses a few cells to every shot and is drawn again from what is left; clear and clearAround take cells away, and mesh draws the ones still there as blocks.

Constructors

CellGrid({required int columns, required int rows, double cell = 1.0})
An empty grid of columns by rows cells of cell metres. Throws an ArgumentError when either count is not positive.
CellGrid.fromMask(List<String> mask, {double cell = 1.0})
A grid from lines of text, one per row, # for a cell and anything else for none; rows shorter than the longest are empty past their end.
factory

Properties

cell → double
The size of one cell, in metres.
final
columns → int
Count of cells across, along X; positive.
final
count → int
How many cells are there.
no setter
hashCode → int
The hash code for this object.
no setterinherited
rows → int
Count of cells down, one per line of a mask; positive.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear(int column, int row) → bool
Takes cell (column, row) away. True when it was there.
clearAround(double x, double y, double radius) → int
Takes away every cell whose middle is within radius metres of (x, y), measured from the grid's corner. How many went.
isAlive(int column, int row) → bool
Whether cell (column, row) is there; outside the grid, no.
mesh({required Vector3 place(double x, double y), double? depth, LinearColor? color}) → MeshData?
The cells still there as blocks depth deep, merged into one mesh; null when none are left. place says where a cell's middle goes, from its middle's (x, y) in metres from the grid's corner; the block is centred on that point.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(int column, int row, {bool alive = true}) → bool
Puts cell (column, row) there, or takes it away when alive is false. True when that changed it; a cell outside the grid is left.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited