Constants
Volver a la referencia

Constants

What a game reads and never changes, on the root in groups: the renderers, input names, limits, presets and what the engine carries by kind.

8 símbolos

BUILTINvariablenacatamalon

BUILTIN: { FONTS, MUSIC, SOUNDS, LOOKS, PALETTES }

What the engine carries, asked for by name, by kind.

  • FONTS: the fonts a text can name, 'nacatamalon:arcade' first, the one it uses when it names none.
  • MUSIC.SONGS: the songs, useLoadSong({ src: 'nacatamalon:' + key }). MUSIC.INSTRUMENTS and MUSIC.SAMPLES: what a song's notes play with @name, and what its sample voices play.
  • SOUNDS: the kinds of sound effect renderSfx makes.
  • LOOKS: the looks a material can take.
  • PALETTES: the colours of the machines that had a fixed list of them, nes, gameBoy and c64, as #rrggbb: for getColor, snapToPalette or a palette of rows. For paletteMatch, useLoadPalette({ src: 'nacatamalon:nes' }).

Propiedades

FONTStypeOperator
MUSIC{ SONGS, INSTRUMENTS, SAMPLES }
SOUNDStypeOperator
LOOKStypeOperator
PALETTESReadonly<Record<TConsolePaletteName, typeOperator>>

Ejemplo

const song = useLoadSong({ src: `nacatamalon:${BUILTIN.MUSIC.SONGS[0].key}` });
createText({ text: 'READY', font: BUILTIN.FONTS[2] });
const dusk = getColor(BUILTIN.PALETTES.nes[19]);
Ver el código · CONST.ts:258

INPUTvariablenacatamalon

INPUT: { GAMEPAD_BUTTONS, GAMEPAD_AXES, POINTER_BUTTONS, DEADZONE, ACTION_PRESS }

The names input is read by, and the numbers it starts from.

  • GAMEPAD_BUTTONS and GAMEPAD_AXES: what a standard pad's buttons and sticks are called, in order, and GAMEPAD_BUTTON_LABELS / GAMEPAD_AXIS_LABELS how a controls screen shows them.
  • POINTER_BUTTONS: main, middle, right, back and forward.
  • DEADZONE: how far a stick or a trigger moves before it counts, the pad's and an action's, when nothing says. ACTION_PRESS: how far it moves before an action counts as pressed.
  • ACTION_PRESETS: input maps ready to use, so a game does not write its sixteen bindings by hand. By console, nes, genesis, snes and arcade, whose actions are its buttons (a, b, start; button1 to button6 and coin on an arcade), and by kind of game, platformer (jump, action, pause). Every one has up, down, left and right on the arrows, WASD, the d-pad and the left stick; a console's buttons sit on the pad where they sat on its own.

Propiedades

GAMEPAD_BUTTONStypeOperator
GAMEPAD_AXEStypeOperator
POINTER_BUTTONStypeOperator
DEADZONEnumber
ACTION_PRESSnumber

Ejemplo

for (const button of INPUT.GAMEPAD_BUTTONS) {
    if (pad.pressed(button)) console.log(INPUT.GAMEPAD_BUTTON_LABELS[button]);
}

createGame('#app', { actions: INPUT.ACTION_PRESETS.genesis });
// and actions of its own, after:
createGame('#app', { actions: [...INPUT.ACTION_PRESETS.nes, { name: 'dash', bindings: [{ type: 'key', key: 'c' }] }] });
Ver el código · CONST.ts:165

LIMITSvariablenacatamalon

LIMITS: { LIGHTS, SCENE_LIGHTS, PALETTE_COLORS }

How far the engine goes, fixed by what it draws and simulates with: a game cannot raise them.

  • LIGHTS: how many lights shine on one thing drawn, eight, as the consoles of the era had: each model is lit by the eight that reach it most. An ambient light does not count.
  • SCENE_LIGHTS: how many a scene holds at a time, thirty-two, which each model takes its eight from. Past them they are dropped with a warning.
  • PHYSICS_LAYERS: how many collision layers a scene has, sixteen, the most both physics backends can tell apart.
  • PALETTE_COLORS: as many colours as a palette may hold, 256.

Propiedades

LIGHTSnumber
SCENE_LIGHTSnumber
PALETTE_COLORSnumber
Ver el código · CONST.ts:191

PHYSICSvariablenacatamalon

PHYSICS: { … }

Values physics is written with. ALL_LAYERS is every layer at once, what a collider hits unless it says otherwise.

Ejemplo

usePhysicsBody2d({ body: 'dynamic', collider, collidesWith: PHYSICS.ALL_LAYERS });
Ver el código · CONST.ts:209

RENDERvariablenacatamalon

RENDER: { TYPE, PIXEL_SNAP }

How the engine draws: the renderers createGame can be asked for, which pixels it draws on, and how many numbers one corner of a line takes.

TYPE.WEBGL2 is the same as writing 'WEBGL2' in createGame({ renderer }). PIXEL_SNAP.SCREEN, GAME and OFF are what createGame({ pixelSnap }) and useGame().setPixelSnap take. LINE_VERTEX_FLOATS is seven, where a corner is (x, y, z) and its colour (r, g, b, a), for a game that writes the corners of its lines itself.

Propiedades

TYPE{ AUTO, WEBGPU, WEBGL2 }
PIXEL_SNAP{ SCREEN, GAME, OFF }

Ejemplo

createGame({ renderer: RENDER.TYPE.WEBGL2, pixelSnap: RENDER.PIXEL_SNAP.GAME });
Ver el código · CONST.ts:76

SCREENvariablenacatamalon

SCREEN: { CONSOLES, SCALING, KEEP, ALIGN }

The game's screen: what shape it is, and how it sits in its page.

  • CONSOLES: each console's screen, its size, the shape of its pixels (pixelAspect) and its pictures a second, to spread into createGame: nes, snes, genesis, gameBoy, gba, ps1 and n64.
  • SCALING: how big it is painted in its page, what createGame({ scaling }), fullscreenScaling and useGame().setScaling take: NONE, INTEGER, CONTAIN or FILL.
  • KEEP: which sides keep the game's size when the page is another shape, createGame({ keep }): BOTH, WIDTH, HEIGHT or NONE.
  • ALIGN: where createGame({ align }) puts it in its container: CENTER, a side (TOP, BOTTOM, LEFT, RIGHT) or a corner (TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT).

Propiedades

CONSOLESReadonly<Record<TConsoleScreenName, Required<Pick<TGameOptions, 'height' | 'width' | 'pixelAspect' | 'step'>>>>
SCALING{ NONE, INTEGER, CONTAIN, FILL }
KEEP{ BOTH, WIDTH, HEIGHT, NONE }
ALIGN{ CENTER, TOP, BOTTOM, LEFT, RIGHT, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }

Ejemplo

createGame('#app', { ...SCREEN.CONSOLES.snes, scaling: SCREEN.SCALING.INTEGER });
createGame('#app', { width: 320, height: 180, align: SCREEN.ALIGN.TOP });
Ver el código · CONST.ts:111

nacatamalon/effects

POST_EFFECTSvariablenacatamalon/effects

POST_EFFECTS: { NAMES }

The post effects: the ones the engine carries, and starting points for them.

  • NAMES: the post effects a project names in its post list.
  • CRT_PRESETS: four tubes for crt(). consumer is the television in the living room, pvm a studio monitor, arcade a cabinet, composite a cheap cable.
  • COLOR_LEVELS: how many steps a channel had on each machine, for dither() and posterize().

Propiedades

NAMEStypeOperator

Ejemplo

usePostProcess(crt(POST_EFFECTS.CRT_PRESETS.pvm));
usePostProcess(crt({ ...POST_EFFECTS.CRT_PRESETS.consumer, noise: 0 }));
usePostProcess(posterize({ levels: POST_EFFECTS.COLOR_LEVELS.genesis }));
Ver el código · CONST.ts:230

nacatamalon/files

DOCUMENTSvariablenacatamalon/files

DOCUMENTS: { SCENE, MOTION, STORE, TILEMAP, PALETTE, ATLAS, PARTICLES, SONG, SHADER_GRAPH }

What the engine's documents say they are, field by field: FORMAT is what a file's format holds and VERSION its version, for a tool or a game that writes one by hand. The engine's own serialize… and the editor write them already.

Some documents name themselves and count their versions apart (a scene is format: 'nacatamalon-scene', version: 1); the rest have only format, and it is the version. A version goes up when a document written today would be misread by an older engine. A scene claiming a higher one than this engine's is loaded anyway and warned about once.

Propiedades

SCENE{ FORMAT, VERSION }
MOTION{ FORMAT, VERSION }
STORE{ FORMAT, VERSION }
TILEMAP{ FORMAT }
PALETTE{ FORMAT }
ATLAS{ FORMAT }
PARTICLES{ FORMAT }
SONG{ FORMAT }
SHADER_GRAPH{ FORMAT }

Ejemplo

const palette = { format: DOCUMENTS.PALETTE.FORMAT, kind: 'palette', name: 'Dusk', colors: ['#102030'] };
const isScene = (file: { format?: unknown }) => file.format === DOCUMENTS.SCENE.FORMAT;
Ver el código · CONST.ts:288