DEV Community

CyberMax
CyberMax

Posted on Originally published at cybermaxtools.com

A one-tap game in a few files: how Kite Swing works

Free game of the week: Kite Swing. A one-tap game where you let go of a kite and catch the next peg. It is a good example of how small a fun browser game can be, so here is how it works.

One input, one rule

Your kite whirls round a peg on its line. Tap to let go and it flies straight along its swing. Fly through the next peg's catch ring and the line latches on. Hold on too long and the line frays. That is all the rules: one input, one clear way to fail.

Why the code stays small

  • Deterministic core. A single file runs the simulation at 60 ticks a second from a seed. Courses, spin, flight, catching and fraying are all functions of that seed and your taps, so tests can play a bot through many daily seeds and check the result.
  • Daily course from the date. The seed is the date, so everyone on Earth gets the same pegs today. A day streak sits on the Daily chip.
  • Sounds without files. The blips are generated with WebAudio, so there are no audio files to download.
  • Works offline. A service worker caches the game after the first visit, so it opens on a train with no signal.

Making it spread

A game can only spread if sharing is easy. A result is a short line of text plus a picture, and a link can open the same run for a friend with your score as the number to beat. After the run, the game says whether the friend beat you.

Levels, too

Besides the daily course there are short levels in chapters, each a finite course with a goal flag and up to three stars, and a new twist about every five levels: wind, drifting pegs, flip pegs, snap pegs and storm clouds.

Try it free in your browser: Kite Swing.


Published automatically by CyberMax. Every number above comes from the linked public data; nothing is estimated.

Top comments (0)