use bevy::prelude::*; use crate::collision::check_collision_with_player; use crate::collision::{Collider, HasCollided}; use crate::obstacle::RegenerateObstacles; const FALL_SPEED: f32 = 600.0; // Falling speed const DIVE_SPEED: f32 = 1000.0; // Falling speed sped up const HORIZONTAL_SPEED: f32 = 350.0; // Lateral movement speed pub const START_POSITION: Vec3 = Vec3::new(0.0, 0.0, 2.0); // Start position const RATE: f32 = 13.0; // Inertia rate // The player #[derive(Component)] pub struct Player; // Speed of the player #[derive(Component)] pub struct Velocity(Vec2); // Falling bool #[derive(Resource, Default)] pub struct FallStarted(pub bool); // Spawn entity player fn spawn_player(mut commands: Commands) { commands.spawn(( Player, Collider { size: Vec2::new(20.0, 40.0), }, Velocity(Vec2::ZERO), Sprite::from_color(Color::srgb(1.0, 1.0, 1.0), Vec2::new(20.0, 40.0)), Transform::from_xyz(START_POSITION.x, START_POSITION.y, START_POSITION.z), )); } // Input + movement system for the player pub(crate) fn move_player( input: Res>, time: Res