Skip to content

Latest commit

ย 

History

History
149 lines (120 loc) ยท 4.85 KB

File metadata and controls

149 lines (120 loc) ยท 4.85 KB

๐Ÿ† Stark Brawl - Offline Wave-Based Shooter with Blockchain on Starknet and Dojo

๐Ÿ”ฅ Stark Brawl is an offline shooter where players face waves of enemies, using NFT characters on Starknet. The game integrates Dojo, an on-chain game engine in Cairo, allowing game mechanics to be managed in a decentralized way while remaining a fully local experience.


๐Ÿ“Œ Features

  • Offline gameplay with no multiplayer or online requirements.
  • Wave-based enemies with increasing difficulty.
  • Starknet integration for NFT character ownership.
  • Cairo + Dojo contracts to store player progression on-chain.
  • Reward system with tokens for surviving more waves.
  • 2D graphics with PixiJS/Phaser.js.
  • Web3 wallet connection (Argent X, Braavos).

โš™๏ธ Technologies Used

Component Technology
Frontend React + Vite + TypeScript
Graphics PixiJS or Phaser.js
Blockchain Starknet + Cairo + Dojo
Local State localStorage + IndexedDB
Contracts Starknet.js + Dojo

๐Ÿ›  Installation and Setup

๐Ÿ“‹ Prerequisites

Ensure you have the following installed:

  • Node.js (>= 16.x)
  • npm or yarn
  • Starknet Wallet Extension (Argent X or Braavos)
  • Dojo CLI (to compile Cairo contracts)

Install Dojo:

curl -L https://install.dojoengine.org | bash

Initializes the project and installs dependencies

๐Ÿ“ฅ Clone the Repository
  git clone https://github.com/youruser/stark-brawl.git
  cd stark-brawl
๐Ÿ“ฆ Install Dependencies
    npm install
   # or
    yarn install
๐Ÿš€ Run the Project
    npm run dev
   # or
   yarn dev
   Open http://localhost:3000/ in your browser to play.

๐Ÿ”— Blockchain Implementation with Dojo This project uses Dojo to handle on-chain game logic on Starknet. The Cairo contracts store:

Ownership of characters as NFTs. Player progression (waves survived, rewards earned). Token system for upgrades and skins.

๐Ÿ“œ Deploying Contracts with Dojo ๐Ÿ—๏ธ Compile Cairo Contracts cd contract dojo build

๐Ÿš€ Deploy to Starknet Testnet dojo deploy --network testnet

๐Ÿ”— Connect the Frontend to the Contracts Update contract addresses in client/src/blockchain/config.ts: export const CONTRACT_ADDRESS = "0xYOUR_CONTRACT"; export const NETWORK = "testnet";

๐ŸŽฎ How to Play Log in with your Starknet wallet. Select your NFT character. Survive waves of enemies and earn token rewards. Use tokens to upgrade skills or buy NFT skins.

๐Ÿ“œ Project Structure
stark-brawl/
โ”‚โ”€โ”€ client/                 # Frontend (React + Vite)
โ”‚   โ”œโ”€โ”€ public/             # Static assets (images, sounds, etc.)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ assets/         # Game assets (sprites, animations, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # UI Components (buttons, HUD, menus)
โ”‚   โ”‚   โ”œโ”€โ”€ game/           # Game logic (PixiJS/Phaser.js)
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/          # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ blockchain/     # Starknet smart contract interactions
โ”‚   โ”‚   โ”œโ”€โ”€ utils/          # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ styles/         # Global styles
โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx         # Main React App
โ”‚   โ”‚   โ”œโ”€โ”€ main.tsx        # React root rendering
โ”‚   โ”‚   โ”œโ”€โ”€ config.ts       # Game configuration settings
โ”‚   โ”œโ”€โ”€ index.html          # Main HTML file
โ”‚   โ”œโ”€โ”€ vite.config.ts      # Vite configuration
โ”‚   โ”œโ”€โ”€ package.json        # Project dependencies
โ”‚   โ”œโ”€โ”€ tsconfig.json       # TypeScript configuration
โ”‚โ”€โ”€ contract/               # Smart Contracts (Cairo + Dojo)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # Dojo components (NFTs, Tokens, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ systems/        # Game logic in Cairo
โ”‚   โ”‚   โ”œโ”€โ”€ resources/      # Game state management
โ”‚   โ”œโ”€โ”€ manifest.yaml       # Dojo contract manifest
โ”‚   โ”œโ”€โ”€ Scarb.toml          # Scarb package manager config
โ”‚   โ”œโ”€โ”€ Makefile            # Automation scripts
โ”‚โ”€โ”€ .gitignore              # Git ignored files
โ”‚โ”€โ”€ README.md               # Project documentation
โ”‚โ”€โ”€ LICENSE                 # License file

Sozo Commands for Running a Project in Dojo with Cairo

# Initialize Dojo
sozo init

# Build the project
sozo build

# Run migrations (optional)
sozo migrate

# Start the project locally
sozo start

# Run tests
sozo test

# Clean previous builds
sozo clean

# Display help and available commands
sozo help

๐Ÿค Contributions If you want to contribute, fork the repository, create a new branch with your changes, and submit a pull request. git checkout -b my-new-feature git commit -m "Added new feature" git push origin my-new-feature

All contributions are welcome! ๐Ÿš€