SolidGrid
A level's solids: at most one per cell of a grid of columns by rows cells, each tileSize wide, plus moving ones. Set it as PhysicsWorld.solids and every particle is pushed out of it: a point particle can only be inside the one tile it is in, so only that tile and the moving solids are checked; a round one checks the tiles its radius reaches.
toString gives its size, for example SolidGrid(40x30, tileSize=16.0, moving=1).
Throws
Samples
// A level 40 tiles across and 20 down, each 16 units: a floor, and a slope up to a ledge.
val grid = SolidGrid(columns = 40, rows = 20, tileSize = 16f)
for (column in 0 until 40) grid.fill(column, 19)
grid.fill(10, 18, shape = SolidShape.RISING)
grid.fill(11, 18)
val world = PhysicsWorld()
world.solids = grid
assertPrints(grid.isSolidAt(8f, 310f), "true")
assertPrints(grid.atOrNull(11, 18)?.shape, "BOX")
assertPrints(grid.atOrNull(12, 18), "null")Content copied to clipboard
Constructors
Functions
Link copied to clipboard
Adds solid, made with Solid.moving, to the solids that move. Adding one already there does nothing.
Link copied to clipboard
Link copied to clipboard