https://github.com/kooparse/entities
A generic system for entities with handle behavior.
https://github.com/kooparse/entities
entities game-engine gamedev generational-index zig ziglang
Last synced: 11 months ago
JSON representation
A generic system for entities with handle behavior.
- Host: GitHub
- URL: https://github.com/kooparse/entities
- Owner: kooparse
- License: mit
- Created: 2021-02-13T13:31:43.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-05T11:12:27.000Z (about 5 years ago)
- Last Synced: 2025-07-17T17:16:04.201Z (11 months ago)
- Topics: entities, game-engine, gamedev, generational-index, zig, ziglang
- Language: Zig
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Entities
Generic system of entities written in zig. Without ABA problems, using
generational index in order to access the associated data. The code is clear and simple to understand.
## Examples
```zig
usingnamespace @import("entities");
pub fn main () void {
var entities = Entities(f32).init(default_allocator);
const handle_1 = try entities.append(1.5);
const handle_2 = try entities.append(2.5);
const handle_3 = try entities.append(3.5);
// You could hardcode specific handle id.
const handle_4 = try entities.append_hard(4.5, 55);
// Getting the inner data by using associated handle.
print("{}\n", .{entities.get(handle_2)});
// Removes data using bucket pooling.
entities.remove(handle_1);
// Iterator over all active handles.
var it = entities.interate();
while(it.next()) |datum| {
print("datum: {}\n", .{datum.*});
}
}
```