A hackable template for creating small and fast browser games


Goodluck is great for:

Show me the code!

Here's what a typical system looks like in Goodluck:

const QUERY = Has.LocalTransform2D | Has.Shake;

export
function sys_shake2d(game: Game, delta: number) {
    for (let entity = 0; entity < game.World.Signature.length; entity++) {
        if ((game.World.Signature[entity] & QUERY) == QUERY) {
            // The entity has the LocalTransform2D and Shake components.

            let shake = game.World.Shake[entity];
            let local = game.World.LocalTransform2D[entity];

            local.Translation[0] = (Math.random() - 0.5) * shake.Radius * 2;
            local.Translation[1] = (Math.random() - 0.5) * shake.Radius * 2;

            // Tag the entity as dirty so that sys_transform2d applies the new translation.
            game.World.Signature[entity] |= Has.Dirty;
        }
    }
}

Features

Goodluck is a template for creating small browser games which fit in a few kilobytes. It's designed for extreme hackability. The codebase is small and simple; it's mostly just ifs and fors. The code is easy to understand and modify.

Getting Started

Goodluck is not a typical library. You don't install it via npm install. Instead, use it as a template: generate a new repository from it, remove features you don't need, and hack away. Consult the README to learn more.


Documentation

What is Goodluck?

A high-level overview of what makes Goodluck special. It also includes an honest list of reasons why you might want to consider other solutions.

Why is Goodluck the way it is?

A list of questions you might be asking yourself with regards to Goodluck's design choices.

API Reference

The annotated source code of Goodluck's core components, systems, and utilities.

Tutorials

js13kBreakout (2022)

Part of the js13kBreakouts project.

Castle Peskenstein (2020)

A Twitter thread with a step-by-step account of creating a Wolfenstein3D clone.

Breakout (2020)

Support material from a workshop on gamedev. Follow the commits on the tutorial branch.


Starter Templates

Good defaults with most of Goodluck's components and systems.

Platformer2D 7.0KB w/o tile sprites src

Run ./bootstrap.sh Platformer2D and remove anything you don't need to trim the size even further

NewProject3D 11.2KB src

Run ./bootstrap.sh NewProject3D and remove anything you don't need to trim the size even further


Examples

All examples are WebGL2. The reported sizes are minified, Roadrolled, and zipped.

Animate 8.2KB src
DeferredShading 10.0KB src
FirstPerson 7.3KB src
FollowCamera 13.3KB src
ForwardShading 10.7KB w/o textures src
Instancing 5.0KB src
Monkey 16.1KB src
PathFinding 11.1KB src
RigidBody 10.1KB src
TodoApp 2.3KB src
WebXR 9.3KB src

Games Made With Goodluck

Backcountry
Time Is Money
Oh No! All The Textures Are 404!
ROAR
Mirrorisk
ESCAPE
You Are The Snooze Button
Super Simple Salad Simulator
Afterlife

Other

Social Distancing
Chain Reaction
Breakout
Hej