Here is a demo video of this project.
Below is the detailed documentation of classes in this project.
Class Name | Function Name | Class/Function Description |
---|---|---|
LAYER 1 | ||
Game.cpp | Main class, entry point of the engine. Initialize and update engine class | |
LAYER 2 | ||
Engine.cpp | A wrapper for the whole game engine combine multiple classes like Input, GameManager and SDL | |
Init() | Start the rendering of the SDL and initialize the gameobjects from GameManager | |
Update() | Update all gameobjects assigned in the GameManager | |
Sdlevent() | Detect Input and raise event for the Input | |
Render() | Clear the old render and draw a fresh instance of the gameobjects | |
Clean() | Clear the SDL data | |
GameManager.cpp (Singleton) | have all the world gameobjects | |
Init() | Initialize the gameobjects and cache in the world object vector | |
InputListener.h | have virtual function of keydown and keyup | |
KeyDown() | calls when key is down | |
KeyUp() | calls when key is up | |
InputSystem.cpp (Singleton) | Raise, bind and remove listeners | |
RaiseEvent() | raise event and call the listener bind | |
addListener() | Registering listener | |
removeListener() | Unregister listener | |
TextureManager.cpp | This class is basically a separate module, whose responsibility is to render the texture | |
LoadTexture() | Load texture with the file path | |
LoadTexture() | Load the given texture, loading should be done manually from the file | |
LoadFile() | Load file | |
Physics.cpp (Singleton) | Contains information of physics, like gravity, optimized value for velocity iteration and position iteration | |
EngineTime.cpp | Contains the time information like delta time, FPS, frame time etc | |
LAYER 3 | ||
Vector2.cpp | A vector2 struct with the overload operators | |
Transform.cpp | A class consists of position, rotation and scale as a vector2 | |
Rigidbody.cpp | Create rigidbody for the multiple overload constructor and register it to the box2d via physics class having the information of physics world | |
GameObject.cpp | A class with the virtual function of Draw and Update | |
Draw() | Implemented to the gameobject implementer for the draw | |
Update() | Implemented to the gameobject implementer for the update of the gameobject | |
Collider.cpp | A class having 2 virtual functions for the Init and CheckCollision | |
Init() | Initialize the collider for the object | |
CheckCollision() | TODO | |
LAYER 4 | ||
CircleCollider.cpp | Inherits from the Collider class and create a circle collider to given object | |
Init() override | Setup collider | |
CheckCollison() override | TODO | |
SetCircleCollider() | Setup collider size | |
BoxCollider.cpp | Inherits from the Collider class and create a Box collider to given object | |
Init() override | Setup collider | |
CheckCollison() override | TODO | |
SetBoxCollider() | Setup collider size | |
Helper.cpp | A class with some utility functions | |
Print() | Various overload for the print log | |
Random() | Various overload to find the random in the given range | |
DrawCricle() | Draw a circle, a gizmo circle | |
DrawRectangle() | Draw a rectangle, a gizmo rectangle | |
Ship.cpp | A player class inherit from the gameobject and input listener. It draws ship and initialize the whole system for the player. Used Constructor to draw texture using texture manager | |
Update() override | Update movement | |
Draw() override | Draw ship for the texture | |
OnKeyDown() override | Move direction for the keys | |
OnKeyUp() override | Move direction for the keys | |
InitRigidBody() | Initialize the rigidbody | |
Move() | Update position to the transform | |
boundToScreen() | Check the player stays in the screen | |
Asteroids.cpp | A simple asteroid is spawn and move to the direction, inherited from the gameobject class | |
Update() override | Update the position of the asteroid | |
Draw() override | Update the rendering | |
InitRigidBody() | Initialize the rigidbody | |
InitSpeeds() | Get random speed value using helper class | |
InitDirection() | Get random direction value using helper class | |
Background.cpp | A simple class inherited from the gameobject class and draw the background space | |
Update() override | Update the position of the background | |
Draw() override | Update the render of the background | |
This project is on the way, physics base movement is happening but the collision isn’t detecting. |