This is the Fleks Entity Components System (ECS) integration for KorGE Game Engine. Korge-fleks consists of a growing set of Entity Component definitions, dedicated Entity Systems and utilities around them like AssetStore, Entity-Component serialization, etc. which are reusable or will get better reusable over time. Eventually this will grow into a specialized Korge-based game engine for 2D platform games or similar. It depends on what the ECS systems will be able to do.
Upstream project for Fleks ECS can be found here: https://github.com/Quillraven/Fleks
Korge-Fleks is maintained by @jobe-m
- Korge-Fleks Addon: 0.0.1
- Korge: 3.4.0
- Fleks: 2.2
The Korge-Fleks implementation follows the idea to separate the configuration of Game Objects from its behaviour.
A Game Object in an ECS world is an Entity and by that just an index number (in Fleks e.g.Entity(id = 1)
).
The aspects of an Entity are stored in Components. Aspects can be read as configuration for a Game Object.
Component objects have a relationship to at least one Entity.
ECS Systems iterate over all (active) Entities of an ECS world and execute the "behaviour" for each Entity.
To do so they use the config (aspects) from all associated Components of that Entity.
If I lost you already please step back and read elsewhere a little more about ECS basics. It is important to understand the basic principles of an ECS system. Moreover, there are various interpretations out there what an ECS is and how it works. But when you read further down you should get the idea of how the Fleks ECS can work within a Korge game.
... to be continued
- Components contain only basic (nullable) types like Int, String, Boolean, Entity, invokable (?) and set of them in Lists and Maps
- Components do not contain any Korge-related complex objects like Views, Components, etc.
- Components are easily serializable because of its basic nature
- Save game can be done by simply serializing and saving the whole ECS world snapshot (all active entities and components)
- Loading a save game is done by deserializing a saved world snapshot
- ECS Systems keep track of complex Korge objects and map them to the Entities
- For simplicity all properties of a Component shall be independent of any Korge-specific type
As a clean start the Korge-Fleks Hello World repo can be used. It contains the kproject and gradle setup to use Fleks, Korge-Fleks and Korge together in a project.
In detail the project setup looks like that:
This tells gradle that the overall project depends on a project deps in the root directory.
[...]
dependencies {
add("commonMainApi", project(":deps"))
}
This is the configuration for kproject to setup a project deps in the root directory.
It just contains two dependencies to further projects in the libs
sub-folder.
dependencies:
- ./libs/fleks
- ./libs/korge-fleks
Needed settings for gradle to make kproject usable in the project.
pluginManagement { repositories { mavenLocal(); mavenCentral(); google(); gradlePluginPortal() } }
plugins {
id("com.soywiz.kproject.settings") version "0.0.6"
}
kproject("./deps")
This is the kproject config for including Fleks sources into the Korge project.
name: fleks
type: library
# loading git tag release from GitHub repo (https://github.com/Quillraven/Fleks)
src: git::Quillraven/Fleks::/src::2.2
# using Fleks sources locally in sub-folder "libs/fleks-src"
#src: ./fleks-src
This is the kproject config for including Korge-Fleks sources into the Korge project.
name: korge-fleks
type: library
# loading git tag from GitHub repo (https://github.com/korlibs/korge-fleks)
src: git::korlibs/korge-fleks::/korge-fleks/src::0.0.1
# using Korge-Fleks sources locally in sub-folder "libs/korge-fleks"
#src: ./korge-fleks-src/korge-fleks
dependencies:
- "maven::common::com.soywiz.korlibs.korge2:korge:3.4.0"
- "./fleks"
# This is only needed if kotlinx.serialization should be used
#plugins:
# - serialization
It is important to understand that the Korge-Fleks Addon depends on specific versions of Korge and Fleks ECS. Thus, updating the version of Korge-Fleks also involves updating of Korge and Fleks versions. Do not try to update only one version until you know what you are doing.
The current triple of versions which are working together can be seen at the top of this readme in section "Supported Version-triple".
The Korge, Fleks ECS and Korge-Fleks versions need to be updated in three places:
Korge version:
[plugins]
korge = { id = "com.soywiz.korge", version = "3.4.0" }
Fleks version:
[...]
src: git::Quillraven/Fleks::/src::2.2
Korge and Korge-Fleks verions:
[...]
src: git::korlibs/korge-fleks::/korge-fleks/src::0.0.1
[...]
dependencies:
- "maven::common::com.soywiz.korlibs.korge2:korge:3.4.0"
This repo contains under korge-fleks/src
folder the korgeFleks
addon. It simplifies usage of Fleks in a KorGE
environment. For that a set of Components and Systems are implemented.
... to be continued
... to be continued
... to be continued
... to be continued