On this page
  1. The canvas forgets everything
  2. A creature is a function
  3. What is actually expensive
  4. Device pixel ratio and crispness
  5. Why procedural art and not sprites
  6. Draw order as a design tool
  7. Drawing a creature with no artwork
  8. Scenes built the same way

The canvas forgets everything

A canvas is a rectangle of pixels with an imperative drawing API. Crucially it keeps no record of what you drew: after you draw a creature, the browser knows some pixels are green and nothing else.

That is why every frame redraws the whole scene from scratch, sixty times a second, in a fixed order: background, scenery, collectibles, enemies, player, effects, in-canvas HUD. It sounds wasteful and it is far cheaper than tracking what changed.

It also means draw order is the layering system. There is no z-index; something appears in front because it was drawn later.

A creature is a function

Every creature in the library is a function that takes a position, a size, an animation phase and an options object, and draws a creature from primitives.

Roughly, a side-view creature is: a shadow ellipse, a tail drawn as a quadratic curve, optional wings, two legs as thick rounded strokes whose angle comes from the phase, a body as a rounded rectangle, a belly highlight, optional back spines, a head circle, optional horns, two eyes with pupils, and a snout.

Roughly thirty drawing calls, parameterised. The same function produces the brown Brumble Beast, the orange Ember Fang and the purple Nix — which is why thirty games look like one library rather than thirty separate projects.

What is actually expensive

OperationCostHow we handle it
Creating a gradientHigh — a new object each callCreated once per frame at most, never per entity
save() / restore()Low individually, adds up at hundreds per frameBatched by draw type
Path buildingModerateReused where the shape is static
Text renderingSurprisingly highOnly for HUD and popups, never per entity
Large fillsProportional to pixelsOff-screen entities culled before drawing
Shadows (ctx.shadowBlur)Very highNever used — glows are radial gradients

The last row matters most. Canvas shadow blur is genuinely expensive, and every glow effect in the library is a radial gradient instead — which looks equivalent at these sizes and costs a fraction as much.

Device pixel ratio and crispness

Every game declares a logical size and works entirely in those coordinates. The canvas's actual pixel buffer is that multiplied by the device pixel ratio, capped at 2.

The cap matters on phones. Rendering at a 3× ratio costs more than twice the pixels of 2× for a difference almost nobody can perceive at arm's length — and those pixels come out of the battery.

CSS then scales the canvas to fit the page while preserving aspect ratio, which is how one coordinate system works on a 320-pixel phone and a 1920-pixel desktop without the game knowing about either.

Why procedural art and not sprites

The honest trade-off: procedural art has a ceiling on detail, and a hand-painted sprite will always look richer close up.

What it buys is size — a game file is a few kilobytes of code rather than hundreds of kilobytes of images — resolution independence, parameterisation, and unambiguous provenance. For a stylised arcade look at arcade speeds, those four outweigh the detail ceiling comfortably.

It also makes changes cheap. Recolouring every creature in the library for a new environment is a parameter, not an art pass.

Draw order as a design tool

Because the canvas has no z-index, draw order is the only layering mechanism — and it is worth using deliberately rather than accidentally.

The order across the library is fixed: background, scenery, collectibles, enemies, player, effects, in-canvas HUD. Two decisions in that list matter.

The player draws after enemies, so your creature is never hidden behind something that is about to hit you. And effects draw after everything, so a particle burst reads as happening in front of the scene rather than inside it — which is what makes feedback feel like a response rather than part of the world.

Drawing a creature with no artwork

Every creature on this site is assembled from primitives at draw time — arcs, rounded rectangles, polygons and gradients — and the approach has consequences beyond file size.

The building blocks are shared: a body blob, eyes, horns, spines, a grin, limbs. A specific creature is a set of parameters over those — size, proportion, colour, how many spines, how wide the grin — which means a new creature is a data change rather than a new asset.

It also means creatures can respond to state continuously. A damaged creature is not a different sprite; it is the same drawing with different parameters, so it can flash, swell, wince or desaturate without anybody drawing a second frame.

The trade-off is a ceiling on visual detail. Procedural shapes cannot match hand-drawn artwork for texture and character, and pretending otherwise would be silly. What they buy is a game that starts in under a second on any hardware, which for a browser arcade site is the better half of the bargain.

Scenes built the same way

Backgrounds are procedural for the same reasons creatures are, and they are assembled from a small set of parts.

A scene is a gradient sky, one or two parallax layers of silhouetted terrain, a ground band, and a scattering of details placed by a seeded noise function. Fifteen named scenes across the library are all variations on those parameters.

The parallax layers scroll at different rates, which is what produces depth from flat shapes. It costs almost nothing — each layer is a handful of filled paths — and it is the single largest contributor to a scene reading as a place rather than as a backdrop.

Key takeaways

  • The canvas keeps no record of what you drew, so draw order is the layering system.
  • Every creature is a parameterised function of about thirty drawing calls.
  • Canvas shadow blur is very expensive and is never used — glows are radial gradients.
  • The backing store is capped at 2× device pixel ratio because the third multiple costs battery for no visible gain.

Frequently asked questions

Why not use sprite images?

Code-drawn art is tiny, resolution independent, parameterised and unambiguously ours. The trade is a ceiling on fine detail, which suits a stylised arcade look.

What is the most expensive drawing operation?

Canvas shadow blur, by a wide margin. We never use it; every glow is a radial gradient instead.

Why is my game sharp on one device and not another?

The backing store scales with device pixel ratio up to 2×. Above that we cap it, because the cost roughly doubles for almost no visible difference.

Why is there no pixel art or hand-drawn artwork?
Because every creature is assembled from canvas primitives at draw time. That costs some visual detail and buys a game that starts in under a second on any hardware, with nothing to download and no third-party assets involved.
How can a creature flash or wince without extra frames?
It is a drawing rather than a sprite, so its parameters can change continuously. A damaged creature is the same shape with different colour and proportion values, not a second image.
Illustrated portrait used for the Monster Arcade editorial byline

Alex Morgan

Browser Games Editor & Interactive Gaming Content Specialist

Alex Morgan is the editorial byline for everything published on Monster Arcade — the design notes behind all 30 original games, the strategy guides, and the tuning decisions that set every difficulty curve on the site. More about our editorial byline.

Published · Last updated