Skip to content

Commit

Permalink
Merge pull request #16 from claby2/additional-changes
Browse files Browse the repository at this point in the history
Additional changes
  • Loading branch information
virchau13 authored Mar 4, 2022
2 parents 43118f3 + 70297d9 commit a922882
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ _The last known specimens of the Andor flower, the flower with the tastiest nect

Head over to the **upgrades** menu to pick out upgrades to optimize your playstyle and gain an **unfair advantage**.

Upgrades consist of both passive and active abilities. Active abilities can be activated with either the left or right mouse button, depending on which upgrade slot it is in.
Upgrades consist of both passive and active abilities.
Active abilities can be activated with either the left mouse button (or <kbd>Q</kbd>) or the right mouse button (or <kbd>E</kbd>), depending on which upgrade slot it is in.

Made with [Bevy Engine](https://bevyengine.org/).

Expand Down
4 changes: 2 additions & 2 deletions src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ fn create_help(mut commands: Commands, font: Res<GameFont>) {
"Head over to the upgrades menu to gain an \"unfair\" advantage!\n",
"\n",
"Some upgrades can be activated using mouse buttons:\n",
"Left Click - Use primary upgrade\n",
"Right Click - Use secondary upgrade",
"Left Click or Q - Use primary upgrade\n",
"Right Click or E - Use secondary upgrade",
];

parent.spawn_bundle(TextBundle {
Expand Down
3 changes: 2 additions & 1 deletion src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,12 @@ fn detect_collision(
fn teleport(
windows: Res<Windows>,
camera: Query<(&Camera, &GlobalTransform), With<MainCamera>>,
keyboard_input: Res<Input<KeyCode>>,
button_input: Res<Input<MouseButton>>,
upgrades: Res<UpgradeTracker>,
mut player: Query<&mut Transform, With<Player>>,
) {
if upgrades.was_upgrade_activated(button_input, Upgrade::Teleport) {
if upgrades.was_upgrade_activated(keyboard_input, button_input, Upgrade::Teleport) {
let (camera, camera_transform) = camera.single();
let window = windows.get(camera.window).unwrap();

Expand Down
9 changes: 7 additions & 2 deletions src/upgrades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,16 @@ impl UpgradeTracker {

pub fn was_upgrade_activated(
&self,
keyboard_input: Res<Input<KeyCode>>,
button_input: Res<Input<MouseButton>>,
upgrade: Upgrade,
) -> bool {
(self.primary == Some(upgrade) && button_input.just_pressed(MouseButton::Left))
|| (self.secondary == Some(upgrade) && button_input.just_pressed(MouseButton::Right))
(self.primary == Some(upgrade)
&& (button_input.just_pressed(MouseButton::Left)
|| keyboard_input.just_pressed(KeyCode::Q)))
|| (self.secondary == Some(upgrade)
&& (button_input.just_pressed(MouseButton::Right)
|| keyboard_input.just_pressed(KeyCode::E)))
}

pub fn has_upgrade(&self, upgrade: Upgrade) -> bool {
Expand Down
23 changes: 16 additions & 7 deletions src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,30 @@ pub struct GameWorld {
pub layout: Vec<Vec<Option<Tile>>>,
}

pub const LEVELS: [(&'static str, &'static str); 8] = [
pub const LEVELS: [(&str, &str); 8] = [
(
"Closing Doors",
include_str!("../assets/levels/Levels_-_Beeline_-_Closing_Doors.tsv"),
),
("Cornered", include_str!("../assets/levels/cornered.tsv")),
(
"Serpentine",
include_str!("../assets/levels/Beeline_-_Serpentine.tsv"),
),
(
"Snakes on a Plane",
include_str!("../assets/levels/snakes-on-a-plane.tsv"),
),
("Chicken", include_str!("../assets/levels/chicken.tsv")),
("Maze", include_str!("../assets/levels/maze.tsv")),
(
"Down The Road",
include_str!("../assets/levels/down-the-road.tsv"),
),
(
"Drift",
include_str!("../assets/levels/Levels_-_Beeline_-_Drift.tsv"),
),
("Maze", include_str!("../assets/levels/maze.tsv")),
("Down The Road", include_str!("../assets/levels/down-the-road.tsv")),
("Closing Doors", include_str!("../assets/levels/Levels_-_Beeline_-_Closing_Doors.tsv")),
("Snakes on a Plane", include_str!("../assets/levels/snakes-on-a-plane.tsv")),
("Cornered", include_str!("../assets/levels/cornered.tsv")),
("Chicken", include_str!("../assets/levels/chicken.tsv"))
];

impl GameWorld {
Expand Down

0 comments on commit a922882

Please sign in to comment.