tap2d

command
v0.4.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 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

Tap2D Template

Tap2D is a portrait one-touch endless game for phones, browsers and mini-game shells. Tap the arena to move the player to the next lane and keep clear of the moving obstacles. The run has no loading screen between attempts, and the best score is stored with save.Store.

Controls

  • Tap or click anywhere in the arena.
  • Press Space or Enter.
  • Press the south face button on a gamepad.
  • After a run ends, tap, press Space, Enter or the south button, or select Retry to start the next one.

Saving the best score

Tap2D preserves the stored score if the save came from a newer version or cannot be recovered. New scores are tracked for the current session. Update the game to open a newer save.

If a write fails, choose Retry save to write the current best score. Free up space first if the notice says storage is full. Save details lets you copy the slot error, game version and build for support.

Files

  • resources/data/difficulty.yaml is versioned, strict YAML for the starting speed, score ramp, obstacle gap and obstacle width, loaded asynchronously at startup through assets.Manager and assets.LoadingScreen.
  • difficulty.go loads and validates that data with unknown fields refused.
  • run.go contains deterministic, clock-driven run rules that can be tested without a window.
  • game.go binds the run to a fixed-step game.Loop, a touch canvas, a native score HUD and save.Store.
  • notice.go and strings/ show English or Chinese save guidance and copyable details.
  • game_test.go tests score and retry behavior, difficulty ramping, obstacle motion and canvas output.

Debug the game's Go code with Delve (dlv on PATH):

go tool nsgo dev -target native -debug

Attach from VS Code with the Attach to game configuration in .vscode/launch.json, replacing 40000 with the port in Delve's API server listening at line, or from GoLand with a Go Remote configuration at the same host and port.

Run the headless tests with go tool nsgo test ./..., or launch the template with go tool nsgo dev. Replace the procedural rectangles in game.go with the game's art and connect an ad or analytics service at the tapGame hooks when those platform packages are available.

Performance and retry budget

The fixed-step loop is benchmarked without a renderer:

go tool nsgo test -run '^$' -bench '^BenchmarkRunStep$' ./...

The benchmark resets the run at game over, so it includes the same in-memory retry path used by a player. TestRetryIsPlayableOnTheNextFixedFrame advances exactly one 60 Hz step after a game-over tap and verifies that the next tap is playable without a loading screen. Keep the web build small by retaining the procedural art and the single gameplay asset group. Compare the release WebAssembly artifact's size before and after adding a dependency.

Documentation

Overview

Command mygame is a starter 2D game built with NSGo and game.

Jump to

Keyboard shortcuts

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