The Ninja is an exciting endless runner game built with Python and Pygame that combines fast-paced action with beautiful parallax scrolling visuals. Control a nimble ninja character as you navigate through an endless urban landscape, avoiding obstacles and chasing high scores!
- Endless Running - Infinite gameplay with progressively increasing difficulty
- Double Jump Mechanic - Perform mid-air jumps for advanced maneuverability
- Dynamic Speed System - Game speed increases as your score grows
- Health System - Three-hit health system with visual heart indicators
- Parallax Scrolling - Multi-layered background for immersive depth
- Animated Sprites - Smooth character animations for running and jumping
- Pixel-Perfect Graphics - Carefully crafted visual elements
- Dynamic UI - Animated heart icons and real-time score display
- Background Music - Engaging soundtrack that enhances gameplay
- Sound Effects - Jump, hurt, and game over sound effects
- Audio Management - Dynamic volume control during game states
- High Score System - Persistent score saving using JSON
- Real-time Statistics - Live score tracking and best performance display
- Game State Management - Smooth transitions between gameplay and menus
- SPACE BAR - Jump (Press again in air for double jump)
- Avoid obstacles by jumping over them
- Each collision reduces your health by one heart
- Game speed increases every 2 points scored
- Maximum speed cap ensures fair gameplay
- Game ends when all hearts are lost
- +1 Point for each successfully avoided obstacle
- Speed Boost every 2 points
- Personal Best tracking with persistent storage
- Python 3.6 or higher
- Pygame library
-
Clone the Repository
git clone https://github.com/greatitandev/Ninja-Game-python.git cd the-ninja-runner -
Install Dependencies
pip install pygame
-
Verify File Structure
the-ninja-runner/ โโโ main.py โโโ score.json โโโ images/ โ โโโ city/ # Background layers โ โโโ player/ # Character animations โ โโโ obstacle/ # Obstacle variations โ โโโ heart/ # Health indicators โ โโโ bg/ # Menu backgrounds โโโ sound/ โโโ background.mp3 โโโ jump.wav โโโ hurt.wav โโโ hurt1.wav โโโ lose.wav -
Launch the Game
python main.py
- Object-Oriented Design - Clean class structure for game entities
- Sprite-Based Rendering - Efficient image handling and animation
- Event-Driven Logic - Responsive input handling and game state management
- Frame Rate Control - Consistent 60 FPS gameplay
- Efficient Collision Detection - Rectangle-based collision system
- Memory Management - Proper resource loading and cleanup
# Core Classes
Player() # Handles player movement, jumping, and animations
Obstacle() # Manages obstacle generation and movement
# Game Systems
load_sound() # Audio file management
get_score() # High score persistence
save_score() # Progress saving- Difficulty: Adjust
SPEED_INCREMENTandSPEED_INCREASE_RATE - Physics: Modify
JUMP_STRENGTHandGRAVITYconstants - Visuals: Replace image files in respective folders
- Audio: Add new sound files to the sound directory
The modular code structure makes it easy to add:
- New obstacle types
- Power-ups and collectibles
- Additional character abilities
- New background themes
-
Missing Dependencies
pip install --upgrade pygame
-
File Not Found Errors
- Ensure all asset folders are in the correct location
- Check file paths in the code match your directory structure
-
Audio Playback Issues
- Verify audio file formats (WAV, MP3)
- Check system volume and audio drivers
- Close other applications for optimal performance
- Update graphics drivers if experiencing lag
- Reduce screen resolution if needed
Nimona Engida - Ethiopian Game Developer
Built with passion for game development and Python programming
- Self-taught young programmer and game developer
- Passionate about creating engaging gaming experiences
- Focus on clean code and user-friendly design
- Ethiopian developer promoting local tech talent
We welcome contributions from the community! Feel free to:
- Report bugs and issues
- Suggest new features and improvements
- Submit pull requests with enhancements
- Share your modified versions
- Follow PEP 8 coding standards
- Test changes thoroughly before submitting
- Document new features clearly
- Maintain backward compatibility
This project is licensed under the MIT License - see the LICENSE file for details.
You are free to:
- Use, copy, modify, and distribute the software
- Use for commercial purposes
- Sublicense and sell copies
- Pygame Community - For excellent documentation and support
- Open Source Assets - Contributors to free game development resources
- Testers - Everyone who helped refine the gameplay experience
"With great speed comes great responsibility... to avoid obstacles!" ๐โโ๏ธ๐จ

