An open API service indexing awesome lists of open source software.

https://github.com/coderooz/simple_pygame_game

This is a simple game built with Python and Pygame. Control a red block using the arrow keys to avoid falling white blocks. Earn points for every white block that passes without collision. Features include a score system, game over screen, and replay functionality. Perfect for learning basic game development with Pygame.
https://github.com/coderooz/simple_pygame_game

Last synced: 8 months ago
JSON representation

This is a simple game built with Python and Pygame. Control a red block using the arrow keys to avoid falling white blocks. Earn points for every white block that passes without collision. Features include a score system, game over screen, and replay functionality. Perfect for learning basic game development with Pygame.

Awesome Lists containing this project

README

          

## Simple Pygame Project

This is a simple game developed using Python and Pygame. In this game, the player controls a red block that can move left and right to avoid collision with the falling white blocks. The game continues until the player collides with a white block, at which point the game ends and the player can choose to replay. The player earns points for every white block that passes without colliding.

![Game Image](img/game_start.png)

### Features
- **Player Movement**: Use the left and right arrow keys to move the red block.
- **Enemies**: White blocks fall from the top of the screen at a constant speed.
- **Score System**: Earn points for every enemy that moves past the player without collision.
- **Game Over Screen**: Displays "Game Over" and shows a replay button to restart the game.
- **Replay Functionality**: Allows the player to start a new game without restarting the program.

### How to Run
1. Ensure you have Python and Pygame installed. You can install Pygame using the following command:
```sh
pip install pygame
```
2. Clone the repository:
```sh
git clone https://github.com/coderooz/simple_pygame_game.git
```
3. Navigate to the project directory:
```sh
cd simple-pygame-game
```
4. Run the game:
```sh
python main.py
```

### File Structure
```
simple_pygame_game/
├── main.py
├── game.py
└── settings.py
```

### Explanation

1. **settings.py**: Contains all the configuration settings for easy adjustments.
2. **game.py**:
- `Player` and `Enemy` classes encapsulate the behavior and properties of the game objects.
- `Game` class manages the game loop, event handling, updates, and drawing.
3. **main.py**: Starts the game by creating an instance of `Game` and calling its `run` method.

### Running the Game

To run the game, execute the `main.py` file:

```sh
python main.py
```

- **main.py**: The entry point of the game. Initializes and starts the game.
- **game.py**: Contains the main game logic, including the game loop, player and enemy classes, and collision detection.
- **settings.py**: Configuration file for game settings like screen dimensions, colors, and speeds.

### Some Images:

![Game Image](img/game_start.png)
![Game Play 1 Image](img/game_play.png)
![Game Play 2 Image](img/game_play2.png)
![Game Play 3 Image](img/game_play3.png)
![End Game Image](img/end_game.png)

### Future Improvements
- Add multiple enemies.
- Increase the difficulty over time by increasing enemy speed.
- Add sound effects and background music.
- Implement a high score system.

### Contributing
Feel free to fork this repository and contribute by submitting a pull request. For major changes, please open an issue first to discuss what you would like to change.

### License
This project is licensed under the MIT License. See the `LICENSE` file for more details.

---