- Description
- Features
- Controls
- Installation
- Contributing
- License
- Object-Oriented Programming Concepts
- Algorithm
- Game Logic
- Flowchart
- Contact
Welcome to the Brick Breaker Game repository! This project is a classic arcade game built using SFML (Simple and Fast Multimedia Library) in C++. The game involves breaking bricks using a paddle and a bouncing ball.
- Fullscreen mode for immersive gameplay.
- Simple and intuitive controls.
- Background music and sound effects.
- Score tracking.
- Main menu with options to start the game, view credits, and quit.
- Game over and level completion conditions.
- Left Arrow Key: Move paddle left.
- Right Arrow Key: Move paddle right.
- Escape Key: Return to the main menu.
To run the Brick Breaker Game, follow these steps:
- Clone the repository
git clone https://github.com/hzjadoon/Brick-Breaker-Game-.git cd Brick-Breaker-Game-
- Compile the game
Ensure you have SFML installed. You can compile the game using the following command:
g++ -o brick_breaker main.cpp -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
Contributions are welcome! If you have suggestions for improvements, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
The game is designed using several OOP principles:
- Classes and Objects: The main game components such as
Paddle
,Ball
,Brick
, andMenu
are implemented as classes. - Encapsulation: Each class encapsulates its data and behavior, providing a clear interface for interaction.
- Inheritance and Polymorphism: Although not heavily used in this example, the design allows for future extension where these concepts can be applied.
- Paddle: Represents the player's paddle. Handles movement and position updates.
- Ball: Represents the ball that bounces around the screen. Manages movement and collision detection.
- Brick: Represents individual bricks that the ball will break.
- Menu: Manages the game menu, including the start, about us, and quit options.
- Initialize the game window in fullscreen mode.
- Load textures, sounds, and fonts.
- Create game objects: paddle, ball, and bricks.
- Display the main menu and handle user input.
- If the game starts, enter the game loop:
- Handle user input for paddle movement.
- Update ball position and check for collisions:
- With walls (change ball direction).
- With paddle (change ball direction).
- With bricks (remove brick, increase score, change ball direction).
- Check for game over conditions (ball falls below paddle).
- Check for level completion (all bricks destroyed).
- Display game over or level completion screen as appropriate.
- Handle "About Us" and "Quit Game" options in the main menu.
- Initialize game window
- Load textures, sounds, and fonts
- Create paddle, ball, and bricks
-
If in main menu:
- Display menu
- Handle menu input
- If "Start Game" selected:
- Enter game loop
-
Else if in game loop:
- Handle paddle movement input
- Update ball position
- Check for ball collision with walls
- Check for ball collision with paddle
- Check for ball collision with bricks
- If all bricks are destroyed:
- Display level complete message
- Break game loop
- If ball falls below paddle:
- Display game over message
- Break game loop
- Render game objects
-
Else if in "About Us" screen:
- Display "About Us" information
- Handle "Back to Menu" input
-
Else if "Quit Game" selected:
- Exit game
+--------------------+
| Start |
+--------------------+
|
v
+----------------------------------+
| Initialize game window, load |
| textures, sounds, fonts, and |
| create game objects |
+----------------------------------+
|
v
+--------------------+
| Display Main Menu |
+--------------------+
|
v
+----------------------+
| Handle Menu Input |
+----------------------+
|
+----------+----------+
| |
v v
+-------------------+ +-----------------+
| Start Game | | Show About Us |
+-------------------+ +-----------------+
| |
v v
+-------------------+ +-----------------+
| Enter Game Loop | | Handle About Us |
+-------------------+ +-----------------+
| |
v v
+-------------------+ +-----------------+
| Handle Input, | | Return to Menu |
| Update Positions | +-----------------+
| and Collisions |
+-------------------+
|
v
+-------------------+
| Check for Win or |
| Game Over |
+-------------------+
|
v
+-------------------+
| Display Win or |
| Game Over Screen |
+-------------------+
|
v
+-------------------+
| Return to Menu |
+-------------------+
For any inquiries or feedback, feel free to reach out:
- GitHub: hzjadoon
- Email: [email protected]