Game
Volver a la referencia

Game

Starting an instance, the handle a running game exposes, its events, and what the renderer resolved to.

21 símbolos

createGamefunctionnacatamalon

createGame(target: TGameTarget, game_options: TGameOptions) => (scenes: Readonly<Record<string, TSceneFn>>, initialScene?: string) => TGameInstance

Puts a game in the page: a canvas inside target, drawn at width × height.

It is called twice. The first call makes the canvas and returns a function; calling that with the game's scenes starts it, on the first one or on the one named second. A scene is named by its key, which is how useScene().change('Level') finds it later.

Nothing waits. The renderer starts on its own time, so what comes back is the running game at once: on('ready', …) hears when it is up, and on('error', …) why it could not start.

Parámetros

targetTGameTarget

Where the canvas goes: a CSS selector, an element, or null for the page's body.

game_optionsTGameOptions

Its resolution, background, and how it scales to the page. See TGameOptions.

Ejemplo

const Title: TSceneFn = () => createScene();
const Level: TSceneFn = () => createScene();

const game = createGame('#game', {
    width: 320,
    height: 224,
    background: '#000000',
    scaling: 'integer',
})({ Title, Level }, 'Title');

game.on('error', (error) => console.error(error));
Ver el código · game/bootstrap/create_game.ts:90

registerGameSystemfunctionnacatamalon

registerGameSystem(name: string, fn: TGameSystemFn) => () => void

Registers a game system: code that belongs to the whole game rather than to a scene. Music that goes on between levels, keys that work everywhere (M to mute, F for full screen), achievements, the time played, analytics. Each game that starts after this runs fn once, before its first scene, in a box of its own that no change of scene touches, and tears it down when the game ends, its useCleanup with it. Called in main.ts before createGame; a plugin exports an install function that calls it.

It runs whatever scene the game starts on: a level played straight from the editor, a game made with initialScene, a test that starts on the third level. A scene that launches the others would be missing in all three.

In each frame, the systems' useUpdate run before any scene's, and their useLateUpdate after every scene's: a system gets things ready for the scenes and reads where they left them. A paused game pauses its systems as well (useGame().onPaused tells one so); a paused scene does not.

A system belongs to no scene, so the hooks that need one throw inside it (the cameras, the lights, physics, useRenderStyle, useFog): what concerns the whole game is useGame()'s, and what lasts goes in a store. useScene works in it for the scenes it names (launch('Hud'), pause('Level')), and throws for what would be about a scene of its own: change, and the calls with no name. It draws nothing: what it creates is not seen, so something always on screen (a score) is a scene launched beside the levels; launched from its body or its useReady, before the game has a scene, it comes on the first frame the game is shown, over the scene the game starts on, the splash or not. Behind a splash its updates wait, as the scenes' do. One that throws, starting or in a frame, is reported and the game goes on without it.

The same name with the same function does nothing, so an install called twice does nothing when the body is made once, at the top of the module, and not inside the install; the same name with another function throws. Registered while a game is running, it waits for the next game, and says so once. A plugin starts the name with its own ('nacatamalon-saves'), so two never pick the same. While a tool lays the game out rather than playing it (an editor's edit mode), its systems are taken down, and started again, from the ones registered then, when it is played.

Parámetros

namestring

What the system is called: in warnings, and to tell two apart.

fnTGameSystemFn

Its body, run once in each game.

Ejemplo

import { createGame, createScene, registerGameSystem, useAudio, useKeyboard, useUpdate } from 'nacatamalon';

// M mutes the game wherever the player is. The body is made once, here.
const muteKey = () => {
    const keys = useKeyboard();
    const audio = useAudio();
    useUpdate(() => {
        if (keys.justPressed('m')) audio.setVolume(audio.getVolume() > 0 ? 0 : 1);
    });
};

const Level1 = () => createScene();
const Level2 = () => createScene();

registerGameSystem('mute-key', muteKey);
createGame('#app', { width: 320, height: 180 })({ Level1, Level2 });
Ver el código · game_systems/game_systems.ts:144

useGamefunctionhooknacatamalon

useGame() => TGameHandle

The game itself: its size, its background, whether images are kept crisp, how fast time runs, and whether everything is frozen.

These are the settings that belong to the whole game rather than to one scene, and until now they could only be chosen once, when the game was created. This is how a pause menu, an options screen or a boss entrance changes them while it runs.

Call it while the scene is being built, like every hook, and keep what it returns: the handle stays live, so reading it in a frame long afterwards still gives today's answer.

Ejemplo

export const Level: TSceneFn = () => {
    const game = useGame();
    const keys = useKeyboard();

    useUpdate(() => {
        // A pause menu: everything stops, everything is still drawn.
        if (keys.justPressed('Escape')) {
            game.isPaused() ? game.resume() : game.pause();
        }
        // Slow motion while the key is held.
        game.setTimeScale(keys.isDown('Shift') ? 0.25 : 1);
    });

    return createScene();
};
Ver el código · hooks/game/use_game.ts:42

VERSIONvariablenacatamalon

VERSION: string

The engine's version, as a string: what the console prints when a game starts, and what a bug report should quote.

It is read from the package's own package.json, so it is always the version that is running.

Ver el código · version.ts:13

TCanvasAligntypenacatamalon

TCanvasAlign: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'

Where the game sits in its container when the container is bigger than the game: which side the space left over goes to. It never changes the game's size, which scaling decides first; with nothing left over ('fill', or a keep that shows more world instead) there is nothing to place.

  • 'center': in the middle both ways.
  • 'top', 'bottom': against that edge, in the middle across.
  • 'left', 'right': against that edge, in the middle up and down.
  • 'top-left', 'top-right', 'bottom-left', 'bottom-right': in that corner.

The names are in SCREEN.ALIGN too: SCREEN.ALIGN.TOP_LEFT is 'top-left'.

Ver el código · DOM/types/t_canvas_align.ts:17

TCanvasKeeptypenacatamalon

TCanvasKeep: 'both' | 'height' | 'width' | 'none'

Which sides of the resolution stay pinned. Writes the drawing buffer, not CSS: anything but 'both' makes the game see more or less world instead of leaving bars.

  • 'both': the buffer is always width × height. Every player sees exactly the same frame, and space the scale cannot fill stays as letterbox or pillarbox bars. The default, and the only value where a level designer can be sure what is off-screen.
  • 'height': the height is pinned and the width follows the container, so a wide screen sees more world to the sides. What a side-scroller usually wants.
  • 'width': the width is pinned and the height follows, so a tall screen sees more above and below. The vertical-shooter version of the same idea.
  • 'none': nothing pinned. With no fixed side there is no reference to compute a scale from, so it stays at 1× and the buffer becomes the container's size in CSS pixels. Desktop-app behaviour, not game behaviour. On a screen at 125% or 150% a CSS pixel is 1.25 or 1.5 of the screen's, so each game pixel is stretched to that and comes out 1 of them in some columns and 2 in others; for crisp pixel art add pixelRatio: 'device', which draws at the screen's own pixels so nothing is stretched, at the cost of drawing more of them.

Pairs with TCanvasScaling, which is the other axis and decides how big it is drawn.

The names are in SCREEN.KEEP too: SCREEN.KEEP.HEIGHT is 'height'.

Ver el código · DOM/types/t_canvas_keep.ts:27

TCanvasScalingtypenacatamalon

TCanvasScaling: 'none' | 'integer' | 'contain' | 'fill'

How much the game's image is magnified. Writes CSS, never the drawing buffer: the game keeps drawing the same number of pixels, only the size they are painted at changes.

  • 'none': 1×. The canvas is painted at exactly width × height CSS pixels and ignores the space around it. The default, and what a fixed-size embed wants.
  • 'integer': the largest whole multiple that fits (2×, 3×, 4×…), counted in the screen's own pixels. The pixel-art one: every game pixel lands on an exact square block, so nothing is resampled and no row ends up one pixel taller than its neighbour. On a screen at 125% (a density of 1.25) a whole CSS multiple is not a whole one of the screen, so the CSS size comes out with fractions (5.6×, which is 7 of the screen's pixels); on a density of 2 it can be 3.5×. Leaves bars when the fit is not exact. Below 1× there is no whole number to snap to, so it falls back to the exact fit.
  • 'contain': the largest fit, fractions allowed (2.37×). Fills more of the container than 'integer' and keeps the aspect ratio, at the cost of resampling: pixel art shimmers, smooth art does not care.
  • 'fill': stretched to the container on both axes, aspect ratio broken. The only value that ignores keep: the buffer stays at the base resolution and CSS does the distorting. For a background or an effect where the shape does not matter.

Pairs with TCanvasKeep, which is the other axis and decides how much world is drawn.

The names are in SCREEN.SCALING too: SCREEN.SCALING.INTEGER is 'integer'.

Ver el código · DOM/types/t_canvas_scaling.ts:29

TCaptureOptionstypenacatamalon

What a capture is a picture of. Every field left out means what the screen is showing, so capture() with nothing is a picture of the screen.

In the cameras and in layers, leaving a field out and writing null differ, and the difference is the reason a capture has options at all. Left out, it is the screen's: the camera a tool is flying, the kinds it is hiding. null is the game's: each scene's own camera, or none, and every kind. A tool working on the flat half of a level hides the models and looks through a camera of its own, and a picture of the game taken from it has to undo both.

Propiedades

camera3dopcionalTCamera3d | null

The 3D camera to look through. Left out, the screen's: the tool's, or else each scene's own. null, each scene's own.

camera2dopcionalTCamera2d | null

The 2D camera to look through. Left out, the screen's. null, each scene's own, and a scene with none is drawn in screen pixels, which is what that game shows.

widthopcionalnumber

Width of the picture in pixels. Left out, the canvas's.

heightopcionalnumber

Height of the picture in pixels. Left out, the canvas's.

layersopcionalReadonlyArray<indexedAccess> | null

The kinds of drawing to keep. Left out, what the screen keeps; null, all of them.

backgroundopcionalTColorOption

The colour behind everything. Left out, the game's background.

Ver el código · game/capture/types/t_capture_options.ts:20

TConsoleScreentypenacatamalon

TConsoleScreen: Required<Pick<TGameOptions, 'width' | 'height' | 'pixelAspect' | 'step'>>

A console's screen as createGame takes it: how many pixels it drew, their shape and how many pictures a second. Spread into the options, and whatever comes after wins: createGame('#app', { ...SCREEN.CONSOLES.snes, scaling: 'integer' }).

Ver el código · game/console_screens.ts:21

TGameEventstypenacatamalon

What a running game tells the page around it, and what each event carries.

  • ready: the renderer is up and the first scene has run. Carries the game's handle, which is how anything outside a scene (a React HUD, a debug panel) gets to talk to the game.
  • error: the game could not start, most often because the browser has neither WebGPU nor WebGL2, or a scene's update threw once it was running. Carries why, so the page can say so instead of showing an empty box. A game that throws goes on running, so this is heard once, for the first error.
  • destroy: the game has been taken down and its canvas removed.

Propiedades

errorError
destroyvoid
Ver el código · game/types/t_game_events.ts:18

TGameHandletypenacatamalon

What a game can do with itself while it runs: the settings that belong to the whole game rather than to any one scene.

Everything here is live. Read it in a frame, change it from a menu, and the next frame is drawn with the answer.

Propiedades

getWidth
getHeight
setResolution
onResized
getBackground
setBackground
isSmooth
setSmooth
getPixelSnap
setPixelSnap
getPixelAspect
setPixelAspect
getScaling
setScaling
hasContextMenu
setContextMenu
isDebugEnabled
setDebugEnabled
isPostProcessEnabled
setPostProcessEnabled
getTimeScale
setTimeScale
pause
resume
isPaused
onPaused
onResumed
getBackend
getFps
getSceneCount
getDrawableCount
enterFullscreen
exitFullscreen
isFullscreen
releaseAsset
onHidden
isHidden
onShown
onBlurred
onFocused
hasFocus
onLeaving
Ver el código · game/handle/t_game_handle.ts:38

TGameInstancetypenacatamalon

What the second call of createGame returns: the handle to a running game.

destroy - Stops the loop, releases the renderer and the store, and removes the canvas. Safe to call at any time; subsequent calls have no effect.

on - Listens to what the game tells the page around it: 'ready', 'error' and 'destroy'.

Propiedades

destroy
on
Ver el código · game/types/t_game_instance.ts:14

TGameOptionstypenacatamalon

How a game's window is set up, for createGame: its resolution, the colour behind everything, how it scales to the page and which renderer draws it. Only width and height are required.

Propiedades

widthopcionalnumber

The game's resolution: how many pixels it draws, not how big it looks. 320 × 224 stays 320 × 224 however large the canvas ends up on screen: scaling changes the size it is painted at, and keep is the only thing that changes these numbers.

A camera measures in these units, so this is what decides how much of a level fits.

Left out, the style's (RENDER.STYLES.n64 is 320 × 240), and with none 800 × 600. Said, it wins over the style's: { style: RENDER.STYLES.n64, width: 640, height: 480 }. It can change while the game runs with useGame().setResolution.

heightopcionalnumber

See TGameOptions.width: the two are one decision.

backgroundopcionalTColorOption

Colour the frame is cleared to before anything draws. Defaults to darkviolet, deliberately loud: a scene that renders nothing should be obvious, not black.

Read live from the store every frame, so changing it at runtime takes effect on the next one.

rendereropcionalTRendererType

Which backend draws.

  • 'AUTO' (default): tries WebGPU and falls back to WebGL2 if it fails to start.
  • 'WEBGPU': WebGPU or nothing. Throws instead of falling back.
  • 'WEBGL2': WebGL2 or nothing, same rule.

Read in capitals whatever way it is written, so 'webgl2' is 'WEBGL2'; anything else is refused with the names there are.

Naming one is for testing that backend: a silent fallback would hide the very thing being tested. What actually won is capabilities.backend.

msaaopcional1 | 4

MSAA (multisample anti-aliasing) sample count. 1 (default) disables it: the raw, aliased look that suits a PS1/N64 aesthetic. 4 enables 4× MSAA, smoothing jagged geometry silhouettes (e.g. a 3D model's edges). Only 1 and 4 are guaranteed across devices. It smooths edges only, not texture shimmer.

smoothopcionalboolean

Default texture filtering for sprites. false (default) renders them pixelated (nearest) for crisp pixel art; true renders them smooth (linear). Left out, the style's when it has one.

smoothScalingopcionalboolean

Whether the screen is scaled up to the page smoothly, or by whole pixels kept square. Left out, the style's, and with none it follows smooth. Apart from smooth for a game whose pictures are smooth but whose screen is not: the Nintendo 64 blurred its textures, and its 320 x 240 shown big on a page is sharper pixel by pixel than one blurred again by the browser.

pixelSnapopcionalTPixelSnap

Which pixels everything flat is drawn on: where each sprite, text, panel and map is drawn is rounded, never where it is. A character at 1.83 is drawn on a whole pixel, and moves at 1.83 a frame all the same. The scene's camera and the layers with parallax are drawn on the same pixels, a useCamera2d moved by hand as much as useCameraFollow, so the picture does not shimmer as it pans, and a character it follows stays on the same pixel of the screen.

An edge left exactly between two pixels goes back to the one before: a sprite 5 wide held by its middle at x 10 has its edge on 7.5, and is drawn from 7, so its columns start on pixels and WebGPU and WebGL2 draw it the same. Turned, only where it is drawn is rounded. Flat particles follow the same rule, their size made whole pixels too, through the camera of whatever draws them (the screen, or a view); a turned one has its edges on no grid, and only its middle is rounded.

  • 'screen': whole pixels of the screen. With the camera zoomed in to 3, a pixel of the art is three of the screen and stays three wide, and things move a screen pixel at a time: pixel art kept crisp, and slow motion (a far layer, a camera easing in) still smooth.
  • 'game': whole pixels of the game, as the consoles drew. Everything stays on the art's own grid, and something slower than a pixel a frame steps a whole pixel of the art at a time.
  • 'off': between pixels, for a smooth game, where blending them is the point.

Not said, it follows smooth: 'screen' for pixel art, 'off' for a smooth game. At zoom 1 'screen' and 'game' are the same. See RENDER.PIXEL_SNAP for the three as constants.

pixelAspectopcionalnumber

How wide a game pixel is painted against how tall: 1 (default), square; 8 / 7 for the NES and the SNES, which drew 256 across a 4:3 television, so each pixel was a little wider than tall and their games look squashed with square ones; 32 / 35 for the Genesis at 320. Writes CSS only, like scaling: the game still draws width × height, and the camera, where things are, physics and the pointer do not change.

With scaling: 'integer' the rows stay a whole multiple and the columns take that times pixelAspect, with fractions: the television's shape exactly, at the cost of columns a screen pixel apart in width, which a crt() on top hides. 'fill' ignores it. See SCREEN.CONSOLES for each console's size and shape together, and useGame().setPixelAspect to change it while the game runs.

pixelRatioopcionalnumber | 'device'

How many real pixels each game pixel is drawn with. 1 (default) draws exactly width × height; 2 draws four times as many pixels in the same space; 'device' follows the screen's devicePixelRatio (2 on most phones and Retina displays, 3 on some) and keeps following it if the window moves to another monitor.

Only the drawing gets sharper. width and height are still the game's size: a camera, a position, the pointer and getWidth() all keep measuring in them, so nothing in the game changes. What it buys is edges: a 1080 × 720 game on a Retina screen stops being upscaled by the browser, and 3D silhouettes, far textures and thin geometry come out clean.

Leave it at 1 for pixel art. A sprite that is not rotated or scaled looks exactly the same (each texel just becomes a bigger block of real pixels), so it gains nothing; a rotated or scaled one loses the stepped edges of the era and looks like a modern game. And it is not free: the cost of every pass grows with the square of the number, four times the pixels at 2 and nine at 3, which is what 'device' asks of many phones.

Screen effects keep the game's pixel: the resolution a full-screen effect reads is width × height, so a dither or a palette pattern stays the size of a game pixel instead of getting finer.

scalingopcionalTCanvasScaling

How big the game's image is painted. Writes CSS only: the game keeps drawing width × height pixels and only their size on screen changes.

  • 'none' (default): 1×, exactly width × height CSS pixels.
  • 'integer': the largest whole multiple that fits, in the screen's own pixels (on a screen at 125%, 7 of them a game pixel rather than a CSS 3× that is 3.75). The pixel-art one, because nothing is resampled, at the cost of bars when the fit is not exact.
  • 'contain': the largest fit with fractions allowed. Fills more, resamples.
  • 'fill': stretched to the container, aspect ratio broken. Ignores keep.

See TCanvasScaling.

keepopcionalTCanvasKeep

Which sides of the resolution stay fixed. This one writes the buffer: anything but 'both' makes the game see more or less world instead of leaving bars.

  • 'both' (default): always width × height. What makes a game look the same on every screen; the leftover space becomes letterbox or pillarbox bars.
  • 'height': height pinned and width follows the container, so a wide screen sees more to the sides.
  • 'width': width pinned and height follows, so a tall screen sees more above and below.
  • 'none': nothing pinned, so there is no reference to scale from. Stays at 1× and the buffer becomes the container's size. On a screen at 125% or 150% that stretches each game pixel to 1.25 or 1.5 of the screen's, unevenly: pixelRatio: 'device' keeps pixel art crisp there.

See TCanvasKeep.

fullscreenScalingopcionalTCanvasScaling

How the game's image is painted while it is full screen (enterFullscreen on the game handle). Same values as scaling, and only used while full screen lasts: leaving puts scaling back.

'integer' (default) is the pixel-art answer, whole multiples with bars round the edge in the game's background colour. 'contain' fills more of the monitor and resamples to do it.

It is separate from scaling because the two places want different things: a game sitting in the middle of a page at 1× wants the whole monitor once the player asks for it.

alignopcionalTCanvasAlign

Where the game sits in its container when the container is bigger than the game: 'center', 'top', 'bottom', 'left', 'right' or a corner ('top-left'…), also as SCREEN.ALIGN.TOP… It never changes the game's size, which scaling decides first: it only says which side the space left over goes to.

Said here, it wins over the page. A container whose CSS asks for another place, a flexbox or a grid aligned elsewhere, has the game where align says all the same.

Left out, the page decides. A container that lays its content out itself, with flex or grid, has the game where its justify-content and align-items (a grid's justify-items) put it: a flexbox that aligns nothing puts it top-left, as it would anything. A container that does neither, a plain <div>, has it in the middle both ways.

While full screen it is always the middle: the container is then the whole monitor.

Either way it lands on whole pixels of the screen, so the pixels stay crisp.

stepopcionalTGameStep

How the game's time moves forward. Default 'display'.

  • 'display': one update per picture the screen shows, by however long it really took. A 144 Hz monitor runs 144 updates a second and a 60 Hz one runs 60; * delta keeps the speed the same, but not the result: a jump worked out with gravity reaches a slightly different height on each, and a move written without delta is faster on the better screen.
  • A number, 60 (NTSC) or 50 (PAL): the game moves in steps of exactly 1 / step seconds, as the consoles of the era did, whatever the screen. delta is always that, so x += 2 is two pixels a frame on every machine, a jump is the same height everywhere, and the same keys on the same steps play the same game. A faster screen shows some steps twice; a machine that falls behind runs up to four steps before drawing, and past that the game slows down rather than jumping ahead, the way an overloaded console did.

With a number, timeScale changes how many steps a second are run, never how long each one is: slow motion moves in whole steps, and stays exact. The input of a picture with no step in it waits for the next step, so a press is never lost nor seen twice.

pauseOnBluropcionalboolean

Freeze the loop while nobody can see the page, and unfreeze on the way back. true by default.

It exists because requestAnimationFrame stops in a hidden tab anyway: without this, the first frame back gets a delta of however long the player was away, and everything moving teleports. Pausing makes that gap explicit instead of letting it reach the game.

The page being hidden pauses the game the way a pause menu does, with the reason 'browser', so useGame().onPaused and onResumed are told it. Coming back releases only that hold, so a game paused from a menu stays paused; it resumes one frame after the page is seen again, so the frame that measured the time away is not run. Its sound is held with it: every sound and song stops where it is and carries on from there when the page is back, as a console's did when it was paused. false leaves the game to the browser, which stops sending frames to a hidden tab anyway.

seedopcionalnumber

Initial seed for this game's random generator (useRandom). Absent means a different run every time; set it to make a run reproducible: same seed, same sequence.

actionsopcionalTActionMap

The game's input map: named actions ('jump', 'move_left') and the keys, gamepad buttons and stick directions each one listens to, read with useActions.

The same list a project.json carries, which is where it comes from once there is an editor.

actionsPersistopcionalTActionPersist

Where the player's own rebindings are kept, so they are still there next time. Left out, the controls are whatever the game says every run.

contextMenuopcionalboolean

Whether a right click over the game opens the browser's menu. false (default): the game keeps the right button for itself, as it does in a window of its own. Only over the game: the rest of the page keeps its menu. true for a game in a page that wants "save image". Changed while it runs with useGame().setContextMenu().

debugopcionalboolean

Draws over the game what it is made of and does not show: colliders of every kind, hitboxes, the tiles that stop things, rays. false (default). Changed while it runs with useGame().setDebugEnabled(), which is how a key that shows it is written.

physicsLayersopcionalstring[]

Names for the physics layers, in order: the first is layer 0. With them a body says layer: 'enemy' and collidesWith: ['world', 'player'] rather than numbers. Sixteen at most.

postopcionalTPostChain

The full-screen effects this game is shown through, in order.

A game setting rather than a scene's, because "this looks like a Mega Drive" is a fact about the game and not about whichever room happens to be open: a scene that had to declare the palette again would be a scene that can forget to.

Nothing is waited for. The effects go in at once and each starts working the moment its own file lands, so a slow palette costs you the palette and never the first seconds of the game.

styleopcionalTRenderStyle

The style every scene is drawn in unless it asks for its own (useRenderStyle): how the models' materials are drawn when they do not say, and the effects the game is seen through, after the ones in post, and the resolution and smoothing the game is drawn with when width, height and smooth are left out. One of RENDER.STYLES (nes, snes, genesis, gameBoy, gba, ps1, saturn, n64, dreamcast, cgi) or one of the game's own. Left out, none: each material is drawn as it says.

banneropcionalboolean

Print the startup line in the console: the engine, its version and which backend started. true by default.

On by default because the backend is the first question asked of any drawing bug, and the line answers it in one screenshot. A shipped game that wants a clean console turns it off.

splashopcionalboolean | 'always'

Open with "Made with NacatamalOn": the N grows in, the name slides in beside it, and the game starts. Off unless asked for.

  • true shows it in the published game and skips it while you develop: on localhost (and 127.0.0.1, ::1, .local names) and in a browser driven by automation (Playwright, Puppeteer, Selenium), so neither a reload nor a test ever waits for it.
  • 'always' shows it there too, to see it while working on the game.
  • false, or leaving it out, never shows it.

It costs the game no time, and changes nothing in it. The game starts behind it as it would without one: its first scene is built and loads its files, the level and the HUD that scene launches are launched, its scene changes are made, covered ones too. It only waits there, neither updated, drawn nor clicked, its sounds set to start on their own (autoplay) held back, until the splash is over and its files have arrived, and then the splash fades off it; so on a game with a lot to load it is the loading screen. It lasts under two seconds, and a key or a click ends it. It never shows when a tool drives the game (editorHandleOf).

Ver el código · game/types/t_game_options.ts:39

TGameSteptypenacatamalon

TGameStep: 'display' | number

How a game's time moves forward: 'display', one update per picture the screen shows, or a number of fixed steps a second (60, 50). See TGameOptions.step.

Ver el código · game/types/t_game_options.ts:18

TGameSystemFntypenacatamalon

TGameSystemFn: () => void

What a game system is: a body run once in each game that starts, with that game and a box of its own active, so every hook that lives in a box or in the game works inside it (useUpdate, useLateUpdate, useCleanup, useReady, useGame, useTimer, useTween, the input, the stores). It returns nothing: it is no scene, and builds none.

Ver el código · game_systems/game_systems.ts:22

TPixelSnaptypenacatamalon

TPixelSnap: 'screen' | 'game' | 'off'

Which pixels a game draws on: 'screen', whole pixels of the screen; 'game', whole pixels of the game, as the consoles drew; 'off', between them. See TGameOptions.pixelSnap, and RENDER.PIXEL_SNAP for the three as constants.

Ver el código · game/types/t_game_options.ts:29