Skip to content

LeaderGRL/ECS-SFML-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeaderEngine

LeaderEngine is a 2d game engine written in C++ using the Entity-Component-System (ECS) architecture, built on top of the Simple and Fast Multimedia Library (SFML). The game engine use LuaBridge to allow users to write game logic in Lua with an asset loader system driven by a YAML configuration file. The main goal of this project is to create a simple, yet powerful game engine that is easy to use and extend.
It is currently in development and is not ready for use.

Features

  • Rendering
    • Sprites
    • Animations
    • Text
    • Shapes
    • Particles
    • Tilemaps
  • Camera
    • Size
    • Position
    • Rotation
    • Zoom
    • Multiple cameras
  • Physics
    • Rigidbodies
    • Box Colliders
    • Raycasts
  • Audio
    • Sound
    • Music
  • Input
    • Keyboard
    • Mouse
    • Gamepad
  • Events
    • Event System
    • Event Queue
  • UI
  • Networking
  • Scripting
    • Lua
      • Game loop => Update
  • Editor

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • SFML (2.6.1 or higher)
  • C++ Compiler (C++ 20 standard or higher)

Installing

Windows

  1. Clone the repository
git clone https://github.com/LeaderGRL/ECS-SFML-Engine.git
  1. Open the project in Visual Studio
  2. Build the project
  3. Run the project

Linux

  1. Clone the repository
git clone
  1. Build the project
make
  1. Run the project
./LeaderEngine

UML Diagram

Components class diagram

UML Diagram

Managers class diagram

UML Diagram

Systems class diagram

UML Diagram

Entity class diagram

UML Diagram

Usage

Creating a script

Go to your game/Assets/Scripts directory and create a new lua file.

-- Object.lua
Object = {
    ObjectName = "Rocket",
    speed = 100,
    EManager = EntityManager:GetInstance(),
    RManager = ResourceManager:GetInstance(),
    EventManager = EventManager:GetInstance(),
}

function Object:Update(dt)
    self:Move(dt)
end

function Object:fixedUpdate()
    print("Fixed Update")
end

Loading assets

Go to your game/Assets/Config directory and update the Resources.yaml file.

# assets.yaml
---
textures:
    path: YOUR_PATH_TO_TEXTURES
  - id: TEXTURE_ID


animations:
  - id: ANIMATION_ID
    textureId: TEXTURE_ID
    frames:
      - x: 0
        y: 0
        width: 64
        height: 64
        duration: 0.1
      - x: 64
        y: 0
        width: 64
        height: 64
        duration: 0.1
      - x: 128
        y: 0
        width: 64
        height: 64
        duration: 0.1

Creating an entity

For now, the scene is managed by the Application class. You can create an entity by calling the CreateEntity function.
// Application.cpp
void Application::Init()
{
    // ...
    Entity* camera = EntityManager::GetInstance().CreateEntity("MainCamera");
	camera->AddComponent<ScriptComponent, const char*>("Assets/Scripts/Cameralua");
}

Getting an entity

-- Object.lua
    local camera = self.EManager:GetEntity(self.cameraName)

Adding a component

-- Object.lua
    if camera then
        camera:AddComponent(Component.CAMERA)
    end

Adding a sprite

    if object then
        object:SetSprite(self.RManager:GetTexture("OBJECT_TEXTURE_ID"))
    end

Adding an animation

    objectAnimation:AddComponent(Component.ANIMATION)

    if object then
        objectAnimation:PlayAnimation("OBJECT_ANIMATION_ID", true)
    end

Second parameter is a boolean to loop the animation

Acknowledgments

This project relies on the following great tools:

  • SFML - Simple and Fast Multimedia Library
  • LuaBridge3 - A lightweight, dependency-free library for binding Lua to C++
  • yaml-cpp - A YAML parser and emitter in C++
  • Box2D - A 2D Physics Engine for Games

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published