BreakoutDojo πŸ…

A simple Atari-Breakout clone powered by Dojo Game Engine on StarkNet, deployed with Slots.

0
1

Challenges

Best Gaming dApp on Starknet

Ranked 5,000 $STRK

I never really built a serious game before, so this sounded like something fun to try out! Docs are pretty good for the most part, although there are a few that are outdated. The ai agent was pretty conservative with answering my Cairo questions, but got the job done. Cairo book is great! I've never used Cairo/Dojo before, so there was a rather large learning curve. I don't have a Rust background, so this was especially challenging. Overall, it was a fun challenge, I learned how to build and deploy an end-to-end Dojo game!

Deploy your dApp with Slot

Pool 1,250 $STRK

I wanted to deploy my Dojo game rather than host locally, and this was a great option! I ran into some issues installing slot due to glibc versions, and ran into passkey auth issues when I tried installing in a linux VM. Luckily I figured out a way. Overall though, the deployment of torii and katana itself was quick once I figured out the right commands. Slots made a deployment for my game possible!

Project details

πŸš€ About BreakoutDojo

🌟 Project Overview

A simple Atari-Breakout clone powered by Dojo Game Engine on StarkNet, deployed with Slots.

BreakoutDojo is a provable game that can be played in the browser. It's based on the original Atari Breakout game and uses the Dojo Game Engine to compute the game state completely on-chain. The provable mechanics ensure that all actions, scores, and other game data are verifiable.

πŸ“ˆ Key Features

  • πŸ‹οΈProvable game mechanics: All game states are computed on-chain.

  • Verifiable scoring system: Players can prove their score is correct.

  • Fun gameplay. Come on, this game is a classic!

πŸ“¦ Tech Stack

  • Frontend:

    • React + Vite: Used for building a fast, modern, and interactive user interface.

    • Dojoclient: Easy integration for subscribing to game events, integration with wallets, and sending user actions to the contract.

  • Backend:

    • Dojo Stack: Provable game engine running entirely on StarkNet.

    • Cairo Language: Implements the entire game logic (ball movement, paddle movement, brick collision detection, scoring, etc).

  • Database: On-Chain Storage: All core game data (ball position and velocity, paddle position, bricks, score, etc.).

  • APIs:

πŸ› οΈ How It Works

  1. Works just like the classic Atari breakout game. The objective: Destroy all the bricks on the screen by hitting them with the ball, and bouncing the ball with the paddle

  2. How to play

    1. Connect the wallet

    2. Start playing! Click on Start to begin.

    3. Use the on-screen arrow buttons to move the paddle left or right or stop the paddle.

    4. Try to avoid the ball from hitting the bottom of the screen. If you do, it is game over!

    5. Try to hit as many bricks as you can.

  3. Good luck, have fun!

πŸ“Œ Technicals

  • The Dojo model is a Game object, with a Paddle, Ball, Bricks, and score. Actions include

    1. start: creates a new game

    2. tick: renders the next frame of the game by calculating the new positions and states of the ball, paddle, bricks based on their current velocity and collisions

    3. move_paddle: sets the velocity vector of the paddle

  • On the frontend, the React app hooks up buttons to the actions of the Dojo contract. It uses the Dojo js sdk to subscribe to the Game object change, and render the game objects using plain old html canvas.

βœ… Why Your Submission?

  • 🌍 I believe this is the first provable breakout game running on-chain. I wanted the whole game logic, with rendering objects and collisions, scoring, to be provable (to avoid cheaters haha).

  • I wanted to push the limits of what Dojo engine, Dojo SDK, and Starknet could handle in terms of transactions processed per second. The game runs at 1-3 FPS; attempts to increase this to 10 FPS caused transaction issues based on the SDK. I also encountered transaction size limits, and had to reduce the number of bricks in the game :) I tried a few things to address the mismatched nonce txns like using mutexes, which works to some extent.

πŸ“… Project Future

  • It would be nice to explore how to increase the FPS of the game. I considered using optimistic updates, but it gets wonky when a game running at 60 FPS locally finishes minutes ahead of the on-chain version. Transaction errors could cause the on-chain to reset the game back to a prior state

  • Could add more features to the game itself: more brick types, bullets, coins and powerups.

🀝 Team & Contributions

  • πŸ§‘β€πŸ’»jh3141 : Lead Developer, UI/UX Designer