Skip to content

labsensacional/electric-bomberman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Electric Bomberman

A browser-based Bomberman 2 (NES) emulator with real-time death detection overlay.

Features

  • 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

How it works

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 #3ABEFF found 3–16px below the eye center, or ≥9 white pixels within 4px of the eye
  • Player 2 → ≥9 dark red #de2800 pixels 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.

Controls

Action Player 1 Player 2
Move W A S D Arrow keys
Bomb Shift -
Alt action R /
Start Enter Enter
Select V ,

ESP32 Shocker (optional)

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.

Setup

  1. Open esp32/WiFi_REST_Shocker.ino in Arduino IDE.
  2. Set TRANSMITTER_ID at the top of the sketch to match your collars.
  3. Optionally set WIFI_SSID and WIFI_PASSWORD if you want one network compiled in. Leaving them blank is supported.
  4. Flash to your ESP32.
  5. On first boot, the firmware will either connect to a remembered network or start a Shocker_Config access point so you can save Wi-Fi credentials.
  6. Note the IP address printed to the Serial Monitor after boot.
  7. In the Bomberman site, enter that IP in the right-side panel and enable the shocker if you want automatic shocks on death.

Firmware API

  • GET /ping
  • GET /status
  • GET /shock?player=1&intensity=25
  • GET /vibrate?player=1&intensity=25
  • GET /beep?player=1
  • GET /set_level?player=1&level=25
  • GET /adjust_level?player=1&delta=5
  • GET /test_both

Browser behavior

  • 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 localStorage and 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 open http://localhost:3000. Browsers block mixed-content fetch from HTTPS pages.

Running locally

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.

Project structure

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

About

Every time your player dies you receive an electroshock. Made using basic computer vision.

Resources

Stars

Watchers

Forks

Contributors