-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a camera plugin, add draft level component
- Loading branch information
Showing
3 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use bevy::prelude::*; | ||
|
||
use crate::{state::AppState, WINDOW_WIDTH}; | ||
pub struct CameraPlugin; | ||
|
||
#[derive(SystemSet, Clone, Hash, Debug, PartialEq, Eq)] | ||
pub struct CollisionState; | ||
|
||
impl Plugin for CameraPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_systems(Startup, setup_camera); | ||
app.add_systems(OnEnter(AppState::GameCreate), move_camera); | ||
} | ||
} | ||
|
||
fn setup_camera(mut commands: Commands) { | ||
commands.spawn(Camera2dBundle { | ||
transform: Transform::from_xyz(0.0, 0.0, 0.0), | ||
..Default::default() | ||
}); | ||
} | ||
|
||
fn move_camera(mut camera_query: Query<&mut Transform, With<Camera2d>>) { | ||
let mut camera = camera_query.single_mut(); | ||
camera.translation.x = -WINDOW_WIDTH / 2.0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters