Skip to content
bunlonghengPublic

About

Math Hero - pick a hero and race the clock through addition, subtraction, multiplication and division across 5 difficulty tiers. A comic-book math game for kids.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Math Hero

Math Hero

A comic-book math game for kids: pick a hero, race the clock across 4 operations and 5 tiers

Live · Repo · Portfolio

Math Hero - preview

Math Hero

Pick a hero and race the clock through math.

Addition, subtraction, multiplication, and division across 5 difficulty tiers, wrapped in a comic-book hero theme built for kids.

CI Next.js TypeScript License: MIT

Play it live -> math-hero-bheng.vercel.app

Math Hero - pick one of 12 illustrated heroes

Features

  • 12 illustrated heroes - each with its own color, element, and treasure icon; pick one to start.
  • 4 operations x 5 difficulty tiers - addition, subtraction, multiplication, division, with the number range scaling per tier.
  • Beat the clock - a per-question countdown; run out of time and the answer is revealed.
  • Learn from every answer - a wrong pick or a timeout reveals the correct answer before moving on.
  • Persistence - your operation, difficulty, and sound settings plus a best score per mode are saved between sessions.

Math Hero game screen - a hero, a timed question, and four answer choices

Tech stack

Area Choice
Framework Next.js 16 (App Router)
Language TypeScript (strict)
Styling CSS Modules + next/font (self-hosted Playpen Sans)
Images next/image (self-hosted hero art)
Effects canvas-confetti, Web Audio
Tests node:test (pure logic) + Playwright (e2e)
Hosting Vercel

How it works

flowchart LR
  A[Browser] -->|static, client-only| B["components/Game.tsx"]
  B -->|"buildRun(hero, op, difficulty)"| C["lib/gameEngine.ts<br/>pure reducer"]
  C -->|"generateRun (injectable rng)"| D["lib/math.ts<br/>question generator"]
  B --> E["lib/settings.ts<br/>localStorage"]
Loading

The quiz is a pure state machine: all randomness lives in the buildRun / generateRun factories (an injectable rng), so gameReducer is a pure, fully unit-tested function of (state, action).

Getting started

npm install
npm run dev

Open http://localhost:3026.

Scripts

Script Does
npm run dev Dev server on port 3026
npm run build Production build
npm run typecheck tsc --noEmit (app + tests)
npm run lint ESLint
npm test Unit tests (math + engine + settings)
npm run e2e Playwright end-to-end tests (builds + serves on 3034)

License

MIT (c) 2026 Bunlong Heng


Built by Bunlong Heng · See it in my portfolio →

About

Math Hero - pick a hero and race the clock through addition, subtraction, multiplication and division across 5 difficulty tiers. A comic-book math game for kids.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages