A hackable template for creating small and fast browser games
Goodluck is great for:
Learning game programming and game design.
Prototyping gameplay ideas.
Building size-constrained games.
Experimenting with algorithms and APIs.
Modeling problems through animated simulations
Show me the code!
Here's what a typical system looks like in Goodluck:
constQUERY = Has.LocalTransform2D | Has.Shake;
exportfunctionsys_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.
A tiny core with an expressive and fast ECS implementation, which keeps the data (components) separate from the logic (systems).
2D rendering pipeline using WebGL's instancing, resulting in very good performance (tens of thousands of sprites).
3D rendering pipeline supporting Gouraud and Phong shading with gamma-corrected directional and point lights; diffuse, specular, and normal texture mapping; real-time shadows; forward and deferred rendering, both with a post-processing step; instanced rendering, and more.
A versatile toolkit of useful systems for movement, animation, collisions, particles, entity life cycle (spawn, autodestruct), UI, mouse, keyboard, touch and gamepad input, etc.
Capable of great performance, even on older mobile devices.
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.