There are a few things that Excalibur does that are good to know before you start building games!
Conventions
-
Excalibur uses a theater metaphor, for example: Scenes, Actors, and Actions.
-
Excalibur uses Resources to load external files like images and sounds. They can also be used to load other things like data or config.
-
The negative y direction is up, and the positive y direction is down.
-
Distance units are in pixels, velocity in pixels per second, and acceleration in pixels per second per second.
-
Rotation units are in radians.
-
All elapsed times and durations in Excalibur are in milliseconds.
-
Actor z-indices follow the browser way of doing things.
- Things with larger positive numbers are on top of lower numbers.
-
Coordinate Spaces
- World space is the pixel position where Entities and Actors live by default.
- Screen space is the pixels on the canvas element viewport according to the browser.
- Page space is pixel offset from the top left of browser window
- Local space is relative to a parent Entity or Actor
-
Things are in "world" space unless specified with a
localprefix or added as a child actor. -
Bounds are always an axis aligned bounding box, meaning a non-rotated box.
-
Excalibur handles offscreen draw culling for you! No need to manage that!
-
Excalibur uses pre-multiplied alphas when drawing which is important to know if you use Material
API Naming
- Boolean properties describing what an object is or has are named
isX/hasX, read-only or settable:actor.isKilled,engine.isRunning,graphics.isVisible,tile.isSolid. Options use the same name:new Actor({ isVisible: false }). Test: if "the object is ___" is a natural sentence, useisX. - Booleans that name a behavior to perform, or mirror a web platform property, keep their plain name:
sound.loop,sound.muted,graphics.smoothing,flipHorizontal. Text formatting attributes follow CSS and typography vocabulary (font.bold,font.family), and common computer jargon likeenabledis also left as is. - Anything that has a side effect or does real work is a verb method:
engine.start(),contact.cancel(),input.setEnabled(false). - Async state is a Promise property, never
isX():await engine.ready,await track.done. The synchronous check isengine.isReady. - Compound words are spelled consistently:
offscreenis one word, matchingOffscreenCanvas(isOffscreen,OffscreenSystem), while "on screen" splits in camelCase (isOnScreen,forceOnScreen,onScreenOnly). The acronym staysHiDPI(isHiDPI).