Resolve all warnings
This commit is contained in:
parent
3d5df31da7
commit
f2c604e489
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -468,6 +468,7 @@ dependencies = [
|
|||
"bevy_time",
|
||||
"bevy_utils",
|
||||
"const-fnv1a-hash",
|
||||
"sysinfo",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2276,6 +2277,15 @@ version = "0.5.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51"
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
|
@ -3122,6 +3132,20 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.30.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"ntapi",
|
||||
"once_cell",
|
||||
"windows 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "taffy"
|
||||
version = "0.5.2"
|
||||
|
|
|
@ -21,13 +21,13 @@ bevy = { version = "0.14.0", default-features = false, features = [
|
|||
"trace", # tracing is nice
|
||||
"wayland",
|
||||
"wav", # sound files
|
||||
"sysinfo_plugin", # probably will want this for troubleshooting or just surfacing useful information to the gamer (such as FPS?)
|
||||
|
||||
# TODO: would be nice to get this working while developing
|
||||
"dynamic_linking",
|
||||
|
||||
# NOTE: Features we may want at some point.
|
||||
# "vorbis", # music -- maybe mp3?
|
||||
# "sysinfo_plugin", # probably will want this for troubleshooting or just surfacing useful information to the gamer
|
||||
# "bevy_gizmos", # debug geometry?
|
||||
# "track_change_detection", # for hot-reloading of assets? (scripts?)
|
||||
# "file_watcher", # for hot-reloading of assets? (scripts?)
|
||||
|
|
|
@ -2,17 +2,24 @@ use bevy::prelude::*;
|
|||
|
||||
#[derive(Resource, Debug, Default)]
|
||||
pub struct AssetLoader {
|
||||
pub images: Sprites,
|
||||
pub layouts: Layouts,
|
||||
pub images: Images,
|
||||
pub sounds: Sounds,
|
||||
pub fonts: Fonts,
|
||||
}
|
||||
|
||||
#[derive(Resource, Debug, Default)]
|
||||
pub struct Sprites {
|
||||
pub struct Layouts {
|
||||
pub player: Handle<TextureAtlasLayout>,
|
||||
pub statue: Handle<TextureAtlasLayout>,
|
||||
}
|
||||
|
||||
#[derive(Resource, Debug, Default)]
|
||||
pub struct Images {
|
||||
pub player: Handle<Image>,
|
||||
pub statue: Handle<Image>,
|
||||
}
|
||||
|
||||
#[derive(Resource, Debug, Default)]
|
||||
pub struct Sounds {
|
||||
pub meow: Handle<AudioSource>,
|
||||
|
@ -28,6 +35,9 @@ pub fn startup(
|
|||
asset_server: Res<AssetServer>,
|
||||
mut texture_atlases: ResMut<Assets<TextureAtlasLayout>>,
|
||||
) {
|
||||
let props = asset_server.load("img/Props.png");
|
||||
let player = asset_server.load("img/Player.png");
|
||||
|
||||
let player_atlas = TextureAtlasLayout::from_grid(
|
||||
UVec2::new(32, 64),
|
||||
3,
|
||||
|
@ -42,7 +52,11 @@ pub fn startup(
|
|||
let statue_atlas_handle = texture_atlases.add(statue_atlas);
|
||||
|
||||
*assets = AssetLoader {
|
||||
images: Sprites {
|
||||
images: Images {
|
||||
player,
|
||||
statue: props.clone(),
|
||||
},
|
||||
layouts: Layouts {
|
||||
player: player_atlas_handle,
|
||||
statue: statue_atlas_handle,
|
||||
},
|
||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -19,9 +19,8 @@ pub enum Game {
|
|||
|
||||
#[derive(States, Default, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum View {
|
||||
// #[default]
|
||||
// LoadingScreen,
|
||||
#[default]
|
||||
LoadingScreen,
|
||||
MainMenu,
|
||||
InGame,
|
||||
}
|
||||
|
@ -32,7 +31,7 @@ struct MainMenuSet;
|
|||
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
struct InGameSet;
|
||||
|
||||
fn main() {
|
||||
fn main() -> AppExit {
|
||||
let mut app = App::new();
|
||||
|
||||
app.add_plugins((
|
||||
|
@ -55,17 +54,21 @@ fn main() {
|
|||
FrameTimeDiagnosticsPlugin,
|
||||
))
|
||||
.init_resource::<assets::AssetLoader>()
|
||||
.insert_state(View::default())
|
||||
.insert_state(Game::default())
|
||||
.init_state::<View>()
|
||||
.init_state::<Game>()
|
||||
.add_systems(OnEnter(View::MainMenu), main_menu::startup)
|
||||
.add_systems(OnExit(View::MainMenu), main_menu::exit)
|
||||
.add_systems(OnEnter(View::InGame), (player::startup, statue::startup))
|
||||
.add_systems(OnExit(View::InGame), (player::exit, statue::exit))
|
||||
.add_systems(Startup, (startup, assets::startup, camera::startup))
|
||||
.add_systems(
|
||||
OnEnter(View::LoadingScreen),
|
||||
(startup, assets::startup, camera::startup),
|
||||
)
|
||||
.add_systems(
|
||||
Update,
|
||||
(
|
||||
update,
|
||||
finish_setup.run_if(in_state(View::LoadingScreen)),
|
||||
(
|
||||
player::sprite_select,
|
||||
player::controls,
|
||||
|
@ -91,8 +94,7 @@ fn main() {
|
|||
// brightness: 1.,
|
||||
// });
|
||||
|
||||
let exit = app.run();
|
||||
info!("Exit: {:#?}", exit);
|
||||
app.run()
|
||||
}
|
||||
|
||||
fn toggle_fullscreen(mut window: Mut<Window>) {
|
||||
|
@ -106,6 +108,10 @@ fn toggle_fullscreen(mut window: Mut<Window>) {
|
|||
#[derive(Component)]
|
||||
struct FpsText;
|
||||
|
||||
fn finish_setup(mut app_state: ResMut<NextState<View>>) {
|
||||
app_state.set(View::MainMenu);
|
||||
}
|
||||
|
||||
fn startup(mut commands: Commands, assets: Res<assets::AssetLoader>) {
|
||||
commands.spawn((
|
||||
FpsText,
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
struct SystemSet;
|
||||
|
||||
#[derive(Component, Deref, DerefMut, Debug, Default)]
|
||||
pub struct Velocity(pub Vec2);
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ use bevy::{prelude::*, window::PrimaryWindow};
|
|||
|
||||
use crate::camera::Watched;
|
||||
use crate::movement::YSortable;
|
||||
use crate::statue;
|
||||
use crate::{
|
||||
assets::AssetLoader,
|
||||
movement::{Heading, Mover, Speed, Velocity},
|
||||
statue::Statue,
|
||||
};
|
||||
|
||||
const PLAYER_SPEED: f32 = 1000.;
|
||||
|
@ -21,22 +21,21 @@ pub struct Crosshair;
|
|||
pub fn startup(
|
||||
mut commands: Commands,
|
||||
assets: Res<AssetLoader>,
|
||||
asset_server: Res<AssetServer>,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||
) {
|
||||
let texture = asset_server.load("img/Player.png");
|
||||
let listener = SpatialListener::new(1.);
|
||||
|
||||
commands
|
||||
.spawn((Player, YSortable, Watched))
|
||||
.with_children(|player| {
|
||||
player.spawn((
|
||||
SpriteSheetBundle {
|
||||
texture,
|
||||
transform: Transform::from_scale(Vec3::new(2., 2., 1.)),
|
||||
atlas: assets.images.player.clone().into(),
|
||||
sprite: Sprite::default(),
|
||||
SpriteBundle {
|
||||
texture: assets.images.player.clone().into(),
|
||||
..default()
|
||||
},
|
||||
TextureAtlas {
|
||||
layout: assets.layouts.player.clone().into(),
|
||||
..default()
|
||||
},
|
||||
Mover {
|
||||
|
@ -92,7 +91,6 @@ pub fn startup(
|
|||
pub fn controls(
|
||||
mut commands: Commands,
|
||||
mut player_q: Query<(&mut Sprite, &mut TextureAtlas, &mut Heading, Entity), With<Player>>,
|
||||
asset_server: Res<AssetServer>,
|
||||
input: Res<ButtonInput<KeyCode>>,
|
||||
mouse_input: Res<ButtonInput<MouseButton>>,
|
||||
assets: Res<AssetLoader>,
|
||||
|
@ -130,19 +128,7 @@ pub fn controls(
|
|||
.map(|ray| ray.origin.truncate())
|
||||
{
|
||||
let spos = world_position.extend(-world_position.y);
|
||||
let statue_texture = asset_server.load("img/Props.png").clone();
|
||||
commands.spawn((
|
||||
Statue,
|
||||
SpriteSheetBundle {
|
||||
texture: statue_texture,
|
||||
atlas: TextureAtlas {
|
||||
layout: assets.images.statue.clone(),
|
||||
index: 0,
|
||||
},
|
||||
transform: Transform::from_translation(spos),
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
commands.spawn(statue::statue_at_position(&assets, spos));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -4,34 +4,33 @@ use bevy::prelude::*;
|
|||
#[derive(Component, Debug)]
|
||||
pub struct Statue;
|
||||
|
||||
pub fn startup(mut commands: Commands, assets: Res<AssetLoader>, asset_server: Res<AssetServer>) {
|
||||
let texture = asset_server.load("img/Props.png");
|
||||
commands.spawn((
|
||||
pub fn statue_at_position(
|
||||
assets: &Res<AssetLoader>,
|
||||
translation: Vec3,
|
||||
) -> (
|
||||
Statue,
|
||||
YSortable,
|
||||
bevy::prelude::SpriteBundle,
|
||||
bevy::prelude::TextureAtlas,
|
||||
) {
|
||||
(
|
||||
Statue,
|
||||
YSortable,
|
||||
SpriteSheetBundle {
|
||||
texture: texture.clone(),
|
||||
atlas: TextureAtlas {
|
||||
layout: assets.images.statue.clone(),
|
||||
index: 0,
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::new(50., 50., 0.)),
|
||||
..Default::default()
|
||||
SpriteBundle {
|
||||
transform: Transform::from_translation(translation),
|
||||
texture: assets.images.statue.clone(),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
commands.spawn((
|
||||
Statue,
|
||||
YSortable,
|
||||
SpriteSheetBundle {
|
||||
texture: texture.clone(),
|
||||
atlas: TextureAtlas {
|
||||
layout: assets.images.statue.clone(),
|
||||
index: 0,
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::new(50., 100., 0.)),
|
||||
..Default::default()
|
||||
TextureAtlas {
|
||||
layout: assets.layouts.statue.clone(),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
)
|
||||
}
|
||||
|
||||
pub fn startup(mut commands: Commands, assets: Res<AssetLoader>) {
|
||||
commands.spawn(statue_at_position(&assets, Vec3::new(50., 50., 0.)));
|
||||
commands.spawn(statue_at_position(&assets, Vec3::new(50., 100., 0.)));
|
||||
}
|
||||
|
||||
pub fn exit(mut commands: Commands, q: Query<Entity, With<Statue>>) {
|
||||
|
|
Loading…
Reference in a new issue