From 29117837f79fd416f0bc60d016c4ecfef29ae1d8 Mon Sep 17 00:00:00 2001 From: Julia Naomi Date: Tue, 5 Dec 2023 07:46:56 -0600 Subject: [PATCH] extracts-sheep-code --- src/lib.rs | 14 +++++------- src/main.rs | 8 +------ src/physics.rs | 3 +-- src/player.rs | 50 ++++++++++++++++++++-------------------- src/sheep.rs | 58 +++++++++++++++++++++++++++++++++++++++++++++++ src/test_level.rs | 44 ++++++++--------------------------- 6 files changed, 101 insertions(+), 76 deletions(-) create mode 100644 src/sheep.rs diff --git a/src/lib.rs b/src/lib.rs index 6baad67..ecdc1cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,10 @@ #![allow(clippy::type_complexity)] pub mod debug_diagnostic; -pub mod test_level; -pub mod player; pub mod physics; +pub mod player; +pub mod sheep; +pub mod test_level; use std::f32::consts::PI; @@ -38,15 +39,12 @@ impl Plugin for GamePlugin { app.add_plugins((FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default())); } - app.add_plugins(( - player::PlayerPlugin, - physics::PhysicsPlugin, - )); + app.add_plugins((player::PlayerPlugin, physics::PhysicsPlugin)); - app.add_systems(Startup, test_level::setup); + app.add_systems(Startup, (test_level::setup, sheep::setup)); } } pub fn get_sprite_rotation() -> Quat { Quat::from_euler(EulerRot::XYZ, PI / 2.0 - PI / 4.0, 0.0, 0.0) -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index af22e2d..90b8f10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,23 +1,17 @@ // disable console on windows for release builds #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] -use bevy::pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap}; +use bevy::pbr::DirectionalLightShadowMap; use bevy::prelude::*; use bevy::window::PrimaryWindow; use bevy::winit::WinitWindows; use bevy::DefaultPlugins; use bevy_game::GamePlugin; -use std::f32::consts::PI; // ToDo: Replace bevy_game with your new crate name. use bevy::asset::AssetMetaCheck; use std::io::Cursor; use winit::window::Icon; -use rand::prelude::*; - -const TREE_PATH: &str = "test/pine.png"; -const SHEEP_PATH: &str = "test/sheep.png"; - fn main() { App::new() .insert_resource(Msaa::Off) diff --git a/src/physics.rs b/src/physics.rs index e27b241..dd61e00 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1,6 +1,5 @@ use bevy::prelude::*; - pub struct PhysicsPlugin; impl Plugin for PhysicsPlugin { @@ -16,4 +15,4 @@ fn apply_velocity(mut query: Query<(&Velocity, &mut Transform)>, time: Res