Physics · class
CompositeSurface
Explained in Your first game, Rigid bodies.
class CompositeSurface implements GroundSurfaceimport { CompositeSurface } from '@driftengine/physics';Constructor
new
constructor(surfaces: readonly GroundSurface[])| Parameter | Type | Description |
|---|---|---|
surfaces | readonly GroundSurface[] |
Accessors
| Name | Type | Description |
|---|---|---|
partsget | readonly GroundSurface[] | The floors this is made of.MoreExposed because "two of my floors are in the same column" is a question only
the parts can answer, and it is one a consumer has to be able to ask. Two
walkable surfaces overlapping with millimetres between them is invisible to
every gameplay check — |
Methods
sample
sample(x: number, z: number, out: SurfaceHit, atY?: number): booleanAsk every part and keep the best answer.
| Parameter | Type | Description |
|---|---|---|
x | number | |
z | number | |
out | SurfaceHit | |
atY? | number |
More
atY is what makes this correct rather than arbitrary. Without a reference
height the only available rule is "highest wins", which teleports a character
on the low line of a split up onto the high one the moment the two overlap.
sampleBand
sampleBand(x: number, z: number, out: SurfaceHit, loY: number, hiY: number): booleanSee GroundSurface.sampleBand: the highest floor any part puts in the band.
| Parameter | Type | Description |
|---|---|---|
x | number | |
z | number | |
out | SurfaceHit | |
loY | number | |
hiY | number |
More
The one query where composing surfaces costs nothing in fidelity — a band is a filter, so asking every part and keeping the highest answer is the same answer a single surface holding all of them would give.