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