← Back to Recent Work
Building a Gameplay Framework in SFML & C++
A deep dive into gameplay architecture, engine patterns, AI, and scalable systems design
C++ SFML CMake Architecture
Visit Repository →
Features
Object-Oriented Design with Component-based features
- Used
Component->SceneComponent->PrimitiveComponenthierarchy to mimic Unreal Engine - Settable Render and Update Priorities.
- Abstracted Object/ Entity/ Component lifetimes and ownership.
Enemy Ships
- Implemented Craig Reynold’s Flocking algorithm for group movement and player seeking behavior. (see:
Source/Ships/Bot.cpp->void Bot::AddFlockingForces()) - Group Shooting policy for limiting max number of enemy ships to Auto Shoot at player when they have Line of Sight
Implicit Grids for collision detection using Binary Spatial Partitioning.
- Implementation in
Core/Physics/ImplicitGrid.h - Added LineCasting and CircleCasting functions. (
Core/Physics/Physics.h)
Timer & Timer Manager
- With
OnStart()OnComplete()andOnUpdate()assignable functions
A customisable and flexible Particle System.
- Pooled particles
- Support for Emission Bursts
- Update Colour & Scale over lifetime
- Set Emission Orientation and Initial velocity to be applied in Global or Local space.
- Set Emitter and Particle shape, shape can be:
- Static vector of
- Logical function with a resolution specified, will generate points using the function using a 0-1.f
- Static presets such as Circle, Square, Line.
Templated Object Pooling
- Used for particles/ states and their lifetimes.
- Restricted to pools holding weak pointers to pooled objects.
- Make any object poolable by inheriting from APoolable.
Global Input Event Messaging System
- Create Input bindings on Button Pressed, Button Held, Button Released.
- Wrapper on top of SFML input event polling
Graph based on linked lists
- Written to be scalable and ready to use with multiple prospect graph requirements (such as pathfinding).
- Used it for implementing Finite State machine.
Core/Graph/FSM/FSM.h- Used by Portal, Enemy Ship, Kamikaze Enemy Ship
- Reusable BaseWaitState so you can add functionality at the start, end and tick of the timer on child states.
Added a Stars background to game.
- Random stars keep twinkling over time.
- 2D Parallax effect based on player’s acceleration.
UIManager for HUD
- Renders UI Objects only, made functionality to easily display Text but can be easily extended to render shapes etc.
Design patterns
- Game loop (lol)
- Dirty Flag
- Deferred delete for
Core/ECS/Object.h->Object::Kill() - Component transform recalculation optimization (
Core/ECS/GameEntity.h->GameEntity::bPositionDirty_)
- Deferred delete for
- Observer (
Core/Event.h) - Strategy (
Ships/AShootingStrategy.h) - Object Pooling (
Core/Pooling/WeakPointerObjectPool.h) - State Machine (
Graph/FSM/FSM.h,EnemyShiphas 2 FSMs, 1 for attacking and movement each,Portalfor teleport cooldown) - Singleton (
Systemis a singleton, which ownsFSMManager,ScreenShaker, etc and gives weak pointers when requested.)