Riah Studio Home

Free cheat sheet

Make browser games feel right: 34 concepts, each with a prompt line you can paste

Every concept here has a working demo you can poke, and a prompt line with real numbers you can paste straight into your AI coding agent.

We build browser games with AI agents. The difference between a game that feels stiff and one that feels good is usually a handful of small, named tricks, and an agent does them well once you name them and give it numbers. This page is that list: what each trick is in plain words, the line we would type, and the mistake we see most.

34 concepts · 7 for 2D · 5 for 3D · 22 for both · updated 2026-11-16

Movement that feels good

Coyote time 2D

A short grace period after you run off a ledge where jumping still works, because players press jump a hair late and expect it to count.

Prompt line

Add coyote time: keep a timer that starts at 100 ms when the player leaves the ground and allow a normal jump while it is above 0; reset it to 0 the moment a jump starts so it can't double-jump.

Common mistake: Not clearing the timer when the jump starts, which quietly gives every player a free double jump.

A runner leaves a ledge and presses jump 70 ms late; with coyote time on it clears the gap, with it off it falls.
A runner leaves a ledge and presses jump 70 ms late; with coyote time on it clears the gap, with it off it falls.

Jump buffering 2D

Remembering a jump press for a moment before landing, so pressing a little early still jumps as soon as feet touch the ground.

Prompt line

Add a jump buffer: when jump is pressed in the air, store a 120 ms timer; on landing, if the timer is above 0, jump immediately and clear it.

Common mistake: Buffering for 300 ms or more, which makes the character jump when the player has already changed their mind.

A hopper presses jump 90 ms before landing; with the buffer it bounces straight up again, without it the press is lost.
A hopper presses jump 90 ms before landing; with the buffer it bounces straight up again, without it the press is lost.

Variable jump height 2D

Letting a quick tap make a small hop and a held button make a full jump, by cutting upward speed when the button is released.

Prompt line

Make jump height depend on hold time: launch at 9 m/s upward, and if the jump button is released while still rising, multiply vertical speed by 0.45 once.

Common mistake: Cutting speed every frame the button is up instead of once, which makes falls feel sticky and jumps feel random.

Two jumpers side by side: one taps, one holds, and they reach very different heights from the same launch speed.
Two jumpers side by side: one taps, one holds, and they reach very different heights from the same launch speed.

Acceleration and friction 2D & 3D

Speeding up and slowing down over a few frames instead of snapping to full speed, which gives movement weight.

Prompt line

Replace instant movement with acceleration: max speed 6 m/s, reach it in 0.12 s on the ground and 0.25 s in the air, and stop from full speed in 0.08 s when input is released; when input points against the current velocity, brake at that 0.08 s rate first, then accelerate the new way.

Common mistake: Using the same slow acceleration for turning around, which makes the character feel like it is skating on ice.

A square moves back and forth; toggle between instant speed and eased speed to feel the difference in weight.
A square moves back and forth; toggle between instant speed and eased speed to feel the difference in weight.

Fixing fast diagonal movement 2D & 3D

Pressing two directions at once adds two full-speed vectors, so diagonal movement ends up about 41% faster unless you scale it back.

Prompt line

Normalize the movement input vector before multiplying by speed, so moving diagonally at 5 units/s is exactly as fast as moving straight; keep analog stick values below 1 as they are.

Common mistake: Normalizing analog stick input too, which kills the slow walk players get from a half-pushed stick.

Two dots race to a corner, one moving straight and one diagonally; without the fix the diagonal one wins every time.
Two dots race to a corner, one moving straight and one diagonally; without the fix the diagonal one wins every time.

Invincibility after a hit 2D & 3D

A short window after taking damage where the player can't be hit again, shown by blinking, so one mistake doesn't cost three hearts.

Prompt line

After the player takes damage, make them immune for 1.0 s and blink the sprite every 80 ms; ignore further hits during that window but still let them collide with walls.

Common mistake: Turning off all collision during the window, so players fall through floors or walk through doors they shouldn't.

A ship drifts through a stream of hazards; with the immune window it loses one heart per touch, without it a single touch drains the bar.
A ship drifts through a stream of hazards; with the immune window it loses one heart per touch, without it a single touch drains the bar.

Juice: making hits land

Hit stop 2D & 3D

Freezing the game for a few frames when a big hit connects, so the impact reads as heavy.

Prompt line

On a strong hit, pause gameplay updates for 70 ms (about 4 frames at 60 fps) while still drawing; scale it to 40 ms for light hits and never stack pauses longer than 120 ms.

Common mistake: Freezing the input reading too, so presses made during the pause are dropped and controls feel unresponsive.

A hammer strikes a block on a loop; toggle the 70 ms freeze on and off and the hit goes from tap to thud.
A hammer strikes a block on a loop; toggle the 70 ms freeze on and off and the hit goes from tap to thud.

Screen shake that fades 2D & 3D

Shaking the camera by an amount that grows with impact and fades away smoothly, instead of a fixed jitter.

Prompt line

Add camera shake with a trauma value from 0 to 1: hits add 0.3, trauma decays by 1.5 per second, and shake offset is trauma squared times 12 px using smooth noise rather than fresh random numbers each frame.

Common mistake: Picking a new random offset every frame, which looks like a glitch instead of a shake.

Click or press a key to add trauma; the shake builds with repeated hits and settles on its own.
Click or press a key to add trauma; the shake builds with repeated hits and settles on its own.

Squash and stretch 2D & 3D

Briefly flattening an object when it lands and stretching it when it launches, keeping its area about the same, so it feels soft and alive.

Prompt line

On landing, scale the sprite to 1.25 wide by 0.8 tall and ease back to 1:1 over 150 ms; on jump, use 0.85 wide by 1.2 tall; anchor the scale at the feet so it doesn't float.

Common mistake: Scaling from the center, which makes the sprite sink into the floor or hover above it.

A ball bounces with and without squash and stretch; with it the bounce feels rubbery, without it it feels like a coin.
A ball bounces with and without squash and stretch; with it the bounce feels rubbery, without it it feels like a coin.

Easing curves 2D & 3D

A curve that shapes how a value moves from start to end over time, so menus and pickups glide instead of moving at one flat speed.

Prompt line

Animate UI panels with ease-out cubic over 220 ms when they open and ease-in cubic over 160 ms when they close; use linear only for things that really move at constant speed, like conveyor belts.

Common mistake: Using ease-in for things that appear, which makes the screen feel slow to respond right when the player is waiting.

Four dots travel the same distance in the same time using linear, ease-in, ease-out and ease-in-out.
Four dots travel the same distance in the same time using linear, ease-in, ease-out and ease-in-out.

Particle bursts 2D & 3D

A spray of tiny short-lived bits on impact, pickup or explosion that sells the moment without new art.

Prompt line

On enemy death, spawn 24 particles with random direction, speed 80 to 220 px/s, gravity 400 px/s², a life of 0.4 to 0.7 s, and shrink and fade them to zero over their life.

Common mistake: Giving every particle the same speed and life, which makes the burst look like a stamped circle.

Each pop throws a burst; toggle between uniform particles and randomized ones to see why variety matters.
Each pop throws a burst; toggle between uniform particles and randomized ones to see why variety matters.

Health bar damage trail 2D & 3D

A second, lighter bar behind the health bar that drains a moment later, so players can see how much a hit just took.

Prompt line

Give health bars a trailing layer: the main bar drops instantly on damage, the trail waits 400 ms, then catches up at 60% of max health per second.

Common mistake: Animating the main bar slowly instead, which makes the player's real health unclear in a tight moment.

A bar takes hits on a timer; the pale trail lingers and then catches up so each hit's size is readable.
A bar takes hits on a timer; the pale trail lingers and then catches up so each hit's size is readable.

Time and the game loop

Fixed timestep 2D & 3D

Running game physics in equal small steps, no matter how fast or uneven the screen refreshes, so jumps reach the same height on every machine.

Prompt line

Run physics at a fixed 60 Hz step with an accumulator: add the real frame time, step in 1/60 s chunks while the accumulator holds enough, cap catch-up at 5 steps per frame, and draw with the leftover fraction to interpolate.

Common mistake: Not capping catch-up steps, so one slow frame makes the game try to catch up forever and lock up.

Two balls bounce through the same uneven, stuttering frames; the one on raw frame time drifts, the fixed-step one bounces the same every time.
Two balls bounce through the same uneven, stuttering frames; the one on raw frame time drifts, the fixed-step one bounces the same every time.

Smoothing that ignores frame rate 2D & 3D

The common trick of moving a fraction of the way to a target each frame behaves differently at 30 and 144 fps unless the fraction accounts for time.

Prompt line

Replace lerp(a, b, 0.1) per frame with lerp(a, b, 1 - exp(-10 * dt)), so a follower closes about 63% of the gap every 0.1 s at any frame rate.

Common mistake: Multiplying the fraction by dt, which is close but overshoots on long frames and still drifts between machines.

Two followers chase the same target, one updated 20 times a second and one 60; with the fix they move together, without it they split.
Two followers chase the same target, one updated 20 times a second and one 60; with the fix they move together, without it they split.

Object pooling 2D & 3D

Reusing a fixed set of bullets, particles or enemies instead of creating and throwing away new ones, which avoids hitches from memory cleanup.

Prompt line

Pool bullets: allocate 256 up front, mark them active or idle, take an idle one on fire and return it on hit or after 2 s off screen; if the pool is empty, recycle the oldest active bullet.

Common mistake: Forgetting to reset every field when an object is reused, so a recycled bullet keeps the last one's speed or color.

A turret fires from a pool of 24 slots shown as a strip; each slot lights up while in use and goes dark when it returns.
A turret fires from a pool of 24 slots shown as a strip; each slot lights up while in use and goes dark when it returns.

Cameras and layers

Camera with a deadzone 2D

A camera that lets the player move inside a small box before it follows, then follows smoothly, so small steps don't jiggle the whole screen.

Prompt line

Make the camera follow the player only when they leave a deadzone 80 px wide and 50 px tall at screen center, then move toward them with frame-rate-independent smoothing at a rate of 6 per second.

Common mistake: Following the player exactly every frame, which turns every little wobble into the whole world shaking.

A wandering dot and its camera frame; the box shows the deadzone, and the view only moves when the dot pushes on its edge.
A wandering dot and its camera frame; the box shows the deadzone, and the view only moves when the dot pushes on its edge.

Parallax layers 2D

Scrolling far background layers slower than near ones, which fakes depth in a flat game.

Prompt line

Add four background layers scrolling at 0.1, 0.3, 0.6 and 1.0 times camera speed, with each layer's image tiling horizontally so the loop seam never shows.

Common mistake: Moving the foreground faster than 1.0 without meaning to, which makes players misjudge where solid ground is.

A landscape scrolls by in layers; toggle parallax off and the same art flattens into one wall.
A landscape scrolls by in layers; toggle parallax off and the same art flattens into one wall.

Collision and space

Box overlap checks 2D

Checking whether two upright rectangles touch by comparing their edges, the cheapest collision test there is.

Prompt line

Use axis-aligned box collision: two boxes overlap when a.x < b.x + b.w and a.x + a.w > b.x and the same holds on y; resolve by pushing out along the axis with the smaller overlap.

Common mistake: Moving both axes and then resolving once, which snags the player on the seams between floor tiles.

Drag or arrow-key a box across others; touching boxes light up and show the overlap amount.
Drag or arrow-key a box across others; touching boxes light up and show the overlap amount.

Circles that push apart 2D & 3D

Treating crowds, coins or units as circles and nudging overlapping ones apart, which stops them stacking into a single blob.

Prompt line

Separate overlapping circles: when the distance between centers is less than the sum of radii, move each one half the overlap along the line between them, and run 3 passes per frame for crowds.

Common mistake: Fixing only one pair per frame, so big crowds jitter and never settle.

A crowd of circles pours toward the center; with separation they pack neatly, without it they pile on one spot.
A crowd of circles pours toward the center; with separation they pack neatly, without it they pile on one spot.

Grid for nearby checks 2D & 3D

Sorting objects into grid cells so each one only checks its neighbors for collisions instead of every other object in the game.

Prompt line

Add a spatial hash with 64 px cells: rebuild it each frame, and test each object only against objects in its own cell and the 8 around it.

Common mistake: Making cells much smaller than the objects, so each one lands in many cells and the savings vanish.

Many dots drift around; the counter shows pair checks with and without the grid, and the cells near the highlighted dot glow.
Many dots drift around; the counter shows pair checks with and without the grid, and the cells near the highlighted dot glow.

Line of sight 2D & 3D

Casting a straight line from an enemy to the player and checking if a wall gets in the way, so enemies only react to what they could see.

Prompt line

Give guards line of sight: cast a ray from guard to player up to 300 px, stop at the first wall it crosses, and only switch to chase if the ray reaches the player within a 90° view cone.

Common mistake: Checking every frame for every guard against every wall, which is fine at 5 guards and stalls at 50; check 5 times a second instead.

A guard sweeps its view cone around walls; the ray turns pink when it reaches the target and stops at the wall when it doesn't.
A guard sweeps its view cone around walls; the ray turns pink when it reaches the target and stops at the wall when it doesn't.

Draw order by height on screen 2D

In top-down games, drawing things lower on the screen last so a character walks in front of a tree when below it and behind it when above.

Prompt line

Sort all world sprites by the y of their feet each frame before drawing, ties broken by x, and keep the floor and UI on their own layers outside the sort.

Common mistake: Sorting by the sprite's top edge or center, which makes tall things like trees pop in front of the player too early.

A walker circles a tree; toggle sorting off and it paints over the trunk from the wrong side.
A walker circles a tree; toggle sorting off and it paints over the trunk from the wrong side.

Enemies that seem to think

Pathfinding with A* 2D & 3D

Finding a short route through a maze by always trying the most promising next step first, guessing the remaining distance as it goes.

Prompt line

Implement A* on the tile grid with 4-way moves, cost 1 per step, Manhattan distance as the guess, and cap the search at 2000 visited tiles; recompute a path at most every 0.5 s per enemy.

Common mistake: Recomputing paths every frame for every enemy, which is the usual cause of a game slowing down only when enemies appear.

A path threads a maze toward a target; tap or press a key to move the target and watch the searched tiles fill in.
A path threads a maze toward a target; tap or press a key to move the target and watch the searched tiles fill in.

Seek and arrive 2D & 3D

Steering toward a target by turning velocity a little each frame, and slowing down inside a radius so the follower parks instead of orbiting.

Prompt line

Steer followers with seek and arrive: desired velocity points at the target at 180 px/s, scaled down linearly inside a 90 px slow radius; steer by at most 400 px/s² per frame toward the desired velocity.

Common mistake: Skipping the slow radius, so followers overshoot and circle the target forever.

A follower chases a moving point; toggle arrive off and it overshoots and loops around the target.
A follower chases a moving point; toggle arrive off and it overshoots and loops around the target.

Flocking 2D & 3D

Making a group move like birds or fish with three small rules per member: steer away from crowding, match neighbors' heading, and drift toward the group's center.

Prompt line

Add flocking to 60 agents with a 40 px neighbor radius: separation weight 1.5 within 18 px, alignment 1.0, cohesion 0.8, max speed 90 px/s; use the spatial grid for neighbor lookups.

Common mistake: Weighting cohesion higher than separation, which collapses the flock into a single dot.

A flock wheels around the canvas; toggle between all three rules and separation alone to see what each adds.
A flock wheels around the canvas; toggle between all three rules and separation alone to see what each adds.

Enemy states 2D & 3D

Giving each enemy a small set of named moods, like patrol, chase and return, with clear rules for switching, so behavior stays readable and easy to fix.

Prompt line

Give the enemy a state machine with patrol, chase and return: chase when the player comes within 140 px, give up only once they're beyond 200 px for 2 s (the gap stops flicker), then return, and patrol between 2 points otherwise; show the current state as a label in debug builds.

Common mistake: Switching states every frame at a boundary, which makes enemies flicker between two moods; add a gap, like chase at 140 px and give up at 200.

An enemy patrols, spots a wanderer, chases, loses it and walks home, with its current state printed above it.
An enemy patrols, spots a wanderer, chases, loses it and walks home, with its current state printed above it.

Randomness you can trust

Seeded random 2D & 3D

A random number generator that gives the same sequence every time from the same starting number, so levels, replays and daily challenges repeat exactly.

Prompt line

Use a seeded generator (a 32-bit mulberry-style function) for all level generation, take the seed from the UTC date as YYYYMMDD for the daily run so every player gets the same one, and never call the built-in random for anything gameplay touches.

Common mistake: Using the seeded generator for gameplay and the built-in one for a single enemy spawn, which breaks every replay from that point on.

Islands generate from a seed shown on screen; step the seed forward and back and the same seed always rebuilds the same map.
Islands generate from a seed shown on screen; step the seed forward and back and the same seed always rebuilds the same map.

Smooth noise terrain 2D & 3D

Random values that change gradually from place to place, layered at a few sizes, which gives hills and caves instead of static.

Prompt line

Generate terrain height from smooth noise at 3 layers: scale 1/120 at weight 1.0, 1/40 at 0.4 and 1/12 at 0.15, then map the sum to 0 to 1 and treat values below 0.35 as water.

Common mistake: Using a single layer of noise, which gives blobby, samey hills with no small detail.

A strip of terrain scrolls by built from layered noise; add or remove layers to see detail appear.
A strip of terrain scrolls by built from layered noise; add or remove layers to see detail appear.

Loot tables with weights 2D & 3D

Picking drops by giving each item a weight, so common things show up often and rare things rarely, and it's easy to tune later.

Prompt line

Make a weighted loot table: common 70, uncommon 22, rare 7, legendary 1; pick by rolling 0 to the total and walking the list; guarantee a rare if the last 40 drops had none.

Common mistake: Stacking several percent rolls in a row (10% then 5% then 1%), which gives odds nobody on the team can actually work out.

Chests open on a loop and the bar chart fills toward the 70/22/7/1 weights as the counts grow.
Chests open on a loop and the bar chart fills toward the 70/22/7/1 weights as the counts grow.

3D basics

Field of view 3D

How wide the camera sees, which sets how big distant things look and how fast the world seems to rush by.

Prompt line

Set the camera's vertical field of view to 60° for third-person and 75° for first-person, keep it fixed when the window changes shape so wide screens see more to the sides, and offer a 60 to 100° slider.

Common mistake: Using a narrow field of view on a wide monitor in first person, which is a fast route to motion sickness.

A wireframe corridor seen at a narrow, a medium and a wide field of view; the same scene stretches or squeezes.
A wireframe corridor seen at a narrow, a medium and a wide field of view; the same scene stretches or squeezes.

Skipping what the camera can't see 3D

Not drawing objects outside the camera's view cone, which saves time on every frame for nothing the player would notice.

Prompt line

Cull objects outside the camera's view: give each object a bounding sphere, skip drawing any sphere fully outside the 6 view planes, and log how many were drawn per frame in debug.

Common mistake: Culling against the object's center point instead of its bounds, so big objects vanish while their edges are still on screen.

A top-down map of a turning camera's view cone; objects inside are drawn, objects outside go grey, and the count updates live.
A top-down map of a turning camera's view cone; objects inside are drawn, objects outside go grey, and the count updates live.

Level of detail 3D

Swapping a detailed model for simpler versions as it gets farther away, since nobody can see the detail at a distance anyway.

Prompt line

Give trees 3 detail levels: full mesh under 30 m, a half-poly mesh to 80 m, a flat camera-facing card beyond that; switch with a 5 m overlap so they don't flicker at the edge.

Common mistake: No overlap between levels, so objects right at the switch distance flicker between two versions.

Shapes march toward and away from the camera, trading points for detail as they get closer.
Shapes march toward and away from the camera, trading points for detail as they get closer.

Camera that doesn't clip through walls 3D

A third-person camera on an invisible arm that shortens when a wall gets between it and the player, then slides back out.

Prompt line

Put the third-person camera on a 4 m arm behind the player, cast a sphere of radius 0.3 m along it each frame, pull the camera in to just before any hit instantly, and ease it back out at 3 m/s.

Common mistake: Easing the camera in as slowly as it eases out, so for half a second the player sees the inside of a wall.

A side view of a walker and its camera arm; the arm snaps short when a pillar passes between them and slides back after.
A side view of a walker and its camera arm; the arm snaps short when a pillar passes between them and slides back after.

Distance fog 3D

Fading far things toward the sky color, which hides where the world stops drawing and gives a sense of scale.

Prompt line

Add linear fog from 40 m to 120 m blending into the exact sky color, and set the camera's far draw distance to 125 m so objects fade out fully before they're cut off.

Common mistake: Using a fog color that doesn't match the sky, which leaves a visible band where the world ends.

Rows of posts recede into the distance; toggle fog to see far posts fade into the sky instead of popping.
Rows of posts recede into the distance; toggle fog to see far posts fade into the sky instead of popping.