Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

CAR GAME

OOPs Project
- Priyanshi (2K20/SE/101)
- Sandali (2K20/SE/117)
Intro We developed a console-based simple c++ Car Game using an object-oriented
approach. We have used SDL2 and SQLite libraries to add visuals to the game
and maintain the database.
From the outset, the application demands the user to log in/create a new
account consisting of a unique username and a strong password. Then,
proceeding to the main screen, there are three choices
- PLAY: begins the game
- RULES: displays the set of instructions / ‘ How To Play ‘
- QUIT: quits the ongoing game and brings the user back to the main
screen
The game's main aim is to dodge the enemy car approaching from the opposite
direction using the 'LEFT-RIGHT-UP-DOWN’' arrow keys and move forward,
thus increasing the score visible on top of the screen. One can mute the
background music by pressing the ‘M’ key or quit the game by pressing the ‘Q’
key.
We can increase the level during the game by incrementing it when the score
exceeds a specific number. The game ends when the user car and the enemy
car collide head-on. At the very end, a leaderboard is displayed.
Header -
-
iostream
sqlite3.h
-

Files
SDL.h
- SDL_image.h
- SDL_ttf.h
- SDL_mixer
- ResponsiveBox.h
- Account
- Register.h
- LeaderBoard.h

User -
-
Coord.h
MusicHandler.h

Defined
- TextureManager.h
- GameWindow.h
- EventHandler.h

Header -
-
Car.h
CircularQueue_ArrayImplementation.h

Files -
-
Road.h
PlayGame.h
- Game.h
- CLASSES & OBJECTS: Encapsulation, constructors and
destructors, data abstraction and data hiding
- VIRTUAL FUNCTIONS & ABSTRACT CLASS (Runtime
Polymorphism): class Car has a virtual function called Render()
- INLINE FUNCTIONS:
- isEmpty() and isFull() functions of the class CQ

OOP -
-
min() and max()
get_Right_X(), get_Left_X(), get_Top_Y,
get_Bottom_Y() functions of the class Responsive_Box
and

concepts
- running() function of the class GameWindow
- Play_ShortSound(), STOP_ShortSound(),
Play_Bkgrd_Drumbeats() and STOP_Bkgrd_Drumbeats()
functions of the class MusicPlayer
- Update_Score() of the class PlayGame
- STATIC DATA MEMBERS & FUNCTIONS: Static data members
SavedPassword, SavedSocre, and SavedLevel, and static member
function GetDataFromDatabase() in class Account
- FRIEND CLASS: class RegistrationPage is a friend of class Account
Hierarchical Inheritance Multilevel Inheritance Multiple Inheritance

Car ResponsiveBox EventHandler GameWindow

Button Game
Incoming_Ca
User_Car
r

Text_Input_B
ox
- ACCOUNT: manages user’s username, password, score, and
level
- REGISTER: renders the registration/login screen and handles
the user login and password input
- 1
LEADERBOARD: collects the username and score of the top 3

Classes -
users and renders them on the sdl window
COORD: handles the coordinate system of the whole game and
the sdl window
- RESPONSIVEBOX: It handles the dimensions and positioning
of a box
- BUTTON: It has a function check_Button_is_Clicked()
which returns true when there is a
SDL_MOUSEBUTTONDOWN event i.e. user clicks
the button.
- TEXT_INPUT_BOX: It inputs text when the
user clicks inside the text box and stops taking
text input when the user clicks out of the box.
- CAR: It is an abstract class. It consists of a virtual function
Render(). Also, it has an object of class TextureManager as its
protected data member which is used to create the texture of the
1
car. Its constructor initializes the dimensions of the car which is

Classes used when the car is rendered(the destination SDL_Rect) and


loads the car image. It has the following child classes
- USER_CAR renders the user car and keeps a track of the
moving step(inherited from Car) which increases on each
level
- INCOMING_CAR renders the user car and keeps a
track of the moving step which for now remains the same
in each level
- CQ: Circular queue data structure is used to move the incoming
cars in a circular fashion.
- GAMEWINDOW: It initialises/quits SDL and
creates(constructor)/destroys(destructor) SDL window and
renderer.
- MUSICPLAYER: handles 1the sound system of the game,

Classes -
playing and stopping the car sounds and the background drum
beats in the game.
EVENTHANDLER: handles the event loop of the main menu
screen
- PLAYGAME handles/renders/manages the car game loop
- GAME: It has the main game loop. First it calls the function
SignUp_OR_SignIn() of the class RegistrationPage to register
the user. If registration/login is done successfully, the game
moves on to the main menu screen which has 3 options Play
Game, Rules and Quit. It handles the rendering of these screens
and the inherited class EventHandler handles the user input.

You might also like