examples: add initial ecs-app
This is a temporary application to begin iterating on high-level ECS applications. Eventually, this will be removed - for now it's just here so we can see how this API looks today and improve it. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
6ec27861b4
commit
d3b03901fb
4 changed files with 96 additions and 1 deletions
26
examples/ecs-app/physics2d.zig
Normal file
26
examples/ecs-app/physics2d.zig
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const mach = @import("mach");
|
||||
const ecs = mach.ecs;
|
||||
const std = @import("std");
|
||||
|
||||
pub const Message = ecs.Messages(.{
|
||||
.tick = void,
|
||||
});
|
||||
|
||||
pub const module = ecs.Module(.{
|
||||
.components = .{
|
||||
.location = Vec2,
|
||||
.rotation = Vec2,
|
||||
.velocity = Vec2,
|
||||
},
|
||||
.messages = Message,
|
||||
.update = update,
|
||||
});
|
||||
|
||||
pub const Vec2 = struct { x: f32, y: f32 };
|
||||
|
||||
fn update(msg: Message) void {
|
||||
switch (msg) {
|
||||
// TODO: implement queries, ability to set components, etc.
|
||||
.tick => std.debug.print("\nphysics tick!\n", .{}),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue