A fast-paced multiplayer game where players compete in real-time to collect the most cookies from a shared plate. Built to demonstrate UDP networking, client-server architecture, and real-time game state synchronization.
Key Technical Features:
- Real-time UDP socket communication for low-latency multiplayer
- Client-server architecture with centralized game state management
- Lobby system with player ready-up functionality
- Server-side collision detection and validation
- Thread-safe concurrent client and server operations
Core: Python 3.8+ • Pygame 2.0+ • UDP Sockets
Architecture: Client-Server Model • Threading • JSON Serialization • Event-Driven Design
- Python 3.8+
- Pygame (
pip install pygame)
git clone https://github.com/TechnoMechno/371_Networking_Project.git
cd 371_Networking_Project
python game_main.py- Run
python game_main.py - Click "Host Game" to start a server
- Share your IP address with other players
- Click "Ready" when all players have joined
- Run
python game_main.py - Enter the host's IP address
- Click "Join Game"
- Click "Ready" to start
- Objective: Collect more cookies than your opponents
- Controls: Left click to grab cookies from the plate
- Cookie Types:
- 🍪 Regular Cookie: 1 point
- ⭐ Star Cookie: 3 points (rare)
371_Networking_Project/
├── 📂 game_code/ # Core game logic and entities
│ ├── config.py # Game configuration and constants
│ ├── game.py # Main game loop
│ ├── player.py # Player entity
│ └── cookie_refactored.py # Cookie entity
│
├── 📂 server2/ # Server-side implementation
│ ├── server_main.py # Server entry point
│ ├── networking.py # UDP server logic
│ └── GameStateManager.py # Game state management
│
├── 📂 client2/ # Client-side implementation
│ ├── client_main.py # Client entry point
│ ├── client_networking.py # UDP client logic
│ ├── render.py # Rendering engine
│ └── Button.py, TextBox.py # UI components
│
└── game_main.py # Main application entry point
- UDP Protocol: Implemented custom handshake protocol for connection validation
- Packet Handling: Managed packet loss and out-of-order delivery
- State Sync: JSON-based game state broadcasting to all clients
- Python threading for simultaneous client/server operations
- Thread-safe communication between network and game logic
- Server Authority: Centralized validation prevents cheating and desync
- Collision Detection: Server-side validation for cookie grabbing
- State Management: Enum-based system (LOBBY → PLAYING → GAME_OVER)
- Race Conditions: Server-side validation ensures only first valid request succeeds
- Mid-Game Joins: JOIN_CHECK handshake prevents joining during active games
- Scalability: Modular client-server design allows easy feature additions
- Power-ups and special abilities
- Leaderboard and persistent stats
- Multiple game modes (team play, time attack)
- NAT traversal for internet play
- Player authentication system
This project is open source and available for educational purposes.
