Cleanup
This commit is contained in:
parent
6781105af3
commit
623a06284b
|
@ -22,7 +22,7 @@ the heavy-lifting for me _plus_ it's a fun excuse to write more Rust.
|
||||||
- https://github.com/bevyengine/bevy/blob/main/examples/audio/audio.rs
|
- https://github.com/bevyengine/bevy/blob/main/examples/audio/audio.rs
|
||||||
- https://github.com/bevyengine/bevy/blob/main/examples/audio/audio_control.rs
|
- https://github.com/bevyengine/bevy/blob/main/examples/audio/audio_control.rs
|
||||||
- https://github.com/bevyengine/bevy/blob/main/examples/audio/spatial_audio_2d.rs
|
- https://github.com/bevyengine/bevy/blob/main/examples/audio/spatial_audio_2d.rs
|
||||||
- [ ] Y-sort
|
- [X] Y-sort
|
||||||
- [ ] Tile system
|
- [ ] Tile system
|
||||||
- [ ] Basic map
|
- [ ] Basic map
|
||||||
- [ ] Enemies
|
- [ ] Enemies
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::player;
|
use crate::player::Player;
|
||||||
|
use bevy::render::camera::Camera as BevyCamera;
|
||||||
|
|
||||||
pub struct Camera;
|
pub struct Camera;
|
||||||
|
|
||||||
impl Plugin for Camera {
|
impl Plugin for Camera {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(Startup, spawn)
|
app.add_systems(Startup, spawn)
|
||||||
.add_systems(PostUpdate, focus);
|
.add_systems(PostUpdate, focus)
|
||||||
|
.add_systems(Update, y_sort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +20,12 @@ fn spawn(mut commands: Commands) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus(
|
fn focus(
|
||||||
player: Query<&Transform, With<player::Player>>,
|
player: Query<&Transform, With<Player>>,
|
||||||
mut camera: Query<
|
mut camera: Query<&mut Transform, (With<BevyCamera>, Without<Player>)>,
|
||||||
&mut Transform,
|
|
||||||
(With<bevy::render::camera::Camera>, Without<player::Player>),
|
|
||||||
>,
|
|
||||||
) {
|
) {
|
||||||
let ply = player.single();
|
camera.single_mut().translation = player.single().translation
|
||||||
let mut camt = camera.single_mut();
|
}
|
||||||
camt.translation = ply.translation
|
|
||||||
|
fn y_sort(mut q: Query<&mut Transform>) {
|
||||||
|
q.for_each_mut(|mut tf| tf.translation.z = -tf.translation.y)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue