Booster strafing

This commit is contained in:
dawnDus 2022-02-25 21:49:14 -05:00
parent f26f019584
commit 7db42e86e6
No known key found for this signature in database
GPG Key ID: 972AABDE81848F21
1 changed files with 32 additions and 14 deletions

View File

@ -47,7 +47,8 @@ impl TargetPlayer {
enum BoosterSwitch {
None,
Up,
Sides,
Left,
Right,
Down,
}
@ -205,8 +206,10 @@ impl Player {
}
if state.control_flags.control_enabled() {
if self.controller.move_up() && self.controller.trigger_strafe() {
self.strafe_up = true;
if self.controller.trigger_strafe() {
if self.controller.move_up() {
self.strafe_up = true;
}
} else if !self.controller.strafe() {
self.strafe_up = false;
}
@ -286,7 +289,7 @@ impl Player {
if state.control_flags.control_enabled() {
if self.controller.trigger_jump() && self.booster_fuel != 0 {
if self.equip.has_booster_0_8() {
self.booster_switch = BoosterSwitch::Sides;
self.booster_switch = BoosterSwitch::Up;
if self.vel_y > 0x100 {
self.vel_y /= 2;
@ -297,11 +300,11 @@ impl Player {
self.vel_x = 0;
self.vel_y = state.constants.booster.b2_0_up;
} else if self.controller.move_left() {
self.booster_switch = BoosterSwitch::Sides;
self.booster_switch = BoosterSwitch::Left;
self.vel_x = state.constants.booster.b2_0_left;
self.vel_y = 0;
} else if self.controller.move_right() {
self.booster_switch = BoosterSwitch::Sides;
self.booster_switch = BoosterSwitch::Right;
self.vel_x = state.constants.booster.b2_0_right;
self.vel_y = 0;
} else if self.controller.move_down() {
@ -340,7 +343,7 @@ impl Player {
&& (!self.controller.jump() || self.booster_fuel == 0)
{
match self.booster_switch {
BoosterSwitch::Sides => self.vel_x /= 2,
BoosterSwitch::Left | BoosterSwitch::Right => self.vel_x /= 2,
BoosterSwitch::Up => self.vel_y /= 2,
_ => (),
}
@ -400,25 +403,40 @@ impl Player {
&& self.booster_switch != BoosterSwitch::None
{
match self.booster_switch {
BoosterSwitch::Sides => {
BoosterSwitch::Left | BoosterSwitch::Right => {
if self.flags.hit_left_wall() || self.flags.hit_right_wall() {
self.vel_y = -0x100;
}
if self.direction == Direction::Left {
self.vel_x -= 0x20;
}
if self.direction == Direction::Right {
self.vel_x += 0x20;
let mut booster_dir = self.direction;
if self.controller.strafe() {
if self.controller.move_left() {
self.booster_switch = BoosterSwitch::Left;
} else if self.controller.move_right() {
self.booster_switch = BoosterSwitch::Right;
}
if self.booster_switch == BoosterSwitch::Left {
booster_dir = Direction::Left;
} else if self.booster_switch == BoosterSwitch::Right {
booster_dir = Direction::Right;
}
}
self.vel_x += match booster_dir {
Direction::Left => -0x20,
Direction::Right => 0x20,
_ => 0,
};
if self.controller.trigger_jump() || self.booster_fuel % 3 == 1 {
if self.direction == Direction::Left || self.direction == Direction::Right {
state.create_caret(
self.x + 0x400,
self.y + 0x400,
CaretType::Exhaust,
self.direction.opposite(),
booster_dir.opposite(),
);
}
state.sound_manager.play_sfx(113);