Skip to content

Making a 2D game engine using CPP and SFML and then making a small game with it

Notifications You must be signed in to change notification settings

digocorbellini/2D-Game-Engine

Repository files navigation

2D-Game-Engine

Goal

Make a 2D game engine using CPP and SFML and then make a small game with it

Design

This game engine is loosely based on an entity component system (ECS) with an observer pattern for individual systems. GameObjects serve as the entities, and the components and the systems are combined into classes which are added to gameObjects to give them behaviours. In a typical ECS implementation, a more data oriented approach would be utilized, which would split the data aspect of a component from its implementation in a system, however, I went for a more object oriented approach since I felt that it allowed the user of the engine to implement new features in a more intuative manner. The components have to individually subscribe to different overarching systems, such as the rendering system and the physics system, in order to get their behaviours executed. The behaviour of the systems are still implemented within the components, but they are executed by the overarching systems to which they subscribe to. Althuogh more is required within a component, I felt as though it helped reduce the number of components that needed to be iterated through wihtin each system.

Such an object oriented approach to an ECS does bring more overhead to the engine, but I felt as though Unity's approach of letting users implement behaviours through monobehaviour scripts was very intuative and my engine aims to emulate such an experience.

Features

  • GameObjects
  • Components
  • Rendering Layers and order in layers
  • Gizmos
  • Collisions
  • Physics (Gravity and object velocity)
  • Scenes
  • Prefabs
  • Parenting
  • Sound
  • Animation

Project stucture

Holds all of the files that either handle the game systems (Game loop, physics, and scene management) as well as abstract classes used to make components and scenes.

Holds general components that implement features which are intented to be used in most games (BoxCollider, SpriteRenderer, etc).

Holds all of the code that will be used to make the game

Holds all of the scenes in the game

Game

Bug Rush

You are a hungry cockroach that has spotted a half eaten donut on the other side of the kitchen table that looks prefect for the taking! However, the owner of the house is out for you! Every time they walk into the kitchen and switch on the lights, you're in danger!

Cross the kitchen table while avoiding enemy bugs and hiding from the lights behind objects in order to reach the sugary delight!

About

Making a 2D game engine using CPP and SFML and then making a small game with it

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages