top of page

C++ 2D Game Engine with SDL

Updated: Oct 15, 2019

I made my own game engine in c++ with SLD libraries. Using an entity component system and scenes. I implemented most components with game programming patterns in mind to have the best practices.


Components:

BaseComponent

Every component derives from the Basecomponent.


RenderComponent

each scene has a SceneRenderer, that holds vector of RenderComponents, you can ask a new one to give to a game object. It can hold an animator and will automatically start drawing the animation.


GridComponent

attached to the GridManager and is useed for easy grid movement with lerp and collision checking.


StateMachineComponent

This component holds states, state is a class you inherit from when making a new state, you can overwrite the entry, update, and end fucntion. the state machine will call the update function of the current state. you can also attach an animatorcomponent. the default entry will call the playClip of the animationName the state holds.


TransformComponent

Holds a postion and scale. you can also parent and child other transformComponents.


InputComponent

Link keys / controller buttons to a command. The InputComponent will check with the manager if keys are pressed.


AnimatorComponent

When making an AnimatorComponent, you pass the cols and rows. Then you can begin making a clips, they hold a name, begin and end frame and how fast each frame last. You add those clips to the animator. Then you can play them by passing a string. The Animator will Update the current clip.


Managers:

InputManager

Linked with InputComponent, it will check for updates from the keyboard or controller and pass it to the components.


ResourceManager

Reads, stores and gives stored textures with the SDL library. Usually used to give RenderComponents their texture.


GridManager

Has a list of GridComponents. Those components use this manager as a middleman to communicate between each other: check position, move, triggers...



Code Examples:



Code in scene file:


Input in scene file:


AnimationComponent:


RenederComponent:


Resources in Scene file:




 

307 views0 comments

Recent Posts

See All

KIN

bottom of page