Inspiration

We wanted to bring real hardware into a game and make the experience feel more magical and immersive. That idea led us to combine laser tag with Wii-style motion controls in a game about sword fighting and magic.

What it does

HexDuel is a two-player spell-dueling game. Players connect a 3D-printed sword to our web app over Bluetooth, where a 3D version of the sword moves along with them. To cast one of nine spells, players enter the sequence shown on the battle screen using the sword’s colored buttons, then finish with the requested motion. They fire the spell at their opponent using an infrared laser.

A storybook narrator named Moss guides the adventure and gives players quests from their evil twin (and Gemini API). Players can challenge a friend using a four-digit room code or practice against Swamp Bot.

How we built it

Hardware: Each sword has an ESP32, an MPU6500 motion sensor, four buttons, LEDs, a buzzer, and an infrared transmitter and receiver. The swords connect over Bluetooth LE or USB.

Frontend: We used React and React Three Fiber (Three.js) to build the 3D arena and digital sword. Web Bluetooth and Web Serial connect the app to the swords.

Backend: We used Node.js and Express with WebSockets to manage real-time matches, Postgres on Tiger Data to store game and sensor data, and Auth0 for logins.

AI and voice: Gemini writes the quests, and ElevenLabs gives Moss a voice. Voice commands also let players move through the menus hands-free.

Hosting: We hosted the game on Render and built a Google Cloud Run helper for the Gemini API.

Challenges we ran into

Getting gestures to register reliably took a lot of hands-on tuning of the motion thresholds. Keeping two swords, two laptops, and one shared game state in sync in real time was harder than we expected. We also had to keep testing while one sword was still waiting for its motion sensor.

Accomplishments that we're proud of

We built working physical swords that can cast spells and hit each other with infrared. Around them, we created a complete storybook game with narration, AI-written quests, and online play. All art on the project is originally illustrated except HTML/CSS elements, including animations of Moss, the player model with a sword and without a sword, and the earth exploding (in the video).

What we learned

We learned how to program the ESP32 in C++, read IMU data, connect hardware to a browser over Bluetooth, and keep hardware and game state synchronized over a network.

Tracks

Main Track: Entertainment & Creative Technology

MHL Challenges: Best Domain Name from GoDaddy Registry, Best Use of Gemini API, Best Use of Auth0, Best Use of Tiger Data (Usages explained in video and description)

SwampHacks Specific Challenges: Easy on the Eyes

Built With

Share this project:

Updates

Submission history