Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/centau/ecr
A sparse-set based ECS library for Luau.
https://github.com/centau/ecr
ecs entity-component-system game-development library luau roblox
Last synced: about 2 months ago
JSON representation
A sparse-set based ECS library for Luau.
- Host: GitHub
- URL: https://github.com/centau/ecr
- Owner: centau
- License: mit
- Created: 2022-11-12T12:57:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-27T19:22:42.000Z (4 months ago)
- Last Synced: 2024-08-27T21:26:35.640Z (4 months ago)
- Topics: ecs, entity-component-system, game-development, library, luau, roblox
- Language: Luau
- Homepage: https://centau.github.io/ecr/
- Size: 390 KB
- Stars: 38
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-roblox - ECR - A sparse-set based ECS library for Luau. (Libraries / Entity Component System)
README
#
### ⚠️ This library is in early stages of development with breaking changes being made often.
ECR is a Luau ECS library.
- A library and not a framework
- Uses typechecking.
- Sparse-set based storage that can support perfect SoA.
- Carefully optimized memory usage and performance.
- Signals for detecting changes to components.## Getting started
Read the [crash course](https://centau.github.io/ecr/tut/crash-course) for a
brief introduction to the library.## Code sample
```lua
local ecr = require(ecr)-- define components
local Position = ecr.component() :: Vector3
local Velocity = ecr.component() :: Vector3-- define a system
local function update_physics(world: ecr.Registry, dt: number)
for id, pos, vel in world:view(Position, Velocity) do
world:set(id, Position, pos + vel*dt)
end
end-- instantiate the world
local world = ecr.registry()-- create entities and assign components
for i = 1, 10 do
local id = world:create()
world:set(id, Position, Vector3.new(i, 1, 1))
world:set(id, Velocity, Vector3.new(10, 0, 0))
end-- run system
update_physics(world, 1/60)
```