Members
(constant) d4 :Array.<Vec2>
Contains directional vectors in all four cardinal directions.
Type:
- Array.<Vec2>
(constant) d4edge :Array.<Vec2>
Contains directional vectors in all four diagonal directions.
Type:
- Array.<Vec2>
(constant) d4mid :Array.<Vec2>
Contains directional vectors in all four cardinal directions plus the middle.
Type:
- Array.<Vec2>
(constant) d8 :Array.<Vec2>
Contains directional vectors in all diagonal and cardinal directions.
Type:
- Array.<Vec2>
(constant) d8mid :Array.<Vec2>
Contains directional vectors in all diagonal and cardinal directions plus the middle.
Type:
- Array.<Vec2>
(constant) mapSize :int
The maximum coordinate of a tile. The top-rightmost tile has the coordinate (mapSize, mapSize).
Type:
- int
(constant) shadowOffset :Vec2
The standard offset of a unit's shadow. Used for drawing unit splashes.
Type:
(readonly) state
The current state of the game.
Properties:
| Name | Type | Description |
|---|---|---|
secs |
number | Smoothed position of the music track in seconds. |
lastSecs |
number | Last "discrete" music track position, internally used. |
time |
number | Smooth game time, may not necessarily match seconds. Visuals only! |
globalTime |
number | The global time that is independent of the current beatmap. Very useful for animating values. Does not freeze in menus or when the game is paused (TODO actually test this). |
rawBeat |
number | Raw beat calculated based on music position. |
moveBeat |
number | Beat calculated as countdown after a music beat happens. Smoother, but less precise. |
newTurn |
Boolean | If true, a new turn was just fired this frame |
hitTime |
number | Snaps to 1 when player is hit for health animation. |
healTime |
number | Snaps to 1 when player is healed. Seems like healing is an unimplemented mechanic in the base game. |
points |
int | Points awarded based on various events. |
turn |
int | Beats that have passed total. |
hits |
int | The number of times the player has been hit this map. (?) |
totalHits |
int | Same as state.hits, probably. |
misses |
int | The number of times the player has missed an input this map. (?) |
currentBpm |
number | The current BPM (beats per minute). |
playerPos |
Vec2 | Last known player position. |
beatSpacing |
number | The time between two beats. |
Methods
beginBloom()
Patterns will be drawn with bloom enabled until endBloom() is called. Only works in unit splash drawing.
changeBpm(bpm)
Changes the BPM of the current map.
Parameters:
| Name | Type | Description |
|---|---|---|
bpm |
number | The new BPM the map should have. |
damageBlocks(target)
Damages (usually destroys) bullets, conveyors, etc. on a target tile.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
Vec2 | The tile to target. |
deg(x) → {number}
Converts x from radians to degrees.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | The value to convert. |
Returns:
The value in degrees.
- Type
- number
drawArc(pos, sides, angleFrom, angleTo, radius, rotationopt, strokeopt, coloropt, zopt)
Draws a polygonal arc.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the arc. |
||
sides |
int | The number of sides of the arc. |
||
angleFrom |
number | The angle where the arc starts. |
||
angleTo |
number | The angle where the arc ends. |
||
radius |
number | The radius of the arc. |
||
rotation |
number |
<optional> |
0 | The rotation of the arc. |
stroke |
number |
<optional> |
px(1) | The thickness of the outline. |
color |
Color |
<optional> |
Color.white | The color of the outline. |
z |
number |
<optional> |
0 | The z layer of the polygon. |
drawArcRadius(pos, sides, angleFrom, angleTo, radiusFrom, radiusTo, rotationopt, coloropt, zopt)
Draws a polygonal ring sector.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The midpoint of the ring. |
||
sides |
int | The number of sides of the ring sector. |
||
angleFrom |
number | The angle where the sector starts. |
||
angleTo |
number | The angle where the sector ends. |
||
radiusFrom |
number | The inner radius of the ring. |
||
radiusTo |
number | The outer radius of the ring. |
||
rotation |
number |
<optional> |
0 | The rotation of the sector. |
color |
Color |
<optional> |
Color.white | The color of the ring. |
z |
number |
<optional> |
0 | The z layer of the ring. |
drawBackground(col)
Draws a single color background.
Parameters:
| Name | Type | Description |
|---|---|---|
col |
Color | The color of the background. |
drawBeatAlt(col)
Same as DrawBeatSquare, but flashes in a different pattern. Only works inside levels.
Parameters:
| Name | Type | Description |
|---|---|---|
col |
Color | The color of the square. |
drawBeatSquare(colopt)
Draws a square that flashes and changes size with the beat. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.mix(Color.pink, Color.white, 0.7) | The color of the square. |
drawBounceSquares(colopt)
Draws a lattice of squares with alternating sizes. The sizes of the squares swap with the beat. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the squares. |
drawCircles(colopt, timeopt, amountopt, seedopt, minSizeopt, maxSizeopt, moveSpeedopt)
Draws circles in random sizes that move around the screen in random directions. This effect is used for Mono, Oct and Sei.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the circles. |
time |
number |
<optional> |
state.time | The circles will move if you put in a value that changes over time. |
amount |
int |
<optional> |
50 | The number of circles to draw. |
seed |
int |
<optional> |
1 | The random seed. |
minSize |
number |
<optional> |
2 | The smallest size a circle can be. |
maxSize |
number |
<optional> |
7 | The largest size a circle can be. |
moveSpeed |
number |
<optional> |
0.2 | The speed at which the circles move. |
drawClouds(colopt)
Draws clouds in the upper half of the screen. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the clouds. |
drawCrescent(pos, sides, angleFrom, angleTo, radius, rotationopt, strokeopt, coloropt, zopt)
Draws a polygonal crescent shape.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The midpoint of the shape. |
||
sides |
int | The number of sides of the shape. |
||
angleFrom |
number | The angle where the crescent starts. |
||
angleTo |
number | The angle where the crescent ends. |
||
radius |
number | The radius of the shape. |
||
rotation |
number |
<optional> |
0 | The rotation of the shape. |
stroke |
number |
<optional> |
px(1) | The width of the thickest part of the crescent. |
color |
Color |
<optional> |
Color.white | The color of the outline. |
z |
number |
<optional> |
0 | The z layer of the shape. |
drawFadeIn(time)
A light blue screen disappears into the bottom right corner. This effect is used to transition between the menu and levels.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number | The effect will move if you put in a value that changes over time. The value should change in reverse (?). |
drawFadeOut(time)
The screen becomes light blue from the top left corner. This effect is used to transition between the menu and levels.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number | The effect will move if you put in a value that changes over time. |
drawFadeShapes(col)
Draws repeating rotated squares that move towards the center with the beat. Only works inside levels.
Parameters:
| Name | Type | Description |
|---|---|---|
col |
Color | The color of the squares. |
drawFallSquares(col1opt, col2opt, timeopt, amountopt)
Draws squares that fall down while spinning and changing color. This effect is used for Quad.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color |
<optional> |
Color.white | The initial color of the squares. |
col2 |
Color |
<optional> |
Color.white | The color the squares change to over their lifetime. |
time |
number |
<optional> |
state.time | The squares will move if you put in a value that changes over time. |
amount |
int |
<optional> |
50 | The number of squares to draw. |
drawFft(pos, radiusopt, lengthopt, coloropt)
Draws a circular audio spectrum. Never used in the base game.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the spectrum. |
||
radius |
number |
<optional> |
px(90) | The inner radius of the spectrum. |
length |
number |
<optional> |
8 | The length of the spectrum bars. |
color |
Color |
<optional> |
Color.white | The color of the spectrum. |
drawFillCircle(pos, rad, coloropt, zopt)
Draws a filled circle.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the midpoint of the circle. |
||
rad |
number | The radius of the circle. |
||
color |
Color |
<optional> |
Color.white | The color of the circle. |
z |
number |
<optional> |
0 | The z layer of the circle. |
drawFillLight(pos, radius, sidesopt, centerColoropt, edgeColoropt, zopt)
Draws a regular polygon with a gradient to the middle.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the shape. |
||
radius |
number | The radius of the shape. |
||
sides |
int |
<optional> |
20 | The number of sides the polygon has. With the default value of 20, it looks close to a circle. |
centerColor |
Color |
<optional> |
Color.white | The color of the shape at the center. |
edgeColor |
Color |
<optional> |
Color.white | The color of the shape at the edge. |
z |
number |
<optional> |
0 | The z layer of the shape. |
drawFillPoly(pos, sides, radius, rotationopt, coloropt, zopt)
Draws a filled polygon.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the center of the polygon. |
||
sides |
int | The number of sides the polygon has. |
||
radius |
number | The radius of the polygon. |
||
rotation |
number |
<optional> |
0 | The rotation of the polygon. |
color |
Color |
<optional> |
Color.white | The color of the polygon. |
z |
number |
<optional> |
0 | The z layer of the polygon. |
drawFillQuad(v1, v2, v3, v4, color, zopt)
Draws a filled quad with a single color.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
v1 |
Vec2 | A vertex of the quad. |
||
v2 |
Vec2 | A vertex of the quad. |
||
v3 |
Vec2 | A vertex of the quad. |
||
v4 |
Vec2 | A vertex of the quad. |
||
color |
Color | The color of the quad. |
||
z |
number |
<optional> |
0 | The z layer of the quad. |
drawFillQuadGradient(v1, v2, v3, v4, c1, c2, c3, c4, zopt)
Draws a filled quad with a gradient.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
v1 |
Vec2 | A vertex of the quad. |
||
v2 |
Vec2 | A vertex of the quad. |
||
v3 |
Vec2 | A vertex of the quad. |
||
v4 |
Vec2 | A vertex of the quad. |
||
c1 |
Color | The color of the quad at v1. |
||
c2 |
Color | The color of the quad at v2. |
||
c3 |
Color | The color of the quad at v3. |
||
c4 |
Color | The color of the quad at v4. |
||
z |
number |
<optional> |
0 | The z layer of the quad. |
drawFillRect(x, y, w, h, coloropt, zopt)
Draws a filled rectangle.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
x |
number | The x coordinate of the bottom left corner. |
||
y |
number | The y coordinate of the bottom left corner. |
||
w |
number | The width of the rectangle. |
||
h |
number | The height of the rectangle. |
||
color |
Color |
<optional> |
Color.white | The color of the rectangle. |
z |
number |
<optional> |
0 | The z layer of the rectangle. |
drawFillSquare(pos, radius, coloropt, zopt)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the midpoint of the square. |
||
radius |
number | The radius of the square (half the side length). |
||
color |
Color |
<optional> |
Color.white | The color of the square. |
z |
number |
<optional> |
0 | The z layer of the square. |
drawFillTri(v1, v2, v3, color, zopt)
Draws a filled triangle with a single color.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
v1 |
Vec2 | A vertex of the triangle. |
||
v2 |
Vec2 | A vertex of the triangle. |
||
v3 |
Vec2 | A vertex of the triangle. |
||
color |
Color | The color of the triangle. |
||
z |
number |
<optional> |
0 | The z layer of the triangle. |
drawFillTriGradient(v1, v2, v3, c1, c2, c3, zopt)
Draws a filled triangle with a gradient.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
v1 |
Vec2 | A vertex of the triangle. |
||
v2 |
Vec2 | A vertex of the triangle. |
||
v3 |
Vec2 | A vertex of the triangle. |
||
c1 |
Color | The color of the triangle at v1. |
||
c2 |
Color | The color of the triangle at v2. |
||
c3 |
Color | The color of the triangle at v3. |
||
z |
number |
<optional> |
0 | The z layer of the triangle. |
drawFlame(col1opt, col2opt, timeopt, amountopt)
Draws circles that move upwards while becoming smaller and changing color. This effect is used for Oxynoe.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color |
<optional> |
Color.white | The initial color of the circles. |
col2 |
Color |
<optional> |
Color.white | The color the circles change to. |
time |
number |
<optional> |
state.time | The circles will move if you put in a value that changes over time. |
amount |
int |
<optional> |
80 | The number of circles to draw. |
drawGradient(col1opt, col2opt, col3opt, col4opt)
Draws a gradient across the screen.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color |
<optional> |
Color.clear | The color of the bottom left corner. |
col2 |
Color |
<optional> |
Color.clear | The color of the bottom right corner. |
col3 |
Color |
<optional> |
Color.clear | The color of the top right corner. |
col4 |
Color |
<optional> |
Color.clear | The color of the top left corner. |
drawLine(p1, p2, strokeopt, coloropt, squareopt, zopt)
Draws a line between two points.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
p1 |
Vec2 | The position of the start point. |
||
p2 |
Vec2 | The position of the end point. |
||
stroke |
number |
<optional> |
px(1) | The thickness of the line. |
color |
Color |
<optional> |
Color.white | The color of the line. |
square |
bool |
<optional> |
true | ??? |
z |
number |
<optional> |
0 | The z layer of the line. |
drawLineAngle(p, angle, len, strokeopt, coloropt, squareopt, zopt)
Draws a line from a point at an angle.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
p |
Vec2 | The position of the start point. |
||
angle |
number | The angle of the line. |
||
len |
number | The length of the line. |
||
stroke |
number |
<optional> |
px(1) | The thickness of the line. |
color |
Color |
<optional> |
Color.white | The color of the line. |
square |
bool |
<optional> |
true | ??? |
z |
number |
<optional> |
0 | The z layer of the line. |
drawLineAngleCenter(p, angle, len, strokeopt, coloropt, squareopt, zopt)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
p |
Vec2 | The position of the midpoint. |
||
angle |
number | The angle of the line. |
||
len |
number | The length of the line. |
||
stroke |
number |
<optional> |
px(1) | The thickness of the line. |
color |
Color |
<optional> |
Color.white | The color of the line. |
square |
bool |
<optional> |
true | ??? |
z |
number |
<optional> |
0 | The z layer of the line. |
drawLineRect(pos, size, strokeopt, coloropt, zopt, marginopt)
Draws a rectangle outline.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the bottom left corner of the rectangle. |
||
size |
Vec2 | The size of the rectangle as a vector of (width, height). |
||
stroke |
number |
<optional> |
px(1) | The thickness of the outline. |
color |
Color |
<optional> |
Color.white | The color of the outline. |
z |
number |
<optional> |
0 | The z layer of the rectangle. |
margin |
number |
<optional> |
0 | Seems to make the rectangle smaller. |
drawLineSquare(pos, rad, strokeopt, coloropt, zopt)
Draws a square outline.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the midpoint. |
||
rad |
number | The radius of the square. |
||
stroke |
number |
<optional> |
px(1) | The thickness of the outline. |
color |
Color |
<optional> |
Color.white | The color of the outline. |
z |
number |
<optional> |
0 | The z layer of the square. |
drawLines(colopt, seedopt, amountopt, angleopt)
Draws rounded lines that move around slightly (looks a bit like rays of light).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the lines. |
seed |
int |
<optional> |
1 | The random seed. |
amount |
int |
<optional> |
30 | The number of lines to draw. |
angle |
number |
<optional> |
Math.rad(45) | The angle at which to draw the lines. |
drawLongClouds(colopt)
Draws clouds in the upper half of the screen. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the clouds. |
drawMissiles(colopt, timeopt, amountopt, seedopt)
Draws moving circles with a trail of smaller circles ("missiles"). This effect is used for Zenith.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the circles. |
time |
number |
<optional> |
state.time | The circles will move if you put in a value that changes over time. |
amount |
int |
<optional> |
50 | The number of circles to draw (not including the trailing circles). |
seed |
int |
<optional> |
1 | The random seed. |
drawPetals()
Draws cherry petals that fall down-left. Only works inside levels.
drawPoly(pos, sides, radius, rotationopt, strokeopt, coloropt, zopt)
Draws a regular polygon outline.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the center of the polygon. |
||
sides |
int | The number of sides the polygon has. |
||
radius |
number | The radius of the polygon. |
||
rotation |
number |
<optional> |
0 | The rotation of the polygon. |
stroke |
number |
<optional> |
px(1) | The line thickness of the polygon. |
color |
Color |
<optional> |
Color.white | The color of the polygon. |
z |
number |
<optional> |
0 | The z layer of the polygon. |
drawRadCircles(colopt, seedopt, amountopt, finopt)
Draws circles in random sizes scattered around the center of the screen.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the circles. |
seed |
int |
<optional> |
7 | The random seed. |
amount |
int |
<optional> |
40 | The number of circles to draw. |
fin |
number |
<optional> |
0.5 | How far away the circles are from the center on average. Also scales the circles. |
drawRadLines(pos, sides, radius, len, strokeopt, rotationopt, coloropt, zopt)
Draws lines pointing at a target position.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The target position. |
||
sides |
int | The number of lines to draw. |
||
radius |
number | The distance from the target point to the start points of the lines. |
||
len |
number | The length of the lines. |
||
stroke |
number |
<optional> |
px(1) | The thickness of the outline. |
rotation |
number |
<optional> |
0 | |
color |
Color |
<optional> |
Color.white | The color of the lines. |
z |
number |
<optional> |
0 | The z layer of the lines. |
drawRadLinesRound(colopt, seedopt, amountopt, strokeopt, posSclopt, lenSclopt)
Draws rounded lines pointing at the center of the screen that move around slightly.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the lines. |
seed |
int |
<optional> |
6 | The random seed. |
amount |
int |
<optional> |
40 | The number of lines to draw. |
stroke |
number |
<optional> |
0.25 | The thickness of the lines. |
posScl |
number |
<optional> |
1 | How far away the lines are from the center on average. A higher value means the lines are further away. |
lenScl |
number |
<optional> |
1 | How long the lines are. |
drawRadTris(colopt, timeopt, amountopt, seedopt)
Draws triangles in random sizes that point away from the center and move around the screen in random directions. This effect is used for Crawler.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the triangles. |
time |
number |
<optional> |
state.time | The triangles will move if you put in a value that changes over time. |
amount |
int |
<optional> |
50 | The number of triangles to draw |
seed |
int |
<optional> |
1 | The random seed. |
drawRain(amountopt)
Draws pinkish squares with trails that move down-left with the beat. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
amount |
int |
<optional> |
80 | The number of shapes to draw. |
drawRoundLine(pos, angle, len, coloropt, strokeopt)
Draws a line with rounded endpoints.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the midpoint of the line. |
||
angle |
number | The angle of the line. |
||
len |
number | The length of the line. |
||
color |
Color |
<optional> |
Color.white | The color of the line. |
stroke |
number |
<optional> |
1 | The thickness of the line. |
drawShape(points, wrapopt, strokeopt, coloropt, zopt)
Draws a polygon outline.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
points |
Array | An array of points to connect into a shape. |
||
wrap |
bool |
<optional> |
false | Whether the last point should connect to the first point. |
stroke |
number |
<optional> |
px(1) | The width of the outline. |
color |
Color |
<optional> |
Color.white | The color of the shape. |
z |
number |
<optional> |
0 | The z layer of the shape. |
drawShapeBack(col1, col2, sidesopt, spacingopt, angleopt)
Draws concentric polygons of alternating colors around the center.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color | The first color. |
||
col2 |
Color | The second color. |
||
sides |
int |
<optional> |
4 | How many sides the polygons have. |
spacing |
number |
<optional> |
2.5 | The distance between each polygon "ring". |
angle |
number |
<optional> |
Math.rad(90) | The angle of the polygon. |
drawSkats()
Draws "skats". Used for the credits. Behaves strangely in levels.
drawSpace(col, timeopt)
Draws many stripes pointing towards the center. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color | The color of the stripes. |
||
time |
number |
<optional> |
state.secs | The stripes will move if you put in a value that changes over time. |
drawSpikes(pos, col, amountopt, offsetopt, lenopt, angleOffsetopt)
Draws rounded lines pointing to a position. The angle between all lines is the same.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position the lines will point to. |
||
col |
Color | The color of the lines. |
||
amount |
int |
<optional> |
10 | The number of lines to draw. |
offset |
number |
<optional> |
8 | How far away the midpoint of each line is from the targeted position. |
len |
number |
<optional> |
3 | The length of the line. |
angleOffset |
number |
<optional> |
0 | Additional rotation around the target position applied to each line. |
drawSpin(col1, col2, bladesopt)
Draws stripes radially from the center. (TODO better explanation)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color | The first color. |
||
col2 |
Color | The second color. |
||
blades |
int |
<optional> |
10 | The number of stripes to draw. |
drawSpinGradient(pos, col1, col2, lenopt, bladesopt, spacingopt)
Draws a "fan" of triangles. (TODO better explanation)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position to center the fan on. |
||
col1 |
Color | The inner color of the triangles. |
||
col2 |
Color | The outer color of the triangles. |
||
len |
number |
<optional> |
5 | The radius of the fan. |
blades |
int |
<optional> |
10 | The number of triangles that the fan is made of. |
spacing |
int |
<optional> |
2 | How often a triangle occurs. |
drawSpinShape(col1, col2, sidesopt, radopt, turnSpeedopt, radsopt, radsidesopt, radOffopt, radradopt, radrotsclopt)
Draws a central layered regular polygon surrounded by smaller "sattelite" polygons. Flashes and rotates with the beat. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color | The normal color. |
||
col2 |
Color | The flash color. |
||
sides |
int |
<optional> |
4 | The number of sides of the central polygon. |
rad |
number |
<optional> |
2.5 | The radius of the central shape. |
turnSpeed |
number |
<optional> |
Math.rad(19) | By how much the central shape rotates every beat. |
rads |
int |
<optional> |
6 | The number of sattelite shapes. |
radsides |
int |
<optional> |
4 | The number of sides of the sattelite polygons. |
radOff |
number |
<optional> |
7 | How far away the sattelite shapes orbit. |
radrad |
number |
<optional> |
1.3 | The radius of the sattelite shapes. |
radrotscl |
number |
<optional> |
0.25 | By how much the sattelite shapes will orbit relative to the central shape's rotation. The sattelites orbit in the opposite direction as the central shape spins. |
drawSquares(colopt, timeopt, amountopt, seedopt)
Draws squares that slowly move around the screen and periodically shrink and grow. This effect is used for Alpha.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the squares. |
time |
number |
<optional> |
state.time | The squares will move if you put in a value that changes over time. |
amount |
int |
<optional> |
50 | The number of squares to draw. |
seed |
int |
<optional> |
2 | The random seed. |
drawStars(colopt, flashopt, amountopt, seedopt)
Draws stars in different shapes and sizes that flash with the beat. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The normal color of the stars. |
flash |
Color |
<optional> |
Color.white | The flash color of the stars. |
amount |
int |
<optional> |
40 | The number of stars to draw. |
seed |
int |
<optional> |
1 | The random seed. |
drawStripes(col1opt, col2opt, angleopt)
Draws construction-tape-like stripes. If used inside a level, scrolls from right to left with the beat.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color |
<optional> |
Color.pink | Background color. |
col2 |
Color |
<optional> |
Color.mix(Color.pink, Color.white, 0.2) | Stripe color. |
angle |
number |
<optional> |
Math.rad(135) | The angle of the stripes. |
drawTiles()
Draws the playing field with diagonal highlighted tiles that move with the beat. Should only be used inside levels.
drawTilesFft()
Draws the playing field with an audio spectrum. Never used in the base game. Should only be used inside levels.
drawTilesSquare(col1opt, col2opt)
Draws the playing field with tiles highlighted in a repeating square pattern. Should only be used inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color |
<optional> |
Color.white | The color of the normal tiles. |
col2 |
Color |
<optional> |
Color.blue | The color of the highlighted tiles. |
drawTriSquare(pos, col, len, rad, offsetopt, amountopt, sidesopt, shapeOffsetopt)
Draws regular polygons in a circle around a position.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position to draw the polygons around. |
||
col |
Color | The color of the polygons. |
||
len |
number | How far away the polygons are from the position. |
||
rad |
number | The size of the polygons. |
||
offset |
number |
<optional> |
Math.rad(45) | Additional rotation around the target position applied to each polygon. |
amount |
int |
<optional> |
4 | The number of polygons to draw. |
sides |
int |
<optional> |
3 | How many sides each polygon has. |
shapeOffset |
number |
<optional> |
Math.rad(0) | Additional rotation applied to each polygon around its own center. |
drawTris(col1opt, col2opt, amountopt, seedopt)
Draws triangles that flash with the beat and move down-left. Only works inside levels.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color |
<optional> |
Color.white | The normal color of the triangles. |
col2 |
Color |
<optional> |
Color.white | The flash color of the triangles. |
amount |
int |
<optional> |
50 | The number of triangles to draw. |
seed |
int |
<optional> |
1 | The random seed. |
drawUnit(pos, sclopt, coloropt, partopt)
Draws the current unit's splash image. Should only be used in unit splash drawing.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | Where to draw the unit. |
||
scl |
Vec2 |
<optional> |
vec2(1, 1) | Scale of the unit. |
color |
Color |
<optional> |
Color.white | Color of the unit. |
part |
string |
<optional> |
"" | Suffix of the texture file to draw (e.g. "-glow" to draw "mono-glow.png"). |
drawVertGradient(col1opt, col2opt)
Draws a vertical gradient.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col1 |
Color |
<optional> |
Color.clear | The bottom color. |
col2 |
Color |
<optional> |
Color.clear | The top color. |
drawZoom(colopt, offsetopt, amountopt, sidesopt)
Draws concentric polygons around the center of the screen that increase in thickness further out.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
col |
Color |
<optional> |
Color.white | The color of the polygons. |
offset |
number |
<optional> |
0 | The offset of the first polygon from the center. Periodic. (TODO explain that better) |
amount |
int |
<optional> |
10 | The number of polygons to draw. |
sides |
int |
<optional> |
4 | The number of sides the polygon will have. |
effectExplode(pos)
Creates an explosion effect on a tile.
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
Vec2 | The position of the tile where the effect will appear. |
effectExplodeHeal(pos)
Creates a green explosion effect on a tile.
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
Vec2 | The position of the tile where the effect will appear. |
effectStrikeWave(pos, life, rotationopt)
Creates a warning effect (large square) around a tile.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the tile where the effect will appear. |
||
life |
number | The lifetime of the effect. Usually a constant multiplied with beatSpacing. |
||
rotation |
number |
<optional> |
0 | The size of the effect. Don't ask. |
effectWarn(pos, life)
Creates a warning effect (white square) on a tile.
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
Vec2 | The position of the tile where the effect will appear. |
life |
number | The lifetime of the effect. Usually a constant multiplied with beatSpacing. |
effectWarnBullet(pos, life, rotation)
Creates a warning effect (white bullet) on a tile.
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
Vec2 | The position of the tile where the effect will appear. |
life |
number | The lifetime of the effect. Usually a constant multiplied with beatSpacing. |
rotation |
number | The rotation of the effect. |
endBloom()
Disables bloom for pattern drawing. Only works in unit splash drawing.
getScl(baseopt) → {Vec2}
Used for displaying the unit splash when rolling / clicking on a unit in the menu. Returns a scaling vector dependent on the size of the screen and the time until the unit appears. Only usable in the context of unit splash drawing.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
base |
number |
<optional> |
0.175 | The base scale of the unit splash. |
Returns:
The scaling vector.
- Type
- Vec2
hoverOffset(scl, offset)
Used for displaying the unit splash when rolling / clicking on a unit in the menu. Returns a displacement vector that is used to slightly move the unit up and down periodically. Only usable in the context of unit splash drawing.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
scl |
number | 0.65 | The amplitude of the hover effect. |
offset |
number | 0 | The vertical offset of the hover effect. |
importSprite(name, namespace, aliasopt)
Imports a sprite from another mod so that it can be used in the current mod.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
name |
string | The name of the sprite in the source mod. |
||
namespace |
string | The namepace of the mod the sprite is from. |
||
alias |
string |
<optional> |
name | The name the sprite will have in the current mod. |
log(message)
Writes a string to the console.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string | The message to log. |
makeArc(pos, dir, texopt, bouncesopt, lifeopt)
Creates an Arc turret on the playing field that moves across the screen, bounces from walls and leaves a trail of stationary bullets. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the Arc. |
||
dir |
Vec2 | The movement vector of the Arc. |
||
tex |
string |
<optional> |
"arc" | The texture of the Arc. |
bounces |
int |
<optional> |
1 | The maximum number of times the Arc can bounce off of the wall. |
life |
int |
<optional> |
3 | The number of turns until the trail of bullets disappears. |
makeBullet(pos, dir, texopt)
Creates a bullet on the playing field. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the bullet. |
||
dir |
Vec2 | The distance the bullet moves per turn. The bullet can move multiple squares in a direction at once (e.g. with vec2(1, -2)). |
||
tex |
string |
<optional> |
"bullet" | The texture of the bullet. (TODO list of values) |
makeBulletCircle(pos, texopt)
Shoots 8 bullets from a position in all 8 directions.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position to shoot the bullets from. |
||
tex |
string |
<optional> |
"" | The texture of the bullets. |
makeConveyor(pos, dir, lengthopt, texopt, genopt)
Creates a conveyor on the playing field. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the conveyor. |
||
dir |
Vec2 | The distance the conveyor moves per turn. |
||
length |
int |
<optional> |
2 | The number of conveyor belts in a row. Only 1 and 2 work. |
tex |
string |
<optional> |
"conveyor" | The texture of the conveyor. Does not work with a length of 2. |
gen |
int |
<optional> |
0 | Unknown. |
makeCustomEntity(pos, script, lifetimeopt, destructibleopt, damagePlayeropt, deleteOnContactopt) → {CustomEntity}
Creates a custom entity on the playing field. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the entity. |
||
script |
function | The function to run each frame. |
||
lifetime |
int |
<optional> |
-1 | The number of turns the entity will exist. -1 for infinite. |
destructible |
bool |
<optional> |
false | Whether the entity can be destroyed by the player. |
damagePlayer |
bool |
<optional> |
false | Whether the entity damages the player on contact. |
deleteOnContact |
bool |
<optional> |
false | Whether the entity is destroyed on contact with the player. Only works if |
Returns:
The created entity.
- Type
- CustomEntity
makeDelay(delay, callback)
Delays an action by a number of turns. Appears to be slightly bugged. Should only be used in map update scripts.
Parameters:
| Name | Type | Description |
|---|---|---|
delay |
int | The number of turns until the callback is executed minus one. |
callback |
makeDelayCallback | The function to execute after the delay. |
makeDelayBullet(pos, dir, texopt)
Creates a bullet delayed by one turn.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the bullet. |
||
dir |
Vec2 | The distance the bullet moves per turn. |
||
tex |
string |
<optional> |
"" | The texture of the bullet. |
makeDelayBulletWarn(pos, dir, texopt)
Creates a bullet delayed by one turn with an indicator at the position the bullet will appear.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the bullet. |
||
dir |
Vec2 | The distance the bullet moves per turn. |
||
tex |
string |
<optional> |
"" | The texture of the bullet. |
makeLaser(pos, dir)
Creates a Lancer turret on the playing field that shoots a laser across the playing field two turns later.
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
Vec2 | The position where the turret appears. |
dir |
Vec2 | The direction the turret is pointing in. Only cardinal directions with a magnitude of one work (no diagonal lasers). |
makeLaserSegment(pos, dir)
Makes a one tile long laser segment. You should probably use MakeLaser instead. Should only be used in map update scripts.
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
Vec2 | The position of the laser segment. |
dir |
Vec2 | The direction in which the laser points. |
makeRouter(pos, lengthopt, lifeopt, diagopt, texopt, allDiropt)
Creates a router that shoots conveyors. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the router. |
||
length |
int |
<optional> |
2 | The number of conveyors the router creates. Only 1 and 2 work. |
life |
int |
<optional> |
2 | The number of turns until the router disappears. |
diag |
bool |
<optional> |
false | Whether the conveyors are shot diagonally. |
tex |
string |
<optional> |
"router" | The texture of the router. |
allDir |
bool |
<optional> |
false | Whether the conveyors are in all eight directions. |
makeSorter(pos, mdir, moveSpaceopt, spawnSpaceopt, lengthopt)
Creates a sorter on the playing field that shoots conveyors and moves. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the sorter. |
||
mdir |
Vec2 | The movement direction of the sorter. |
||
moveSpace |
int |
<optional> |
2 | The number of turns it takes for the sorter to move one tile. |
spawnSpace |
int |
<optional> |
2 | The delay between conveyor spawns. |
length |
int |
<optional> |
1 | The number of conveyors spawned. Only 1 and 2 work. |
makeTimedBullet(pos, dir, texopt, lifeopt)
Creates a bullet on the playing field that disappears after a set amount of turns. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the bullet. |
||
dir |
Vec2 | The distance the bullet moves per turn. |
||
tex |
string |
<optional> |
"bullet" | The texture of the bullet. |
life |
int |
<optional> |
3 | The number of turns after which the bullet disappears. |
makeTurret(pos, face, reloadopt, lifeopt, texopt)
Creates a turret on the playing field that moves and shoots bullets at the player. Should only be used in map update scripts.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The position of the turret. |
||
face |
Vec2 | The direction the turret is facing. Also the movement vector of the bullets spawned by the turret. |
||
reload |
int |
<optional> |
4 | The number of turns it takes to reload times two. (TODO check source) |
life |
int |
<optional> |
8 | The number of turns until the turret disappears. |
tex |
string |
<optional> |
"duo" | The texture of the turret. |
makeWall(pos, spriteopt, lifeopt, healthopt)
Creates a wall that blocks bullets and conveyors.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos |
Vec2 | The tile where the wall will appear. |
||
sprite |
string |
<optional> |
"wall" | The sprite to use for the wall. |
life |
int |
<optional> |
10 | The time in turns until the wall disappears. |
health |
int |
<optional> |
3 | How many bullets the wall can block before it is destroyed. |
px(x) → {number}
Converts pixels into world units.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
int | The length in pixels. |
Returns:
The length in world units.
- Type
- number
rad(x) → {number}
Converts x from degrees to radians.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | The value to convert. |
Returns:
The value in radians.
- Type
- number
Type Definitions
makeDelayCallback()
Callback for makeDelay.