Skip to content

Commit

Permalink
Remove camera (manual) zoom (and related system)
Browse files Browse the repository at this point in the history
  • Loading branch information
64kramsystem committed Jul 16, 2022
1 parent 9e0aadf commit 0ed4798
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ https://fishfight.github.io/punchy/demo/
| Throw Item | C | Period | West |
| Shoot | V | Right Shift | East |
| Flop Attack | Spacebar | Comma | South |
| Zoom Camera | Ctrl + + / - | ❌️ | ❌️ |
| Pause/Unpause | Escape / P | ❌ ️ | Start |
| Toggle Fullscreen | F11 | ❌️ | Select |

Expand Down
46 changes: 2 additions & 44 deletions src/camera.rs
Original file line number Diff line number Diff line change
@@ -1,49 +1,7 @@
use bevy::{
core::Time,
prelude::{
Camera, EventWriter, OrthographicProjection, Query, Res, ResMut, Transform, With, Without,
},
render::camera::CameraProjection,
window::Windows,
};
use bevy::prelude::{Camera, EventWriter, Query, Res, Transform, With, Without};
use bevy_parallax::ParallaxMoveEvent;
use leafwing_input_manager::prelude::ActionState;

use crate::{consts, input::CameraAction, metadata::GameMeta, Player};

pub fn helper_camera_controller(
mut query: Query<(
&mut Camera,
&mut OrthographicProjection,
&ActionState<CameraAction>,
)>,
time: Res<Time>,
mut windows: ResMut<Windows>,
) {
let (mut camera, mut projection, input) = query.single_mut();

use CameraAction::*;

if input.pressed(ZoomIn) {
projection.scale = f32::clamp(
projection.scale - 150. * time.delta_seconds(),
1.,
projection.scale,
);
}
if input.pressed(ZoomOut) {
projection.scale += 150. * time.delta_seconds();
}

let scale = projection.scale;
let window = windows.primary_mut();

if (projection.scale - scale).abs() > f32::EPSILON {
projection.update(window.width(), window.height());
camera.projection_matrix = projection.get_projection_matrix();
camera.depth_calculation = projection.depth_calculation();
}
}
use crate::{consts, metadata::GameMeta, Player};

/// Moves the camera according to the RIGHT_BOUNDARY_DISTANCE. Note that this does not enforce
/// limitations of any kind - that's up to the players movement logic (e.g. max distance).
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ fn main() {
.with_system(spawn_throwable_items)
.with_system(player_controller)
.with_system(player_flop)
.with_system(helper_camera_controller)
.with_system(y_sort)
.with_system(player_attack_enemy_collision)
.with_system(enemy_attack_player_collision)
Expand Down

0 comments on commit 0ed4798

Please sign in to comment.