Implemented camera rotation and zooming

This commit is contained in:
Lorenzo Torres 2025-08-13 03:44:25 +02:00
parent 68ccaf8b68
commit d537d89819
10 changed files with 153 additions and 18 deletions

View file

@ -138,6 +138,8 @@ export fn sideros_init(init: api.GameInit) callconv(.c) void {
.input = &input,
};
ecs.hooks.init(allocator) catch @panic("TODO: handle this");
ecs.hooks.addHook(.scroll, systems.zoomCamera) catch @panic("TODO handle this");
pool = ecs.Pool.init(allocator, &resources) catch @panic("TODO: Gracefully handle error");
// TODO(ernesto): I think this @ptrCast are unavoidable but maybe not?
renderer = Renderer.init(allocator, @ptrCast(init.instance), @ptrCast(init.surface)) catch @panic("TODO: Gracefully handle error");
@ -178,3 +180,9 @@ export fn sideros_key_callback(key: u32, release: bool) callconv(.c) void {
}
}
}
export fn sideros_scroll_callback(up: bool) callconv(.c) void {
for (ecs.hooks.scroll.items) |hook| {
hook(&pool, if (up) .up else .down) catch @panic("TODO: actually handle this");
}
}