Bevy Log 🕹
Trying to learn Bevy 2 days after picking up Rust. Let’s see how this goes !!!
Their home page calls Bevy “refeshingly simple” lol.
Bevy implements an Entity Component System rather than traditional Object-Oriented Programing
3 things: Entity Component Systems
Componenet:
#[derive(Component)]
struct Position {x: f32, y: f32}
#[derive(Component)]
struct Velocity {x: f32, y: f32 }
This entire block of code below is a System.
fn spawn_spaceship(mut commands: Commands) {
commands.spawn((
Position {x: 0.0, y:, 0.0} // entity
Velocity{x: 1/0, y:1.0} // entity
));
}
“Data is stored in components and behavior in systems.”
Beyv: World is a data structure that stores and exposes operations on all the entities and components in the application
What are commands?
- Commands are how we alter game state. Equivalent to insert/delete
commands.spawn((
Position {x: 0.0, y:, 0.0} // entity
Velocity{x: 1/0, y:1.0} // entity
));
What are queries?
- Immediate access to existing components. Equivalent to read/write
fn update_position(mut query: Query<(&Velocity, &mut Position)>)