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!
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!
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.
ποΈ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!
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:
Slots: Uses Slots to deploy both Katana (https://api.cartridge.gg/x/breakoutdojo2/katana) and Torii (https://api.cartridge.gg/x/breakoutdojo2/torii) to cartridge.
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
How to play
Connect the wallet
Start playing! Click on Start to begin.
Use the on-screen arrow buttons to move the paddle left or right or stop the paddle.
Try to avoid the ball from hitting the bottom of the screen. If you do, it is game over!
Try to hit as many bricks as you can.
Good luck, have fun!
The Dojo model is a Game object, with a Paddle, Ball, Bricks, and score. Actions include
start: creates a new game
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
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.
π 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.
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.
π§βπ»jh3141 : Lead Developer, UI/UX Designer