use bevy::prelude::*;

pub struct VelocityPlugin;

impl Plugin for VelocityPlugin {
	fn build(&self, app: &mut App) {
		app.add_systems(FixedUpdate, apply_velocity);
	}
}

#[derive(Component, Default, Deref, DerefMut)]
pub struct Velocity(pub Vec2);

fn apply_velocity(time: Res<Time>, mut query: Query<(&mut Transform, &Velocity)>) {
	for (mut transform, velocity) in &mut query {
		transform.translation.x += velocity.x * time.delta_secs();
		transform.translation.y += velocity.y * time.delta_secs();
	}
}
