formatting
This commit is contained in:
parent
f7e2c263ba
commit
ed23befd26
@ -10,7 +10,7 @@ pub fn build(b: *Builder) void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (examples) |example, i| {
|
for (examples) |example, i| {
|
||||||
const name = example[0];
|
const name = if (i == 0) "ecs" else example[0];
|
||||||
const source = example[1];
|
const source = example[1];
|
||||||
|
|
||||||
var exe = b.addExecutable(name, source);
|
var exe = b.addExecutable(name, source);
|
||||||
@ -23,7 +23,6 @@ pub fn build(b: *Builder) void {
|
|||||||
|
|
||||||
// first element in the list is added as "run" so "zig build run" works
|
// first element in the list is added as "run" so "zig build run" works
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
exe.name = "ecs";
|
|
||||||
exe.setOutputDir("zig-cache/bin");
|
exe.setOutputDir("zig-cache/bin");
|
||||||
const run_exe_step = b.step("run", b.fmt("run {}.zig", .{name}));
|
const run_exe_step = b.step("run", b.fmt("run {}.zig", .{name}));
|
||||||
run_exe_step.dependOn(&run_cmd.step);
|
run_exe_step.dependOn(&run_cmd.step);
|
||||||
|
@ -19,13 +19,13 @@ pub fn main() !void {
|
|||||||
reg.add(e2, Position{ .x = 10, .y = 10 });
|
reg.add(e2, Position{ .x = 10, .y = 10 });
|
||||||
reg.add(e2, Velocity{ .x = 15, .y = 17 });
|
reg.add(e2, Velocity{ .x = 15, .y = 17 });
|
||||||
|
|
||||||
var view = reg.view(.{Velocity, Position});
|
var view = reg.view(.{ Velocity, Position });
|
||||||
|
|
||||||
var iter = view.iterator();
|
var iter = view.iterator();
|
||||||
while (iter.next()) |entity| {
|
while (iter.next()) |entity| {
|
||||||
var pos = view.get(Position, entity);
|
var pos = view.get(Position, entity);
|
||||||
const vel = view.getConst(Velocity, entity);
|
const vel = view.getConst(Velocity, entity);
|
||||||
std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{entity, pos.*, vel});
|
std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos.*, vel });
|
||||||
pos.*.x += vel.x;
|
pos.*.x += vel.x;
|
||||||
pos.*.y += vel.y;
|
pos.*.y += vel.y;
|
||||||
}
|
}
|
||||||
@ -36,6 +36,6 @@ pub fn main() !void {
|
|||||||
while (iter.next()) |entity| {
|
while (iter.next()) |entity| {
|
||||||
const pos = view.getConst(Position, entity);
|
const pos = view.getConst(Position, entity);
|
||||||
const vel = view.getConst(Velocity, entity);
|
const vel = view.getConst(Velocity, entity);
|
||||||
std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{entity, pos, vel});
|
std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos, vel });
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -287,7 +287,7 @@ test "context not pointer" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "component context get/set/unset" {
|
test "component context get/set/unset" {
|
||||||
const SomeType = struct { dummy: u1};
|
const SomeType = struct { dummy: u1 };
|
||||||
|
|
||||||
var reg = Registry.init(std.testing.allocator);
|
var reg = Registry.init(std.testing.allocator);
|
||||||
defer reg.deinit();
|
defer reg.deinit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user