Make a 2D game
There are two routes. A browser game is ordinary HTML, JavaScript and canvas that Hexaliz runs and inspects. A native game uses the Hexaliz runtime with an orthographic camera.
Which route
- Browser game: best for sprite-heavy 2D games, any JavaScript library or framework, and games you want to host on the web. The game stays a plain web project that runs without Hexaliz.
- Native game: Python gameplay scripts, physics and the native renderer, and a standalone build of the game that runs without the editor. The world is 3D with Z up; a 2D game keeps everything on the Z = 0 plane and looks at it with an orthographic camera.
Browser game (web template)
- Create the project.
webis a dependency-free canvas game;web-viteadds a Vite dev server for TypeScript and frameworks.shellhexaliz project init --path ~/games/dodge --template web - Open the folder in Hexaliz (File → Open Folder). Game Mode runs the page in its preview; edit the files and reload.
- Make the art in Image Mode or with an AI agent, then import it into the project so the game references it by a project path.
With an AI agent, ask it to read the bundled guide first: hexaliz skill initiate-web-game-dev (over MCP it isproject get_skill with name="initiate-web-game-dev"). It covers the edit, reload, input and capture loop in an isolated browser session, optional window.hexalizTest hooks for testing, and where generated assets go.
To share a browser game, serve the project folder from any static web server, or upload it to a web host. For a quick local test:python -m http.server 0 --bind 127.0.0.1 in the game folder, then open the URL it prints.
Native game (orthographic camera)
- File → New Project with Game + system stubs, or
hexaliz project init --path ~/games/dodge --template game. - Select the camera in the scene tree and set its projection to Orthographic in the inspector, or write it in
assets/scenes/scene.toml:Keepassets/scenes/scene.toml[[entities]] id = "main_camera" name = "Main Camera" [entities.components.Transform] position = [0.0, 0.0, 10.0] # above the XY play plane rotation = [0.0, 0.0, 0.0, 1.0] # looks straight down; screen up is +Y scale = [1.0, 1.0, 1.0] [entities.components.Camera] is_active = true [entities.components.Camera.projection.Orthographic] left = -8.0 right = 8.0 bottom = -4.5 top = 4.5 near = 0.1 far = 1000.0right − lefttotop − bottomat your window’s aspect ratio (16 by 9 above), so the picture is not stretched. - Build the level from boxes and meshes on the XY plane (Z = 0). Give the player entity the tag
Player. - Add controls in
assets/input/actions.input.tomland pointproject.tomlat them with[input] actions = "assets/input/actions.input.toml":assets/input/actions.input.tomlschema_version = 1 kind = "hexaliz.input" [actions.move] type = "axis2d" keyboard = [{ up = "KeyW", down = "KeyS", left = "KeyA", right = "KeyD" }] - Move the player in
scripts/main.py; scripts reload while the game runs:scripts/main.pyimport engine.input as controls from engine import Query, system from engine.components import Transform SPEED = 6.0 @system def move_player(world, input, dt): x, y = controls.axis2d(input, "move") for e, xf in Query(Transform, tag="Player"): xf.position.x += SPEED * x * dt xf.position.y += SPEED * y * dt - Press Play. When it works, build a standalone game with the toolbar’s Build Game, or
hexaliz runtime build_game --op start --project-path ~/games/dodge.
2D art in the native runtime
The native renderer draws meshes, not world sprites. Use flat boxes or planes with an image material for characters and tiles, and the HUD (*.ui.toml, which does draw image sprites) for menus, scores and icons. For a sprite-first game, the browser route is the simpler choice today.
With an AI agent
Connect your IDE first (Connect your AI IDE). Then the agent can create the project, generate and import art, play the game in its own session and check it, with the bundled guides: initiate-web-game-dev for browser games and build-game-scene for native ones (see Bundled guides).