|
| 1 | +# 🎮 Blockrooms: Backrooms inspired FPS onchain |
| 2 | + |
| 3 | +## 📘 Contents |
| 4 | + |
| 5 | +- 🔗 [Our Stack](#our-stack) |
| 6 | +- 🔗 [Game Logic](#game-logic) |
| 7 | + |
| 8 | +# Our-Stack |
| 9 | + |
| 10 | +> A high-level breakdown of the technologies powering **BlockRooms** — from 3D graphics and frontend architecture to fully on-chain gameplay mechanics. |
| 11 | +
|
| 12 | +--- |
| 13 | + |
| 14 | +## 🎮 Frontend Stack |
| 15 | + |
| 16 | +We use a robust set of modern tools to build the visual and interactive parts of BlockRooms: |
| 17 | + |
| 18 | +- 🎨 **Blender** – for modeling and exporting `.gltf` assets used in our 3D game environment. |
| 19 | +- ⚛️ **React** – component-based UI library for structuring our game frontend. |
| 20 | +- ⚡ **Vite** – the dev server and build tool powering the React app. |
| 21 | +- 🌐 **Three.js** (via [`@react-three/fiber`](https://docs.pmnd.rs/react-three-fiber)) – for real-time 3D rendering in WebGL. |
| 22 | +- 🕹️ **PointerLockControls** – to enable mouse-look and FPS-style movement. |
| 23 | +- 🐻 **zustand** – lightweight and scalable state manager to handle in-game data like player state, room transitions, HUD, etc. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## ⛓️ Onchain Game Logic (via [Dojo](https://dojoengine.org/overview)) |
| 28 | + |
| 29 | +The logic of the game lives entirely on-chain, built using the **Dojo Engine**: |
| 30 | + |
| 31 | +- 🧱 **Dojo** – a provable game engine for Starknet. The game state (players, rooms, scores) is stored on-chain using Dojo’s ECS-style architecture. |
| 32 | +- 🔧 **dojo.js SDK** – bridges our React frontend to the onchain world. Enables typed access to components and systems using TypeScript. |
| 33 | +- 🛠️ **Sozo** – CLI tool used for compiling, testing, and deploying Dojo worlds. |
| 34 | +- 📡 **Torii** – for event indexing and real-time subscriptions to in-game events. |
| 35 | + |
| 36 | +👉 **Explore Dojo documentation:** [https://docs.dojoengine.org](https://docs.dojoengine.org) |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | + |
| 41 | +## 🔗 Relevant Links |
| 42 | + |
| 43 | +- 📚 [Dojo Docs](https://dojoengine.org/overview) |
| 44 | + |
| 45 | + |
| 46 | +# Game-Logic |
| 47 | + |
| 48 | +This section outlines the core gameplay loop, progression mechanics, and XP logic of **BlockRooms**. It’s built to reflect both **on-chain** and **frontend** behavior. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## 🧩 Overview |
| 53 | + |
| 54 | +- **Genre**: On-chain, zone-based shooter with progression and XP mechanics. |
| 55 | +- **Map Structure**: 3 zones → Red (8 rooms), Blue (8 rooms), Green (4 rooms) |
| 56 | +- **Objective**: Locate and eliminate the *real enemy* in each zone to unlock the next. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## 🔁 Game Loop Summary |
| 61 | + |
| 62 | +Wallet → Join Session → Spawn in Red Zone → |
| 63 | +→ Choose Room → Read Enemy Positions → Shoot → |
| 64 | +→ If Real Enemy: Gain XP & Unlock Next Zone |
| 65 | +→ If Fake Enemy: Lose XP → Continue Searching |
| 66 | +→ Repeat for all 3 zones until exit |
| 67 | + |
| 68 | +markdown |
| 69 | +Copy |
| 70 | +Edit |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## ⚙️ Game Loop Step-by-Step |
| 75 | + |
| 76 | +### 1. 🔌 Connect Wallet |
| 77 | +- Player connects their **Cartridge Wallet** to the website. |
| 78 | + |
| 79 | +### 2. 👥 Join Session |
| 80 | +- Player taps **Join Session**. |
| 81 | +- A session is created **on-chain**. |
| 82 | +- Player spawns in **Red Zone**, with: |
| 83 | + - `Health = 100` |
| 84 | + - `XP = 200` |
| 85 | + |
| 86 | +### 3. 🧭 Explore Red Zone |
| 87 | +- **Total Rooms**: 8 (Red Zone) |
| 88 | +- Player can only enter **one room at a time**. |
| 89 | +- In each room: |
| 90 | + - **4 positions** are shown by the frontend where enemies may appear. |
| 91 | + - These positions are **predefined** in the frontend. |
| 92 | + - However, the **frontend does not know** which is real or fake. |
| 93 | + - This info is derived from **on-chain** state. |
| 94 | + |
| 95 | +### 4. ❓ Real vs. Fake Enemies |
| 96 | +- Across all 8 rooms: |
| 97 | + - Only **one** hides the **real enemy**. |
| 98 | + - Its identity is **hidden from the frontend** and **stored on-chain**. |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## 🎯 Shooting Logic |
| 103 | + |
| 104 | +| Enemy Type | Action | XP Impact | Zone Impact | |
| 105 | +|----------------|--------|------------------------|------------------------------------------| |
| 106 | +| ❌ Fake Enemy | Hit | `-1 × current_health` | Stay in current zone, keep searching | |
| 107 | +| ✅ Real Enemy | Hit | `+5 × current_health` | Unlock next zone | |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## 💡 XP Formula |
| 112 | + |
| 113 | +- **On Miss (fake):** |
| 114 | + `XP -= 1 × Health` |
| 115 | + |
| 116 | +- **On Hit (real):** |
| 117 | + `XP += 5 × Health` |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## 🔓 Zone Progression |
| 122 | + |
| 123 | +Red Zone (8 rooms) |
| 124 | +→ Real enemy defeated |
| 125 | +→ Blue Zone (8 rooms) |
| 126 | +→ Real enemy defeated |
| 127 | +→ Green Zone (4 rooms) |
| 128 | +→ Game Completed |
| 129 | + |
| 130 | +yaml |
| 131 | +Copy |
| 132 | +Edit |
| 133 | + |
| 134 | +- Once the real enemy in a zone is defeated: |
| 135 | + - The next zone is unlocked |
| 136 | + - Health and XP are retained |
| 137 | +- If **Health = 0**, player may be prevented from progressing. |
| 138 | + |
| 139 | +--- |
| 140 | + |
| 141 | +## 🧠 On-Chain vs. Frontend Responsibilities |
| 142 | + |
| 143 | +| Layer | Responsibility | |
| 144 | +|---------------|-----------------------------------------------------| |
| 145 | +| **Frontend** | Renders rooms, enemy visuals, manages input | |
| 146 | +| **On-Chain** | Chooses real enemy, calculates XP, controls state | |
| 147 | +| **Dojo ECS** | Stores health, XP, room state, and logs events | |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## 🔗 Session End Conditions |
| 152 | + |
| 153 | +- Player defeats the real enemy in the **Green Zone**. |
| 154 | +- The system may record: |
| 155 | + - ✅ Final XP |
| 156 | + - ⏱️ Time taken |
| 157 | + - 🎯 Shots fired |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## ⚠️ Disclaimer: Zone Difficulty Scaling |
| 162 | + |
| 163 | +> The above loop repeats across zones, but XP values change to increase challenge. |
| 164 | +
|
| 165 | +### 🔵 Blue Zone (8 Rooms) |
| 166 | + |
| 167 | +- **Fake Enemy Shot**: `-1.5 × Health` |
| 168 | +- **Real Enemy Shot**: `+10 × Health` |
| 169 | +- **Total Positions**: `8 × 4 = 32` |
| 170 | + |
| 171 | +### 🟢 Green Zone (4 Rooms) |
| 172 | + |
| 173 | +- **Fake Enemy Shot**: `-4 × Health` |
| 174 | +- **Real Enemy Shot**: `+15 × Health` |
| 175 | +- **Total Positions**: `4 × 4 = 16` |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | + |
| 180 | + |
0 commit comments