mach/examples/ecs-app/physics2d.zig
Stephen Gutekanst d3b03901fb 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>
2022-07-04 22:25:39 -07:00

26 lines
562 B
Zig

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", .{}),
}
}