Static
assertThis function is meant to be used in a last branch of if - else if - … - else
chain or in default
of switch - case - case - …
. Let's imagine there is
a union type of which we check all possible cases. Someday we add one more
type to the union, but we forget to extend our switch
by that one more case
.
Thanks to assertUnreachable(theValueOfThatUnionType)
the TypeScript checker
will inform us about such mistake.
a value which we expect to be of type never
Static
booleanHow often to change the returned value
Optional
opts: { Optional
onBy default the method doesn't progress during the game pause.
But with this param set to "ignore"
we can change that behaviour.
Either true
or false
, which changes every n
frames
Static
clampStatic
drawSimilar to BeetPxDraw.text, but with a second color specified, to be used as an outline.
Optional
opts: { Optional
centerOptional
scaleStatic
identityStatic
lerpPicks a number between a
and b
which is in a "distance" between them as specified by t
.
Specifically: lerp(a,b,0) === a
and lerp(a,b,1) === b
.
With opts: { clamp: true }
, the resulting value cannot is always within bounds of a
and b
, even if t
is below 0
or above 1
.
Optional
opts: { Optional
clamp?: booleanStatic
modStatic
noopStatic
offset4Generates a list of XY to add to a given coordinate in order to get all offsets by 1 pixel in 4 directions. Useful e.g. for iterating over adjacent tiles on the game map.
Static
offset8Generates a list of XY to add to a given coordinate in order to get all offsets by 1 pixel in 8 directions. Useful e.g. for iterating over adjacent tiles on the game map, including diagonals.
Static
randomStatic
rangeStatic
repeatStatic
throwStatic
trigStatic
trigStatic
trig
One of 3 main API entry points. This one provides you with the useful utils.
Example