Skip to content

Commit

Permalink
New example
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarumych committed Jun 23, 2024
1 parent a68a163 commit bc5481e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions examples/alive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use edict::{component::Component, query::Entities, world::World};

#[derive(Debug, Component)]
struct A;

#[derive(Debug, Component)]
struct B;

fn main() {
let mut world = World::new();

world.spawn((A, B));

let bs = world.view::<&B>();

for (e, a) in world.view::<(Entities, &A)>() {
if let Some(b) = bs.get(e) {
println!("A {:?} has B {:?}", a, b);
}
}
}
6 changes: 3 additions & 3 deletions examples/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ fn main() {
Pos { x: -1.0, y: 0.0 },
];

let mut scheduler = Scheduler::new();
scheduler.add_system(move_to_system);

world.spawn_flow_for(
e,
flow_fn!(|mut e| {
Expand All @@ -142,6 +139,9 @@ fn main() {
}),
);

let mut scheduler = Scheduler::new();
scheduler.add_system(move_to_system);

loop {
world.insert_resource(DeltaTime(0.1));

Expand Down

0 comments on commit bc5481e

Please sign in to comment.