A Python implementation of a bouncing ball game using the Pygame library.
This project implements a simple physics-based bouncing ball game where players control a platform to bounce a ball and prevent it from falling off the screen. It's an excellent example of basic game development principles and physics simulation in Python using Pygame.
- Physics-based ball movement with realistic bouncing
- Player-controlled platform with arrow key input
- Score tracking and level progression
- Lives system with game over conditions
- Color-changing platform for visual feedback
-
Clone the repository:
git clone https://github.com/fahadelahikhan/Bouncing-Ball-Pygame.git cd Bouncing-Ball-Pygame
-
Install required dependencies:
pip install pygame
-
Run the game:
python main.py
# The game is controlled via keyboard inputs
# Use the LEFT and RIGHT arrow keys to move the platform
# Prevent the ball from falling off the bottom of the screen
# Each successful bounce increases your score
# The ball starts at the center of the screen with random velocity
ball_pos = [400, 300]
ball_speed = [3.0, 3.5]
# The platform starts at the bottom center of the screen
platform_pos = [350, 560]
# As the player bounces the ball, the score increases
# When the score reaches 10, the player advances to level 2
current_level = 2
The game implements basic physics principles:
- The ball moves according to its velocity vector
- When the ball hits a wall or the platform, its velocity is reflected
- The platform can be moved horizontally using arrow keys
- The game tracks score and lives, with increasing difficulty per level
Distributed under the MIT License. See LICENSE for details.
Note: This implementation is for educational and entertainment purposes. The game logic and physics are simplified for demonstration purposes.