Giter VIP home page Giter VIP logo

tnecs's Introduction

![tnecs](logo.png "tnecs logo")

tnecs (Tiny nECS)

Tiny C99 Entity-Component-System (ECS) library. Read the Tutorial.

Originally created for use in a game I am developping using C99: Codename Firesaga. Title pending.

ECSs are an alternative way to organize data and functions to Object-Oriented programming (OOP).

  • OOP: Objects/Classes contain data and methods. Methods act on objects. Children classes inherit methods and data structure from parents.
  • ECS: Components are purely data. Any number of components can be attached to an entity. Entities are acted upon by systems.

Videogame Example:

  • Enemy Entity: AIControlled component, Sprite Component, Physics Component
  • Bullet Entity: Sprite Component, Physics Component, DamageonHit Component
  • Main Character Entity: UserControlled Component, Sprite Component, Physics Component

In tnecs, an entity is an uint64_t index. A component is user-defined struct. A system is a user-defined function. All live inside the world.

The systems iterate over the entities that have a user-defined set of components, inclusively or exclusively, in phases. Phases are user-defined uint8_t. System execution order is first-come first-served by default. For more in-depth discussion about tnecs' design, see the On Design.

Installation

Add tnecs.c and tnecs.h to your source code.

Motivation

Make the simplest possible C99 ECS library, only with the minimum necessary features. Compile with tcc.

ToDo:

  • Thread Safety?

Features

  • Compatible: compiles with tcc, gcc and clang
  • Cross-platform: Windows, Linux, Android (termux)
  • Small: <1700 lines, 2 files.
  • Fast: see benchmarks in test.c
  • Simple: C99 API
  • Independent: only dependent on C99 standard libraries
  • FOSS: Free and Open Source

Alternative ECS/Gamedev libraries for C/C++

Special Thanks

Sanders Mertens for his blog on ECS design. He created many other resources on ECSs.

Credits

Copyright (c) 2021 Average Bear Games, Made by Gabriel Taillon

tnecs's People

Contributors

gabinou avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.