OOP Project Report
OOP Project Report
A PROJECT REPORT
Submitted by
of
SUBMITTED TO:
TABLE OF CONTENTS
1 INTRODUCTION 3
2 OBJECTIVES 3
3 REQUIREMENTS 5
4 SYSTEM DESIGN 8
5 IMPLEMENTATION 12
6 RESULTS 15
8 CONCLUSION 15
9 REFERENCES 16
1
Project Report: FLAPPY BIRD GAME
ABSTRACT
This project presents the development of a Flappy Bird game using C++ and the SFML (Simple
and Fast Multimedia Library). Flappy Bird is a popular side-scrolling game where the player
controls a bird, navigating it through sets of pipes without hitting them. The goal of this project
was to recreate this game from scratch, focusing on object-oriented programming principles.
The game features essential components such as the bird, pipes, background, and scoring system.
The bird's movement is controlled by spacebar inputs, causing it to flap and ascend, with gravity
pulling it down otherwise. Pipes move horizontally across the screen, presenting obstacles for the
player to avoid. The scoring system increases the player's score each time the bird successfully
passes between pipes.
The development process involved designing classes for each game component, implementing
game mechanics, and ensuring smooth animation and collision detection. SFML was chosen for
its simplicity and efficiency in handling graphics, sound, and input, making it suitable for game
development in C++.
The final product is a fully functional Flappy Bird game that runs efficiently and provides an
enjoyable user experience. This project demonstrates the practical application of object-oriented
programming concepts and the capabilities of the SFML library in game development.
2
Project Report: FLAPPY BIRD GAME
1. INTRODUCTION
1.1 Background Information:
2. OBJECTIVES
The primary objective of this project is to develop a clone of the popular Flappy Bird game using
Object-Oriented Programming (OOP) principles in C++ and the Simple and Fast Multimedia
Library (SFML). This project aims to provide a practical application of OOP concepts while
leveraging the capabilities of SFML for game development. Through this project, we seek to
achieve several key goals:
2.1 Understanding and Applying OOP Principles
Encapsulation:
Encapsulation involves bundling the data and methods that operate on the data within a single unit
or class. This project aims to demonstrate how encapsulation can be used to create modular and
maintainable code. Each game component, such as the bird, pipes, background, and score, will be
encapsulated within its own class. This ensures that each class manages its own state and behavior,
promoting code reusability and ease of maintenance.
Abstraction:
Abstraction involves hiding the complex implementation details and exposing only the necessary
functionalities. This project aims to apply abstraction by designing clear and simple interfaces for
each class. This will help in managing the complexity of the game and making the codebase easier
to understand and modify.
3
Project Report: FLAPPY BIRD GAME
By organizing the code into these classes, we aim to create a modular and maintainable codebase
4
Project Report: FLAPPY BIRD GAME
3. REQUIREMENTS
1. Development Environment
To develop the Flappy Bird game, you need a suitable development environment that supports
C++ and SFML. This includes:
IDE (Integrated Development Environment):
Recommended: Visual Studio, CLion, Code:: Blocks, or any other C++ IDE with support for
SFML.
Compiler:
A C++ compiler that supports modern C++ standards (C++11 and above). GCC, Clang, or MSVC
are suitable options.
SFML Library:
Download and install SFML (Simple and Fast Multimedia Library) from SFML's official website.
5
Project Report: FLAPPY BIRD GAME
6
Project Report: FLAPPY BIRD GAME
Scoring System:
A system to track and display the player's score based on the number of pipes successfully passed.
6. Collision Detection
Implement collision detection to determine when the bird hits a pipe or the ground:
Bounding Box Collision:
Check for intersections between the bird's bounding box and the bounding boxes of pipes and
ground.
7. User Interface
Design a simple and intuitive user interface:
Score Display:
Display the current score on the screen using the loaded font.
Restart Prompt:
Display a "RESTART GAME!!" prompt when the game is over.
8. Resource Management
Efficiently manage game resources to ensure optimal performance:
Loading Assets:
Load all textures and fonts at the start of the game to avoid loading delays during gameplay.
Memory Management:
Properly manage memory for dynamic objects such as pipes to prevent memory leaks.
9. Error Handling and Debugging
Implement basic error handling and debugging:
Error Messages:
Display error messages for failed asset loading.
Debugging Tools:
Use debugging tools provided by the IDE to step through the code and identify issues.
10. Documentation
Provide thorough documentation for the project:
Code Comments:
Comment the code to explain the functionality of classes, methods, and key sections.
Example Code Overview
Here's an example structure of the main components implemented in the provided code:
7
Project Report: FLAPPY BIRD GAME
4.SYSTEM DESIGN
The Flappy Bird game will be developed using Object-Oriented Programming (OOP) principles
in C++ and the SFML (Simple and Fast Multimedia Library) for multimedia handling. The system
design includes defining the core components, their interactions, and the overall architecture of the
game. This design will ensure that the game is modular, maintainable, and extendable.
Core Components:
1. Game Class
2. Bird Class
3. Pipe Class
4. Resource Management
5. Collision Detection
6. User Interface
8
Project Report: FLAPPY BIRD GAME
9
Project Report: FLAPPY BIRD GAME
2. Bird Class:
Attributes:
bird_sprite: Sprite for the bird.
bird_texture: Texture for the bird.
10
Project Report: FLAPPY BIRD GAME
Pipe Class
Attributes:
sprite_up: Sprite for the upper pipe.
sprite_down: Sprite for the lower pipe.
pipe_texture_up: Texture for the upper pipe.
pipe_texture_down: Texture for the lower pipe.
move_speed: Speed at which the pipes move.
Methods:
Pipe(float position): Constructor to initialize the pipes.
update(sf::Time& dt): Updates the position of the pipes.
getright_bound(): Gets the rightmost bound of the pipes.
load_texture(): Loads the textures for the pipes.
The Game class is instantiated and initializes all necessary game objects (bird, pipes, background,
ground) and loads resources (textures, fonts).
11
Project Report: FLAPPY BIRD GAME
Game Loop:
The StartGameLoop method runs continuously while the window is open.
Event Handling: The game processes user inputs (keyboard and mouse events) to control the bird
and handle game restart.
Game Logic: The do_processing method updates the game state, including bird movement, pipe
spawning, and collision detection.
Rendering: The Draw method renders all game objects to the window.
Collision Detection:
The check_collision method checks for collisions between the bird and pipes or ground to
determine game over conditions.
Score Management:
The check_scorce method updates the score based on the bird's position relative to the pipes..
Game Restart:
The restart_game method resets the game state, including the bird's position, pipe positions, and
score, allowing the game to restart.
5. IMPLEMENTATION
This section details the implementation of the Flappy Bird game using C++ and SFML, following
the system design discussed above. We will implement the core components: Game, Bird, Pipe
classes, and then integrate them into the main game logic.
1. Project Structure:
Here a screenshot added to understand the project structure
2. Implementation Details:
1.1 Game Class:
12
Project Report: FLAPPY BIRD GAME
Here the screenshots are added to understand the physics and environment of class:
13
Project Report: FLAPPY BIRD GAME
14
Project Report: FLAPPY BIRD GAME
6. RESULTS
After doing all the steps one after the other our Project is ready. Here some screenshots that show
our project result that is it work properly or not.
7. CONCLUSION
In conclusion, the development of the Flappy Bird game using C++ OOP principles and the SFML
library has been successfully executed, resulting in a fully functional and engaging gaming
experience. This project report has outlined the comprehensive design and implementation process
undertaken to realize the game's key features, including its core components, mechanics, and user
interface.
The main objective of this project was to create a Flappy Bird game using Object-Oriented
Programming and SFML. This objective has been achieved by implementing the following key
components:
• Developed a robust game loop to handle user input, update game state, and render graphics
using SFML.
• Utilized OOP principles to create modular and reusable classes for the bird, pipes,
background, and game management.
• Integrated SFML for multimedia handling, including graphics rendering, window
15
Project Report: FLAPPY BIRD GAME
8. REFERENCES
All the following resources are used both making project and project report.
▪ SFML Documentation
▪ Visual Studio
▪ ChatGPT
▪ Visual Studio Community
▪ SFML Library
16