2048

command
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

2048

A 2048 game built with the Onix module system and HTML/CSS UI, with no external assets. The example uses the engine repository's Go module and a 540 × 850 logical viewport that scales while preserving its aspect ratio.

From the engine repository root, enter the example directory and run:

cd examples/2048
go run .
  • Use the arrow keys, WASD, on-screen direction buttons, or swipe across the board to move tiles.
  • Matching tiles merge, adding the merged value to the score. Each tile can merge only once per move.
  • Each valid move spawns a 2 (90% chance) or a 4 (10% chance). Moves that leave the board unchanged do not spawn tiles.
  • Press Z or click the undo button to restore the previous board, score, and random state. One level of undo is available.
  • Press R or click the new-game button to restart. The session's best score survives restarts and resets when the application exits.
  • After reaching 2048, click the continue button or press Enter to keep playing. When no moves remain, undo the last move or start a new game.

Project data and HTML live under resources/. Game state, merge rules, and input handling live under resources/game/. Fixed-size arrays hold the board, line buffers, and undo snapshot. Movement logic performs no heap allocations, and the UI reuses DOM handles to update text and attributes.

From the engine repository root, validate the project, regenerate registration code, and run the targeted tests:

go run ./editor/cmd/onix check ./examples/2048
go run ./editor/cmd/onix generate ./examples/2048
go test ./examples/2048 ./examples/2048/resources/game

Visual acceptance is manual, following the repository guidelines.

Documentation

Overview

Code generated by Onix; DO NOT EDIT.

Directories

Path Synopsis
resources

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL