35 lines
No EOL
896 B
Rust
35 lines
No EOL
896 B
Rust
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()
|
|
}
|
|
} |