Skip to content

Commit

Permalink
Shepherd
Browse files Browse the repository at this point in the history
  • Loading branch information
rewin123 committed Dec 11, 2023
1 parent db25563 commit d9edc02
Show file tree
Hide file tree
Showing 39 changed files with 47 additions and 5 deletions.
Binary file added assets/shepherd/tile000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile014.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile016.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile017.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile019.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile020.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile021.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile022.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shepherd/tile025.png
Binary file added assets/shepherd/tile026.png
Binary file added assets/shepherd/tile027.png
Binary file added assets/shepherd/tile028.png
Binary file added assets/shepherd/tile029.png
Binary file added assets/shepherd/tile030.png
Binary file added assets/shepherd/tile031.png
Binary file added assets/shepherd/tile032.png
Binary file added assets/shepherd/tile033.png
Binary file added assets/shepherd/tile034.png
Binary file added assets/shepherd/tile035.png
Binary file added assets/shepherd/tile036.png
2 changes: 1 addition & 1 deletion src/sheep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
50 changes: 46 additions & 4 deletions src/shepherd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -25,9 +25,34 @@ impl Plugin for ShepherdPlugin {
app.add_event::<SpawnShepherd>()
.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::<ShepherdAnim>::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
}
}

Expand Down Expand Up @@ -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()
Expand All @@ -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();
Expand All @@ -135,3 +165,15 @@ fn bark_system(
}
}
}

fn set_anim(
mut query : Query<(&mut AutoAnim<ShepherdAnim>, Option<&IgniteAllTorhes>)>
) {
for (mut anim, ignite) in query.iter_mut() {
if ignite.is_some() {
anim.set = ShepherdAnim::Walk;
} else {
anim.set = ShepherdAnim::Sleep;
}
}
}

0 comments on commit d9edc02

Please sign in to comment.