Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove orphan Panning component and related code #104

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ https://user-images.githubusercontent.com/1379590/175423671-0dc7bea3-6c63-42ed-a

https://fishfight.github.io/punchy/demo/

## Controls

| Action | ⌨️ Keyboard | ⌨️ Player 2 | 🎮 Gamepad |
| ----------------- | ------------------------------- | ------------------------ | ---------------- |
| Movement | W / S / A / D | Up / Down / Left / Right | Left Stick, DPad |
| Throw Item | C | Period | West |
| Shoot | V | Right Shift | East |
| Flop Attack | Spacebar | Comma | South |
| Zoom Camera | Ctrl + + / - | ❌️ | ❌️ |
| Pan Camera | Ctrl + Up / Down / Left / Right | ❌️ | ❌️ |
| Pause/Unpause | Escape / P | ❌ ️ | Start |
| Toggle Fullscreen | F11 | ❌️ | Select |

## Contributing

Anyone involved in the Fish Fight community must follow our [code of conduct](https://github.com/fishfight/FishFight/blob/main/CODE_OF_CONDUCT.md).
Expand Down
17 changes: 4 additions & 13 deletions src/camera.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
use bevy::{
math::Vec2,
prelude::{Camera, Component, EventWriter, Query, Res, Transform, With, Without},
};
use bevy::prelude::{Camera, EventWriter, Query, Res, Transform, With, Without};
use bevy_parallax::ParallaxMoveEvent;

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

#[cfg_attr(feature = "debug", derive(bevy_inspector_egui::Inspectable))]
#[derive(Component)]
pub struct Panning {
pub offset: Vec2,
}

/// 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).
pub fn camera_follow_player(
player_query: Query<&Transform, With<Player>>,
mut camera_query: Query<(&mut Transform, &Panning), (With<Camera>, Without<Player>)>,
camera_query: Query<&Transform, (With<Camera>, Without<Player>)>,
mut move_event_writer: EventWriter<ParallaxMoveEvent>,
game_meta: Res<GameMeta>,
) {
Expand All @@ -26,14 +17,14 @@ pub fn camera_follow_player(
.max_by(|ax, bx| ax.total_cmp(bx));

if let Some(max_player_x) = max_player_x {
let (mut camera, panning) = camera_query.single_mut();
let camera = camera_query.single();

let max_player_x_diff =
max_player_x - camera.translation.x - game_meta.camera_move_right_boundary;

if max_player_x_diff > 0. {
// The x axis is handled by the parallax plugin.
camera.translation.y = consts::GROUND_Y + panning.offset.y;
// The y axis value doesn't change.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should still be made, but most of the other changes were already done in #100.


move_event_writer.send(ParallaxMoveEvent {
camera_move_speed: max_player_x_diff * consts::CAMERA_SPEED,
Expand Down
5 changes: 0 additions & 5 deletions src/game_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use leafwing_input_manager::{
};

use crate::{
camera::Panning,
consts,
input::MenuAction,
metadata::{BorderImageMeta, GameMeta},
GameState,
Expand Down Expand Up @@ -108,9 +106,6 @@ impl<'w, 's> GameLoader<'w, 's> {
camera_bundle.orthographic_projection.scale = game.camera_height as f32 / 2.0;
commands
.spawn_bundle(camera_bundle)
.insert(Panning {
offset: Vec2::new(0., -consts::GROUND_Y),
})
.insert(ParallaxCameraComponent)
// We also add another input manager bundle for `MenuAction`s
.insert_bundle(InputManagerBundle {
Expand Down