Skip to content

Instantly share code, notes, and snippets.

@cart
Last active February 15, 2021 00:02
Show Gist options
  • Save cart/96b1d39cd04274da566dbf28bf87c2a8 to your computer and use it in GitHub Desktop.
Save cart/96b1d39cd04274da566dbf28bf87c2a8 to your computer and use it in GitHub Desktop.
use bevy::prelude::*;
struct Player {
velocity: Vec3,
}
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_startup_system(spawn_player.system())
.add_system(move_player.system());
}
fn spawn_player(mut commands: Commands) {
commands.spawn((Player, Transform::default());
}
fn move_player(time: Res<Time>, mut query: Query<(&mut Transform, &Player)>) {
for (mut transform, player) in in query.iter_mut() {
transform.translation += player.velocity * time.delta_seconds();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment