1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-09-28 21:19:24 +00:00

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

View file

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