Skip to content

Shiva953/Gorclash

Repository files navigation

Gorclash

A fully on-chain multiplayer arcade mini-game built with Phaser 3, Next.js, React, and GORBAGANA integration. Players compete in real-time to collect tokens, avoid obstacles, and earn on-chain rewards in a fast-paced arena. The game leverages gorbagana testnet for wallet management, in-game rewards, and penalties, providing a unique play-to-earn experience.


How the Game Works

  1. Connect Wallet: Players connect their wallet to participate.
  2. In-Game Wallet: An in-game wallet is created and funded for each player. Fund the in-game wallet with 0.01 GOR to be able to play the game.
  3. Lobby & Matchmaking: Players join a lobby(for which min 0.01 GOR is required) and are matched into a game room.
  4. Arena: The game starts in a scrolling arena with obstacles and tokens.
  5. Controls: Use arrow keys to move your avatar.
  6. Scoring:
    • Collect tokens to increase your score and you get rewarded with 2 GOR for each hit.
    • Hitting obstacles decreases your score and you get penalized with 1 GOR for each hit.
  7. Leaderboard: Scores are displayed in real-time.
  8. End of Round: When time is up, the winner is determined and rewarded on-chain.
  9. Withdrawal: User can withdraw required amount of tokens from the game wallet to their connected wallet address.

Features

  • Every game action is an in-game transaction on the gorbagana testnet
  • Real-time multiplayer arena
  • On-chain rewards and penalties
  • Dynamic obstacles and escalating difficulty
  • Live leaderboard and results

Gorbagana Integration

  • Each player is assigned an in-game wallet (managed via Prisma and Solana).
  • Collecting tokens triggers a in-game gorbagana transaction to reward the player from the global pool.
  • Hitting obstacles triggers a penalty transaction from the player to the global pool.
  • Winners receive on-chain rewards at the end of each round.

Game Program

Here's the program architecture gorclash-program-architecture

Instructions:

  • init_pool: Initializes the global pool for tracking games and holding funds.
  • create_round: Starts a new game round, associating it with the global pool.
  • obstacle_hit: Transfers a penalty from the player to the pool when an obstacle is hit.
  • reward: Sends a reward from the pool to a player (admin only).
  • withdraw: Allows a player to withdraw funds from the game wallet.
  • round_over: Marks a round as finished and records the winner and prize.

You can view the program here.

Tech Stack

  • Frontend: Next.js, React, Phaser 3
  • Backend: Node.js, Socket.IO, Prisma, PostgreSQL
  • Blockchain: Gorbagana, @coral-xyz/anchor, @solana/web3.js, Anchor+Rust for the Program
  • Other: TypeScript, Vite, Sonner (toasts), Prisma ORM

Setup & Installation

Prerequisites

  • Node.js (v18+ recommended)
  • npm or yarn
  • PostgreSQL database
  • Solana CLI (for wallet management)

1. Clone the Repository

git clone <your-repo-url>
cd gorbagana-mini-game

2. Install Dependencies

npm install
# or
yarn install

3. Configure Environment

  • Copy .env.example to .env and fill in your database and Solana credentials.
  • Set up your PostgreSQL database and update prisma/schema.prisma if needed.

4. Run Database Migrations

npx prisma generate
npx prisma migrate deploy

5. Start the Game

npm run dev
  • This will start both the Next.js frontend and the Socket.IO game server.

Running the Game

  • Open your browser and go to http://localhost:3000
  • Connect your Solana wallet.
  • Fund your in-game wallet if prompted.
  • Join a lobby and start playing!


License

This project is licensed under the MIT License. See the LICENSE file for details.


About

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors