diff --git a/assets/shepherd/tile000.png b/assets/shepherd/tile000.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile000.png differ diff --git a/assets/shepherd/tile001.png b/assets/shepherd/tile001.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile001.png differ diff --git a/assets/shepherd/tile002.png b/assets/shepherd/tile002.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile002.png differ diff --git a/assets/shepherd/tile003.png b/assets/shepherd/tile003.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile003.png differ diff --git a/assets/shepherd/tile004.png b/assets/shepherd/tile004.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile004.png differ diff --git a/assets/shepherd/tile005.png b/assets/shepherd/tile005.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile005.png differ diff --git a/assets/shepherd/tile006.png b/assets/shepherd/tile006.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile006.png differ diff --git a/assets/shepherd/tile007.png b/assets/shepherd/tile007.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile007.png differ diff --git a/assets/shepherd/tile008.png b/assets/shepherd/tile008.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile008.png differ diff --git a/assets/shepherd/tile009.png b/assets/shepherd/tile009.png new file mode 100644 index 0000000..1250564 Binary files /dev/null and b/assets/shepherd/tile009.png differ diff --git a/assets/shepherd/tile010.png b/assets/shepherd/tile010.png new file mode 100644 index 0000000..554534a Binary files /dev/null and b/assets/shepherd/tile010.png differ diff --git a/assets/shepherd/tile011.png b/assets/shepherd/tile011.png new file mode 100644 index 0000000..fafde64 Binary files /dev/null and b/assets/shepherd/tile011.png differ diff --git a/assets/shepherd/tile012.png b/assets/shepherd/tile012.png new file mode 100644 index 0000000..87b44d3 Binary files /dev/null and b/assets/shepherd/tile012.png differ diff --git a/assets/shepherd/tile013.png b/assets/shepherd/tile013.png new file mode 100644 index 0000000..2111aaf Binary files /dev/null and b/assets/shepherd/tile013.png differ diff --git a/assets/shepherd/tile014.png b/assets/shepherd/tile014.png new file mode 100644 index 0000000..11cab4b Binary files /dev/null and b/assets/shepherd/tile014.png differ diff --git a/assets/shepherd/tile015.png b/assets/shepherd/tile015.png new file mode 100644 index 0000000..11cab4b Binary files /dev/null and b/assets/shepherd/tile015.png differ diff --git a/assets/shepherd/tile016.png b/assets/shepherd/tile016.png new file mode 100644 index 0000000..11cab4b Binary files /dev/null and b/assets/shepherd/tile016.png differ diff --git a/assets/shepherd/tile017.png b/assets/shepherd/tile017.png new file mode 100644 index 0000000..11cab4b Binary files /dev/null and b/assets/shepherd/tile017.png differ diff --git a/assets/shepherd/tile018.png b/assets/shepherd/tile018.png new file mode 100644 index 0000000..11cab4b Binary files /dev/null and b/assets/shepherd/tile018.png differ diff --git a/assets/shepherd/tile019.png b/assets/shepherd/tile019.png new file mode 100644 index 0000000..11cab4b Binary files /dev/null and b/assets/shepherd/tile019.png differ diff --git a/assets/shepherd/tile020.png b/assets/shepherd/tile020.png new file mode 100644 index 0000000..b9c3d61 Binary files /dev/null and b/assets/shepherd/tile020.png differ diff --git a/assets/shepherd/tile021.png b/assets/shepherd/tile021.png new file mode 100644 index 0000000..b9c3d61 Binary files /dev/null and b/assets/shepherd/tile021.png differ diff --git a/assets/shepherd/tile022.png b/assets/shepherd/tile022.png new file mode 100644 index 0000000..59aa1ce Binary files /dev/null and b/assets/shepherd/tile022.png differ diff --git a/assets/shepherd/tile023.png b/assets/shepherd/tile023.png new file mode 100644 index 0000000..59aa1ce Binary files /dev/null and b/assets/shepherd/tile023.png differ diff --git a/assets/shepherd/tile024.png b/assets/shepherd/tile024.png new file mode 100644 index 0000000..518f76d Binary files /dev/null and b/assets/shepherd/tile024.png differ diff --git a/assets/shepherd/tile025.png b/assets/shepherd/tile025.png new file mode 100644 index 0000000..518f76d Binary files /dev/null and b/assets/shepherd/tile025.png differ diff --git a/assets/shepherd/tile026.png b/assets/shepherd/tile026.png new file mode 100644 index 0000000..88e1c18 Binary files /dev/null and b/assets/shepherd/tile026.png differ diff --git a/assets/shepherd/tile027.png b/assets/shepherd/tile027.png new file mode 100644 index 0000000..88e1c18 Binary files /dev/null and b/assets/shepherd/tile027.png differ diff --git a/assets/shepherd/tile028.png b/assets/shepherd/tile028.png new file mode 100644 index 0000000..81919d3 Binary files /dev/null and b/assets/shepherd/tile028.png differ diff --git a/assets/shepherd/tile029.png b/assets/shepherd/tile029.png new file mode 100644 index 0000000..81919d3 Binary files /dev/null and b/assets/shepherd/tile029.png differ diff --git a/assets/shepherd/tile030.png b/assets/shepherd/tile030.png new file mode 100644 index 0000000..81919d3 Binary files /dev/null and b/assets/shepherd/tile030.png differ diff --git a/assets/shepherd/tile031.png b/assets/shepherd/tile031.png new file mode 100644 index 0000000..9f53b1a Binary files /dev/null and b/assets/shepherd/tile031.png differ diff --git a/assets/shepherd/tile032.png b/assets/shepherd/tile032.png new file mode 100644 index 0000000..9f53b1a Binary files /dev/null and b/assets/shepherd/tile032.png differ diff --git a/assets/shepherd/tile033.png b/assets/shepherd/tile033.png new file mode 100644 index 0000000..9f53b1a Binary files /dev/null and b/assets/shepherd/tile033.png differ diff --git a/assets/shepherd/tile034.png b/assets/shepherd/tile034.png new file mode 100644 index 0000000..5003fde Binary files /dev/null and b/assets/shepherd/tile034.png differ diff --git a/assets/shepherd/tile035.png b/assets/shepherd/tile035.png new file mode 100644 index 0000000..5003fde Binary files /dev/null and b/assets/shepherd/tile035.png differ diff --git a/assets/shepherd/tile036.png b/assets/shepherd/tile036.png new file mode 100644 index 0000000..5003fde Binary files /dev/null and b/assets/shepherd/tile036.png differ diff --git a/src/sheep.rs b/src/sheep.rs index 11ef239..6958387 100644 --- a/src/sheep.rs +++ b/src/sheep.rs @@ -464,7 +464,7 @@ pub fn setup( let mut exact_sheep_count = 0; - for _ in 0..sheep_count { + while exact_sheep_count < sheep_count { let x = rng.gen_range(-r..r); let y = 0.0; let z = rng.gen_range(-r..r); diff --git a/src/shepherd.rs b/src/shepherd.rs index 6f8f581..085b19c 100644 --- a/src/shepherd.rs +++ b/src/shepherd.rs @@ -8,7 +8,7 @@ use crate::{ player::{Bark, DOG_ACCELERATION, DOG_SPEED}, sunday::DayState, torch::{IgniteTorch, TorchBase}, - GameSet, GameStuff, + GameSet, GameStuff, auto_anim::{AutoAnimPlugin, AutoAnim, AnimSet, AnimRange}, }; const SHEPHERD_PATH: &str = "test/Knight.png"; @@ -25,9 +25,34 @@ impl Plugin for ShepherdPlugin { app.add_event::() .add_systems( Update, - (spawn_shepherd_system, ignite_all_torhes, bark_system).in_set(GameSet::Playing), + (spawn_shepherd_system, ignite_all_torhes, bark_system, set_anim).in_set(GameSet::Playing), ) - .add_systems(OnEnter(DayState::Evening), start_ignite_torches); + .add_systems(OnEnter(DayState::Evening), start_ignite_torches) + .add_plugins(AutoAnimPlugin::::default()); + } +} + +#[derive(Default)] +pub enum ShepherdAnim { + #[default] + Sleep, + Walk +} + +impl AnimSet for ShepherdAnim { + fn get_folder_path() -> String { + "shepherd".to_string() + } + + fn get_index_range(&self) -> crate::auto_anim::AnimRange { + match self { + ShepherdAnim::Sleep => AnimRange::new(0, 19), + ShepherdAnim::Walk => AnimRange::new(20,27), + } + } + + fn get_tile_count() -> usize { + 37 } } @@ -100,7 +125,7 @@ fn spawn_shepherd_system( PbrBundle { transform: Transform::from_translation(event.pos) .with_rotation(get_sprite_rotation()) - .with_scale(Vec3::new(1.0, 1.0, 2.0)), + .with_scale(Vec3::new(3.0, 3.0, 3.0)), material: materials.add(StandardMaterial { base_color_texture: Some(asset_server.load(SHEPHERD_PATH)), ..default() @@ -115,6 +140,11 @@ fn spawn_shepherd_system( target_velocity: Vec3::ZERO, }, GameStuff, + AutoAnim { + set : ShepherdAnim::Sleep, + current_frame: 0, + timer: Timer::from_seconds(0.1, TimerMode::Repeating) + } )); } events.clear(); @@ -135,3 +165,15 @@ fn bark_system( } } } + +fn set_anim( + mut query : Query<(&mut AutoAnim, Option<&IgniteAllTorhes>)> +) { + for (mut anim, ignite) in query.iter_mut() { + if ignite.is_some() { + anim.set = ShepherdAnim::Walk; + } else { + anim.set = ShepherdAnim::Sleep; + } + } +} \ No newline at end of file