Spielerando

Code recipes

Small pieces of tested code and math that games need again and again. Each comes with what it is for, good settings, a text for your AI, the code and its tests.

In a pixel art workshop a beekeeper stirs a pot over a small flame while bees carry an apple and a jar of honey to it and steam rises.
Pixel art, drawn by code

Animation timeline

Puts several moves in a row or side by side and plays them back, with named moments for sounds and effects. Use it for intros, door openings, menus whose parts arrive one by one, and small cutscenes.

Arm and leg reach

You say where the hand or foot should go, and it works out where the elbow or knee goes. Feet stay on stairs, hands reach for ledges, and a robot arm follows the mouse.

Behavior tree

How a computer-controlled character decides what to do: a tree of options in order of importance, checked every frame. Each frame it writes down what it tried and what came of it, so your AI can show you that record as proof of why the guard did what it did.

Bezier curves

Smooth curves you shape with a few handle points, for flight paths, roads, swooping cameras and your own movement curves. Things can travel along them at a steady speed, which plain use of a curve does not give you.

Bouncing and arcs

The math of things that fly: it works out the throw that lands exactly on a target, follows the arc and bounces off walls and floors. A ball bounces the same at any frame rate.

Chance calculator

Exact answers to everyday odds questions: the chance of at least one success in a number of tries, how many tries you need to be fairly sure, how many on average, and how likely a run of bad luck is. The result comes with how it was worked out, so your AI can show you the sum as proof instead of guessing a number.

Compare two versions

You changed something and a number moved, and your AI works out whether that is a real difference or could just be luck, and how many players it would take to find out. It works on counts such as wins and on numbers such as seconds, and it will not call a gap real on too few players.

Day and night colors

A sky and light that change through the day, with soft colours at dawn and dusk, plus a clock to drive them. Colours are mixed the way the eye sees them, so sunset glows instead of turning grey.

Death map

Your AI lays a grid over a level, counts where players died and draws the result as a simple map, sometimes called a heatmap. It tells a real trap from one stubborn player who died there thirty times or a busy spot everyone passes anyway, and each hot spot comes with the numbers behind it.

Dialogue check

Your AI walks every way through a conversation and finds lines nobody will ever hear, talks with no way out, and answers that lead nowhere. It also notices when a player runs out of things to say, because some options can only be picked once.

Difficulty curve

Your AI works out how hard each level really is from what players did, counting each player once, and compares it with how hard you meant it to be. It finds the level that is suddenly much harder than the one before, shows who tried again and who gave up, and says when there are too few players to tell.

Easing functions

The complete set of movement curves that make things start softly, land softly, swing past the end or bounce. Your game stops looking stiff, because nothing moves at one flat speed any more.

Economy check

Your AI adds up what comes into your game's economy, what goes out and what piles up, per hour of play and over a session, and shows where the coins come from and what they are spent on. It also catches money that appears from nowhere, which is usually a bug.

Game event log

Your AI adds a small log to your game that writes down what happens, such as a level started or a player died, in a plain file or in the browser on the player's own device. It keeps no accounts, device ids or IP addresses, sends nothing anywhere, and records nothing until the player says yes.

Grid pathfinding

Finds the shortest route across a grid of tiles, around walls and through the cheapest ground. A character can prefer a road over a swamp, and many enemies can chase one player without slowing the game down.

Hit pause

Stops the game's clock for a split second when a blow lands, which makes hits feel solid. The pause ends cleanly, so the game loses exactly that moment and no more.

Idle sway

Makes a character that stands still look alive: it breathes and sways a little, with no visible loop, and its feet stay on the ground. Two characters never move in step, so a crowd looks like people and not like a copy.

Is it a game yet?

Your AI fills in a game card from the real code of your game: goal, action, resistance, feedback, outcome, and a reason to play again. For each it names the place in the code and a short way for you to see it in the game. The check then walks the game's loop and tells you whether it can be won, lost and never gets stuck, and whether you built extras before the core.

Lerp and smoothstep

The small helpers for blending one number into another: halfway between two values, turning health into a bar, a soft fade near an edge. They are the building blocks behind nearly every smooth effect in a game.

Level-up curve

Works out how much experience each level costs, so early levels come fast and later ones take more work. It handles the sums that are easy to get wrong: several levels at once, the bar between two levels, and the top level.

Line of sight

Answers whether one character can see another, on a tile grid or in open space. It also gives you the whole field of view for fog of war, and a guard's view cone for stealth games.

Markov chain

Randomness with a short memory: what comes next depends on what is happening now, so rainy days come in runs and moods drift instead of jumping. It also invents names that sound like your world.

Monte Carlo simulator

Plays a game rule thousands of times and reports what usually happens, how far results spread, and the worst cases it saw. It is for rules too tangled to work out by hand.

Nested state machine

States inside states: a hero who is alive can be on the ground or in the air, and on the ground can be idle or running. A rule like "can die" is written once on the outer state and works everywhere inside it.

Particle burst

A quick spray of sparks, dust, coins or smoke. Every particle gets its own speed, life and spin, slows down in the air and falls with gravity, and a burst is always well filled.

Pixel art from text

Turns a sprite written as rows of letters into real pixels: one letter is one pixel, and a short list says which letter is which colour. Before it draws anything it reports a row that is too short, a letter with no colour and a frame of another size, each with its row and column.

Pixel rotation

Turns a small sprite to any angle in three ways and counts what each way did to its pixels. One way keeps every pixel, one gives the cleanest outline, and one is what most game engines do, so you can choose with numbers and with your eyes.

Plot hole finder

Your AI writes your story down as plain facts, scenes and rules, then walks every way it can go and tests the rules at every step. It finds out whether a dead character speaks again, whether a player can get stuck, and which scenes nobody ever reaches.

PNG pixels

Reads a PNG file into its real pixels and writes pixels back as a PNG file, with nothing to install. It tells you how big the picture really is and whether its background is truly see-through or only painted to look that way.

Quest order check

Your AI walks every order in which a player can do your quests, and finds out whether each quest can still be finished. If doing one thing first locks a quest out for good, you get the exact moves that cause it, so you have proof you can replay in your own game.

Quest state machine

Keeps track of every quest: what stage it is at, which facts of the game are true, and which quest depends on which. Because quests are written as plain lists, your AI can show you exactly why a quest will not start, and hand you the list of what depends on what as proof.

Real loot odds

Works out the real odds of a loot table that includes a bad-luck counter, exactly and without any random sampling. A counter means the chance you show is not the real one, and this tells you the real one, how many rolls players need and the most anyone can ever need.

Screen shake

Makes hits and explosions feel heavy by shaking the picture. Hits add up and fade away by themselves, and the movement is a smooth wobble, so it shakes instead of flickering.

Second opinion on your story

Turns your story into a file for a separate, long-established checking program, which your AI runs on your own computer with Java. It takes the same facts, scenes and rules as the plot hole finder, so you get a second opinion that shares no code with the first.

Seeded random

Random numbers you can repeat: the same starting number gives the same results on every machine, forever. That is what daily challenges, shareable worlds and replays are built on.

Session pacing

Your AI shows the rhythm of a play session: how long people play, what they spend the time on, where nothing happens for a long while, and what they were doing when they stopped. It also measures how long it takes to reach a moment that matters, such as the first fun bit, and compares all of it with your plan.

Shuffle bag

Fair randomness with no long unlucky streaks: outcomes go into a bag, get shuffled and come out one by one. One win in four then really means one win in every four.

Smooth camera follow

A 2D camera that glides after the player instead of being glued to them. It ignores small steps, looks ahead in the direction of travel, and stops at the edges of the level.

Smooth noise

Random numbers that change gently from place to place instead of jumping. It is the base of natural-looking hills, clouds, caves and wandering movement.

Smooth paths

A smooth curve that passes through every point you give it, walked at a steady speed. Lay out a route with a few points and get a line with no corners.

Spring motion

Makes a value chase its target as if it hung on a spring, fast at first, then slowing, with an optional wobble. You can change the target at any moment and it reacts naturally, and a slow frame never breaks it.

Sprite sheet check

Measures a sheet of animation frames and reports what will go wrong with it in a game: a background that is painted and not see-through, frames that cannot be cut evenly, a figure cut in two, feet that are not on one line, a body that jumps sideways and a loop that jerks. Every finding names the frames and the pixel rows it is about.

Sprite stack

Builds a figure from layers drawn as seen from above and piles them up, so that it looks like the figure seen from a slanted camera. Turn the layers and the same drawings show the figure from any side, in pictures that all have one size and all match.

Squash and stretch

The oldest trick in animation: things stretch when they move fast and squash when they land, while keeping their size. It makes even a plain box feel alive.

State machine

Keeps a character, door or game mode in exactly one state, and lets it change only through moves you listed. A move that is not on the list is refused with a plain reason, so your AI can show you the list and the refusal as proof of what can and cannot happen.

State machine check

Your AI walks through everything a character, door, shop or game mode can do, and finds out whether it can get stuck, whether some state can never happen, and whether your own rules always hold. The report states exactly how far it walked, so it works as proof your AI can show you, with the exact moves that lead to each problem.

Story choice stats

Your AI counts what players really chose in a branching story and which endings they reached, and compares that with the story as you wrote it. It shows choices that are hardly choices because nearly everyone picks the same thing, endings nobody has seen, and picks that are not in your story at all.

Story path check

Your AI walks every way through a story written as scenes and choices, and finds out whether a player can get stuck. It tells you if an ending can never be reached, if a scene is cut off, or if a scene needs something nothing ever gives you.

Twine story check

Reads your Twine story as you saved it, a Twee file or the HTML file Twine makes, and finds links to passages that do not exist, passages no player can reach, dead ends, and variables that are read but never set. Every finding names the passage, and the way a player gets there from the start.

Walk cycle

Works out where the feet, the body and the arms of a walking figure are at each moment of a step, by a rule and not from drawn frames. The cycle follows the distance the figure has moved, so a foot on the ground stays where it stands at any speed.

Weighted random

Picks from a list where some things are more likely than others, such as common gold and a rare crown. It also has a counter that protects players from long runs of bad luck.

Where players drop off

Your AI takes the stops a player should pass, in order, and counts how many got to each one, which some people call a funnel because the list narrows from stop to stop. It names the stop where the most people leave, says how sure that is, and flags anything that does not fit your plan.

Win rate check

Your AI works out how often each weapon, class or side wins and how sure that is given how often it was played, and answers too strong, too weak, fits, or cannot tell yet. It says how many more plays would settle it, and shows how often each option gets picked when it is on offer.