A browser-based Bomberman 2 (NES) emulator with real-time death detection overlay.
- Runs Bomberman 2 NES in the browser via EmulatorJS
- Detects player deaths in real-time by analyzing the game's pixel output
- Distinguishes between Player 1 and Player 2 deaths using color signatures
- Displays a live overlay indicating which player died
Every frame, the WebGL canvas is read via gl.readPixels() and scaled to the NES native resolution (256×240). The detector matches each 3×3 region against mask1.png (the death-eye sprite). Isolated mask hits are rejected — only pairs of eyes ~4px apart on the same row are accepted, filtering out explosion particle false positives.
Once eyes are found, nearby pixel colors identify the player:
- Player 1 → blue
#3ABEFFfound 3–16px below the eye center, or ≥9 white pixels within 4px of the eye - Player 2 → ≥9 dark red
#de2800pixels within 4px of the eye
On each confirmed death the player's intensity level auto-increments by 5. A 5 second per-player cooldown prevents immediate re-triggers.
| Action | Player 1 | Player 2 |
|---|---|---|
| Move | W A S D | Arrow keys |
| Bomb | Shift | - |
| Alt action | R | / |
| Start | Enter | Enter |
| Select | V | , |
The ESP32 acts as a local HTTP bridge that triggers RF collar commands when a player dies in-game. The browser UI keeps a separate intensity level for each player and can trigger a shared hardware test.
- Open
esp32/WiFi_REST_Shocker.inoin Arduino IDE. - Set
TRANSMITTER_IDat the top of the sketch to match your collars. - Optionally set
WIFI_SSIDandWIFI_PASSWORDif you want one network compiled in. Leaving them blank is supported. - Flash to your ESP32.
- On first boot, the firmware will either connect to a remembered network or start a
Shocker_Configaccess point so you can save Wi-Fi credentials. - Note the IP address printed to the Serial Monitor after boot.
- In the Bomberman site, enter that IP in the right-side panel and enable the shocker if you want automatic shocks on death.
GET /pingGET /statusGET /shock?player=1&intensity=25GET /vibrate?player=1&intensity=25GET /beep?player=1GET /set_level?player=1&level=25GET /adjust_level?player=1&delta=5GET /test_both
- Death detection runs continuously once the emulator canvas is available.
- The overlay shows live P1/P2 alive/dead status with per-player intensity controls.
- Per-player intensity is stored in
localStorageand auto-escalates by +5 on each death. - A debug panel (bottom-right) lets you pick a folder and save frame captures, processed frames, and eye-patch crops on each death.
- The page no longer contacts the ESP32 on load unless you explicitly enable the hardware flow and provide an IP.
Note: the site must be served over HTTP (not HTTPS) from the same local network as the ESP32, e.g.
npx serve .then openhttp://localhost:3000. Browsers block mixed-content fetch from HTTPS pages.
Serve the project from any static file server (the ROM must be loaded over HTTP, not file://):
npx serve .Then open http://localhost:3000 in your browser.
index.html # emulator, detection overlay, and ESP32 control UI
mask1.png # 3×3 death-eye sprite used for mask matching
rom/ # NES ROM file
esp32/ # ESP32 Arduino sketch
WiFi_REST_Shocker.ino