A two-player snake hunting game on the same screen with PyGame graphics!
Two players competing in an intense snake battle with power-ups and obstacles
- 2 Players: Each player controls their own snake on the same board
- Player Naming: Enter names for both players before starting
- Separate Controls:
- Player 1 (Green Snake): Arrow keys
- Player 2 (Blue Snake): WASD keys
- Scoring System: Food +10 points, power-up +5 points
- Win/Lose: Snake that survives longest or has highest score wins
- Score Tracking: Keep track of wins for each player, +1 win per victory
- Wall Wrapping: Touching walls makes you appear on the opposite side (no death)
- Power-ups: Three types of special items:
- ๐ฆ Speed Boost (Blue): Increase speed for 3 seconds
- ๐ฃ Grow (Purple): Instantly add 2 segments
- ๐ Shrink Enemy (Orange): Remove 2 segments from opponent
- Obstacles: Random gray blocks create challenges
- Speed Effects: Snake glows when speed boosted
Different power-ups: Speed Boost (Blue), Grow (Purple), Shrink Enemy (Orange), plus obstacles
- Install Python (3.7 or higher)
- Install PyGame:
Or manually:
pip install -r requirements.txt
pip install pygame==2.5.2
python main.py- โ: Move up
- โ: Move down
- โ: Move left
- โ: Move right
- W: Move up
- S: Move down
- A: Move left
- D: Move right
- R: Restart game (when game over)
- N: Edit player names (when game over)
- C: Reset win/loss score (anytime)
- Q: Quit game
- Enter: Confirm current name
- Tab: Switch to next player
- Space: Start game with current names
- C: Reset win/loss score
- Backspace: Delete character
- ESC: Start with default names / Go back
- Enter Names: Set names for both players before starting
- Objective: Survive longer than your opponent and score more points
- Eat Food: Red squares give 10 points and make your snake grow
- Collect Power-ups: Colored squares provide temporary advantages:
- Blue = Speed boost for 3 seconds
- Purple = Instantly add 2 segments
- Orange = Remove 2 segments from opponent
- Avoid Collisions: Don't hit obstacles, yourself, or your opponent
- Win Conditions:
- Last surviving snake wins
- If both die simultaneously, higher score wins
- Tie if same score when both die
- Overall Score: Each victory accumulates +1 win, displayed on screen
- Wall Wrapping: Touch screen edge โ appear on opposite side (no death)
- Self Collision: Hit your own body โ death
- Player Collision: Hit opponent's body โ death
- Head-to-Head: Two heads collide โ both die
- Obstacles: Hit gray blocks โ death
- Food: 10 points per red square (round score)
- Power-ups: 5 bonus points per item (round score)
- Survival Bonus: Being the last snake alive usually determines winner
- Round Win: +1 win for victor (cumulative display)
- Tie: No one gets win point
- Reset: Can reset score to 0-0 with C key
- Speed Boost: Double speed for 3 seconds (glowing effect)
- Grow: Instantly add 2 body segments
- Shrink Enemy: Remove up to 2 segments from opponent (won't kill)
- Control the Center: Middle positions have more escape routes
- Use Power-ups Wisely: Speed boost helps escape dangerous situations
- Block Opponent: Use your body to limit opponent's movement
- Avoid Head-on Collisions: Don't charge directly at each other
- Exploit Wall Wrapping: Use wrap-around feature for surprise attacks
- Interactive Interface: Name input screen with real text input
- State Management: Transitions between name input, playing, game over
- Grid Movement: 20x20 pixel grid system
- Smooth Animation: 60 FPS
- Random Generation: Obstacles and power-ups spawn randomly
- Real-time Controls: Continuous input processing
- Collision Optimization: Efficient position-based collision detection
You can modify constants in the game files:
WINDOW_WIDTH/HEIGHT: Change board sizeGRID_SIZE: Adjust movement granularitybase_speed: Modify base snake speed (smaller number = faster)powerup_spawn_interval: Control power-up frequency- Colors and effects can be customized in the color constants section
Have fun playing! ๐๐ฎ