# Mega Man X — Highway Assault

A complete keyboard-controlled fan game with original Canvas pixel art and synthesized audio. One 9,000-pixel highway stage leads through a factory climb to the Iron Colossus boss. Checkpoints, unlimited retries, and full-health respawns keep the mission approachable.

## Play locally

Requires Node 22.13+ and npm.

```sh
npm ci
npm run dev
```

Open the Local URL printed by the development server. The game runs entirely in the browser; only the mute preference is stored on this device.

| Action | Keys |
| --- | --- |
| Move | Left / Right arrows or A / D |
| Jump / wall jump | Z or Space; hold for height |
| Shoot | X or J |
| Charge shot | Hold X or J, then release |
| Dash | C or Shift; one air dash before landing |
| Pause / resume | Escape or P |
| Start / retry / replay | Enter |

The in-game field manual explains wall climbing, checkpoints, and boss warnings. Audio starts after a user gesture. Switching windows automatically pauses and clears held keys.

## Architecture

- `game/simulation.ts` and `game/level.ts`: deterministic 60 Hz physics, level, combat, checkpoints, and boss state machine.
- `game/render.ts`: original 384×216 Canvas pixel graphics with camera tracking, parallax, animation, effects, and HUD.
- `game/input.ts` and `game/audio.ts`: keyboard lifecycle and gesture-activated Web Audio.
- `game/GameClient.tsx`: React menus and animation-loop integration.
- Vinext / React / TypeScript with the Sites Vite plugin and Cloudflare-compatible production output.

No ROM, external sprite sheet, music download, account, database, or game service is required.

## Validate

```sh
npm test
npm run typecheck
npm run build
npm run test:render
```

Tests cover physical-key aliases, focus loss, audio lifecycle, movement, collision, jump timing, dash limits, charge levels, health, checkpoint restoration, boss phases, replay, and complete stage traversal. The production render test verifies the game can be served without browser APIs during server rendering.

## Static Apache deployment

`npm run build` exports the complete game to `dist/client/`. This directory
contains `index.html`, browser JavaScript, CSS, the favicon, and its own
`.htaccess`; it can be served directly by Apache without Node running in the
background.

Point the Apache `DocumentRoot` at the exported folder:

```apache
DocumentRoot /var/www/html/megaman_x/dist/client

<Directory /var/www/html/megaman_x/dist/client>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
```

Enable the optional rewrite and header rules once with
`a2enmod rewrite headers deflate`, then reload Apache. For each update, pull the
source and run `npm ci && npm run build`; no application service or open port is
needed.

Sites deployment metadata lives in `.openai/hosting.json`; generated build
output and packaging artifacts are ignored by Git.
