spawn ball + run in set
This commit is contained in:
parent
7b334b33c0
commit
5ba555b062
5 changed files with 92 additions and 9 deletions
35
src/states/linear/components_ball.rs
Normal file
35
src/states/linear/components_ball.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use bevy::prelude::Component;
|
||||
use rand::prelude::IndexedRandom;
|
||||
|
||||
#[derive(Component, Debug, Clone, Copy)]
|
||||
pub struct RoundBall {
|
||||
pub ball_type: RoundBallType,
|
||||
pub track_progress: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||
pub enum RoundBallType {
|
||||
#[default]
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Purple,
|
||||
}
|
||||
|
||||
impl RoundBallType {
|
||||
pub const fn asset_path(&self) -> &'static str {
|
||||
match self {
|
||||
RoundBallType::Red => "sprites/round/red.png",
|
||||
RoundBallType::Green => "sprites/round/green.png",
|
||||
RoundBallType::Blue => "sprites/round/blue.png",
|
||||
RoundBallType::Purple => "sprites/round/purple.png",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn random_from_4() -> Self {
|
||||
[Self::Red, Self::Green, Self::Blue, Self::Purple]
|
||||
.choose(&mut rand::rng())
|
||||
.copied()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue