/ README.md
README.md
1 # LBaaS Packet Catcher 🎮 2 3 A 2D game parody of "Eggs Electronica Wolf and Hare" where you play as a **Load Balancer as a Service (LBaaS)** catching falling network packets! 4 5 ## 🎯 Game Concept 6 7 Instead of a wolf catching eggs, you control a **load balancer** that must catch falling **network packets** before they hit the ground. Each packet type has its own color and represents different network protocols: 8 9 - 🔴 **HTTP** - Red packets 10 - 🟢 **HTTPS** - Green packets 11 - 🔵 **TCP** - Blue packets 12 - 🟡 **UDP** - Yellow packets 13 - 🟣 **WebSocket** - Magenta packets 14 15 ## 🎮 Controls 16 17 - **A** or **Left Arrow** - Move load balancer left 18 - **D** or **Right Arrow** - Move load balancer right 19 - **Mouse (Left Click)** - Move load balancer to mouse position 20 - **Ctrl+X** - Exit game 21 - **R** - Restart game (when game over) 22 - **UP/DOWN** - Select game mode in menu 23 - **ENTER** - Start game 24 25 ## 🏆 Scoring 26 27 - **SLA-based scoring**: Maintain Service Level Agreement targets 28 - **Dynamic SLA display**: Updates in real-time 29 - **SLA checks**: Every 100 packets against target 30 - **Game modes**: Different SLA targets and error budgets 31 - **Maximum 10,000 packets**: Game ends when limit reached 32 33 ## 🚀 How to Run 34 35 1. **Install Go** (if not already installed) 36 ```bash 37 # On Fedora/RHEL 38 sudo dnf install golang 39 ``` 40 41 2. **Download dependencies** 42 ```bash 43 go mod tidy 44 ``` 45 46 3. **Build and run the game** 47 ```bash 48 ./build.sh 49 ./lbbaspack 50 ``` 51 52 ## 🎨 Features 53 54 ### Core Gameplay 55 - **Progressive difficulty**: Packet spawn rate increases over time 56 - **Multiple packet types**: Different network protocols with unique colors 57 - **SLA System**: Service Level Agreement targets with different game modes 58 - **Dynamic SLA Display**: Real-time SLA percentage updates 59 - **Mouse Control**: Click to move load balancer to mouse position 60 - **Fullscreen Mode**: Immersive gaming experience 61 - **Ctrl+X Exit**: Quick exit with keyboard shortcut 62 63 ### Power-ups & Special Abilities 64 - **Speed Boost** (Yellow): Doubles load balancer movement speed 65 - **Wide Catch** (Cyan): Increases catch area by 50% 66 - **Multi-Catch** (Magenta): Can catch multiple packets simultaneously 67 - **Time Slow** (Blue): Slows down falling packets 68 - **Shield** (Green): Protects against missed packets 69 - **Auto-Balancer** (Orange): Automatically distributes packets to least-loaded backend 70 71 ### Backend Visualization 72 - **Backend Visualization**: See packets flow to backend servers 73 - **Round-robin Load Balancing**: Packets distributed evenly across backends 74 - **Smart Load Balancing**: Auto-balancer finds least-loaded backend 75 - **Packet Counters**: Real-time packet counts per backend 76 77 ### Visual Effects 78 - **Particle effects**: Visual feedback when catching packets 79 - **Power-up indicators**: Visual feedback for active abilities 80 - **Gradient background**: More polished visual appearance 81 - **Level progression**: Levels based on packets caught 82 83 ## 🎯 Game Modes 84 85 1. **Mission Critical** - 99.95% SLA target (3 error budget) 86 2. **Business Critical** - 99.5% SLA target (10 error budget) 87 3. **Business Operational** - 99% SLA target (25 error budget) 88 4. **Office Productivity** - 95% SLA target (50 error budget) 89 5. **Best Effort** - 90% SLA target (100 error budget) 90 91 ## 🏗️ Current Project Structure 92 93 The game is built with a modular architecture following SOLID/DRY principles: 94 95 ``` 96 lbbaspack/ 97 ├── main.go # Entry point and game loop 98 ├── game.go # Game state and core logic 99 ├── packet.go # Packet spawning and management 100 ├── backend.go # Backend management and load balancing 101 ├── powerup.go # Power-up system and effects 102 ├── particle.go # Particle effects system 103 ├── ui.go # UI drawing functions 104 ├── constants.go # Game constants and configuration 105 ├── build.sh # Build script 106 └── README.md # This file 107 ``` 108 109 ### Module Responsibilities 110 111 - **main.go**: Ebiten setup, game loop, and high-level coordination 112 - **game.go**: Game state management and core game logic 113 - **packet.go**: Packet creation, spawning, and movement logic 114 - **backend.go**: Backend management and load balancing algorithms 115 - **powerup.go**: Power-up spawning, activation, and effect management 116 - **particle.go**: Particle system for visual effects 117 - **ui.go**: User interface drawing and display logic 118 - **constants.go**: Centralized game constants and configuration 119 120 ## 🔄 Planned Advanced Refactoring 121 122 The current structure is still quite monolithic. We're planning a more sophisticated architecture following game development best practices: 123 124 ### 🎯 Target Architecture: Entity-Component-System (ECS) 125 126 ``` 127 lbbaspack/ 128 ├── main.go # Entry point 129 ├── engine/ # Core game engine 130 │ ├── game.go # Game state management 131 │ ├── systems/ # ECS systems 132 │ │ ├── input.go # Input handling system 133 │ │ ├── movement.go # Movement system 134 │ │ ├── collision.go # Collision detection system 135 │ │ ├── spawning.go # Entity spawning system 136 │ │ ├── rendering.go # Rendering system 137 │ │ └── ui.go # UI rendering system 138 │ ├── components/ # ECS components 139 │ │ ├── transform.go # Position, rotation, scale 140 │ │ ├── sprite.go # Visual representation 141 │ │ ├── physics.go # Velocity, acceleration 142 │ │ ├── health.go # Health and damage 143 │ │ ├── powerup.go # Power-up effects 144 │ │ └── ai.go # AI behavior 145 │ ├── entities/ # Entity definitions 146 │ │ ├── loadbalancer.go # Load balancer entity 147 │ │ ├── packet.go # Packet entity 148 │ │ ├── powerup.go # Power-up entity 149 │ │ ├── backend.go # Backend entity 150 │ │ └── particle.go # Particle entity 151 │ └── events/ # Event system 152 │ ├── events.go # Event definitions 153 │ └── dispatcher.go # Event handling 154 ├── systems/ # Game-specific systems 155 │ ├── sla.go # SLA calculation system 156 │ ├── loadbalancing.go # Load balancing logic 157 │ ├── powerup_manager.go # Power-up management 158 │ └── game_state.go # Game state transitions 159 ├── ui/ # User interface 160 │ ├── menu.go # Menu system 161 │ ├── hud.go # Heads-up display 162 │ └── game_over.go # Game over screen 163 ├── config/ # Configuration 164 │ ├── game_config.go # Game settings 165 │ ├── powerup_config.go # Power-up definitions 166 │ └── packet_config.go # Packet type definitions 167 └── utils/ # Utilities 168 ├── math.go # Math utilities 169 ├── colors.go # Color definitions 170 └── constants.go # Game constants 171 ``` 172 173 ### 🎮 Benefits of ECS Architecture 174 175 1. **Separation of Concerns**: Each system handles one aspect (movement, rendering, etc.) 176 2. **Composition over Inheritance**: Entities are composed of components 177 3. **Easy Extension**: Add new components/systems without modifying existing code 178 4. **Performance**: Systems can be optimized independently 179 5. **Testability**: Each system can be unit tested in isolation 180 6. **Parallel Processing**: Systems can run in parallel where possible 181 182 ### 🔧 Key Improvements 183 184 - **Event-Driven Architecture**: Loose coupling between systems 185 - **State Management**: Clear game state transitions 186 - **Resource Management**: Proper asset loading and cleanup 187 - **Input Abstraction**: Platform-independent input handling 188 - **Rendering Pipeline**: Efficient rendering with batching 189 - **Physics System**: Proper collision detection and response 190 - **Audio System**: Sound effects and music management 191 192 ## 🛠️ Technical Details 193 194 - Built with **Ebitengine v2** (Go 2D game engine) 195 - Written in **Go 1.24.4** 196 - **Modular architecture** following SOLID/DRY principles 197 - Window size: 800x600 pixels (fullscreen) 198 - Cross-platform support (Linux, Windows, macOS) 199 200 ## 🎯 Game Mechanics 201 202 - **SLA-based gameplay**: Must maintain SLA above target 203 - **Dynamic difficulty**: Packet speed increases with lost packets 204 - **Backend visualization**: See packets flow to backend servers 205 - **Mouse control**: Precise positioning with mouse 206 - **Fullscreen experience**: Immersive gaming 207 - **Strategic depth**: Balance between catching packets and maintaining SLA 208 - **Power-up system**: Collect special abilities for enhanced gameplay 209 210 Enjoy catching those network packets! 🌐📦