module: injected mach.Entity.Mod for global entity operations
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
cb6bdd7eca
commit
65e2168b9f
11 changed files with 94 additions and 56 deletions
|
|
@ -52,6 +52,7 @@ fn deinit(
|
|||
}
|
||||
|
||||
fn init(
|
||||
entity: *mach.Entity.Mod,
|
||||
core: *mach.Core.Mod,
|
||||
sprite: *gfx.Sprite.Mod,
|
||||
sprite_pipeline: *gfx.SpritePipeline.Mod,
|
||||
|
|
@ -65,12 +66,12 @@ fn init(
|
|||
|
||||
// Create a sprite rendering pipeline
|
||||
const allocator = gpa.allocator();
|
||||
const pipeline = try core.newEntity();
|
||||
const pipeline = try entity.new();
|
||||
try sprite_pipeline.set(pipeline, .texture, try loadTexture(core, allocator));
|
||||
sprite_pipeline.send(.update, .{});
|
||||
|
||||
// Create our player sprite
|
||||
const player = try core.newEntity();
|
||||
const player = try entity.new();
|
||||
try sprite.set(player, .transform, Mat4x4.translate(vec3(-0.02, 0, 0)));
|
||||
try sprite.set(player, .size, vec2(32, 32));
|
||||
try sprite.set(player, .uv_transform, Mat3x3.translate(vec2(0, 0)));
|
||||
|
|
@ -94,6 +95,7 @@ fn init(
|
|||
}
|
||||
|
||||
fn tick(
|
||||
entity: *mach.Entity.Mod,
|
||||
core: *mach.Core.Mod,
|
||||
sprite: *gfx.Sprite.Mod,
|
||||
sprite_pipeline: *gfx.SpritePipeline.Mod,
|
||||
|
|
@ -143,7 +145,7 @@ fn tick(
|
|||
new_pos.v[0] += game.state().rand.random().floatNorm(f32) * 25;
|
||||
new_pos.v[1] += game.state().rand.random().floatNorm(f32) * 25;
|
||||
|
||||
const new_entity = try core.newEntity();
|
||||
const new_entity = try entity.new();
|
||||
try sprite.set(new_entity, .transform, Mat4x4.translate(new_pos).mul(&Mat4x4.scale(Vec3.splat(0.3))));
|
||||
try sprite.set(new_entity, .size, vec2(32, 32));
|
||||
try sprite.set(new_entity, .uv_transform, Mat3x3.translate(vec2(0, 0)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue