-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate improvements from jam 🧃
feat: add pixel and resizable features refactor: game camera now has its own module change: now the background color is rendered differently change: different ui cleaning
- Loading branch information
Showing
14 changed files
with
225 additions
and
213 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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,67 @@ | ||
use bevy::{ | ||
core_pipeline::clear_color::ClearColorConfig, | ||
prelude::*, | ||
}; | ||
use bevy_persistent::Persistent; | ||
|
||
use crate::{ | ||
GameOptions, | ||
GameState, | ||
}; | ||
|
||
// TODO: Option for pixel perfect upscaling camera | ||
|
||
// ······ | ||
// Plugin | ||
// ······ | ||
|
||
pub struct CameraPlugin; | ||
|
||
impl Plugin for CameraPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_systems(OnEnter(GameState::Play), init_camera) | ||
.add_systems( | ||
Update, | ||
change_background.run_if( | ||
in_state(GameState::Play).and_then(resource_changed::< | ||
Persistent<GameOptions>, | ||
>()), | ||
), | ||
) | ||
.add_systems(OnExit(GameState::Play), pause_camera); | ||
} | ||
} | ||
|
||
// ·········· | ||
// Components | ||
// ·········· | ||
|
||
#[derive(Component)] | ||
struct GameCamera; | ||
|
||
// ······· | ||
// Systems | ||
// ······· | ||
|
||
fn init_camera(mut cmd: Commands, mut cam: Query<&mut Camera, With<GameCamera>>) { | ||
if let Ok(mut cam) = cam.get_single_mut() { | ||
cam.is_active = true; | ||
} else { | ||
cmd.spawn((Camera2dBundle::default(), GameCamera)); | ||
} | ||
} | ||
|
||
fn change_background( | ||
opts: Res<Persistent<GameOptions>>, | ||
mut cam: Query<&mut Camera2d, With<GameCamera>>, | ||
) { | ||
if let Ok(mut cam) = cam.get_single_mut() { | ||
cam.clear_color = ClearColorConfig::Custom(opts.color.dark); | ||
} | ||
} | ||
|
||
fn pause_camera(mut cam: Query<&mut Camera, With<GameCamera>>) { | ||
if let Ok(mut cam) = cam.get_single_mut() { | ||
cam.is_active = false; | ||
} | ||
} |
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
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
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
Oops, something went wrong.