1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-09-27 12:38:57 +00:00
doukutsu-rs/src/physics.rs

490 lines
20 KiB
Rust
Raw Normal View History

use num_traits::clamp;
2020-09-19 13:19:00 +00:00
use crate::caret::CaretType;
2020-09-12 21:41:33 +00:00
use crate::common::{Condition, Direction, Flag, Rect};
use crate::shared_game_state::SharedGameState;
use crate::stage::Stage;
use crate::npc::list::NPCList;
2021-06-21 11:12:58 +00:00
// -2 -1 0 1 2 3
// +------------------
// -2 | 26 32 33 34 35 36
// -1 | 27 10 14 15 16 18
// 0 | 28 11 1 2 5 19
// 1 | 29 12 3 4 6 20
// 2 | 30 13 8 9 7 21
// 3 | 31 22 23 24 25 17
pub const OFF_X: [i32; 36] = [
0, 1, 0, 1, 2, 2,
2, 0, 1, -1, -1, -1,
-1, 0, 1, 2, 3, 3,
3, 3, 3, -1, 0, 1,
2, -2, -2, -2, -2, -2,
-2, -1, 0, 1, 2, 3 ];
pub const OFF_Y: [i32; 36] = [
0, 0, 1, 1, 0, 1,
2, 2, 2, -1, 0, 1,
2, -1, -1, -1, 3, -1,
0, 1, 2, 3, 3, 3,
3, -2, -1, 0, 1, 2,
3, -2, -2, -2, -2, -2 ];
pub trait PhysicalEntity {
2021-01-01 01:46:01 +00:00
fn x(&self) -> i32;
fn y(&self) -> i32;
fn vel_x(&self) -> i32;
fn vel_y(&self) -> i32;
2020-10-01 03:06:18 +00:00
fn hit_rect_size(&self) -> usize;
2021-01-01 01:46:01 +00:00
fn offset_x(&self) -> i32 { 0 }
fn offset_y(&self) -> i32 { 0 }
fn hit_bounds(&self) -> &Rect<u32>;
2021-01-01 01:46:01 +00:00
fn set_x(&mut self, x: i32);
fn set_y(&mut self, y: i32);
fn set_vel_x(&mut self, x: i32);
fn set_vel_y(&mut self, y: i32);
fn cond(&mut self) -> &mut Condition;
fn flags(&mut self) -> &mut Flag;
2020-09-12 21:41:33 +00:00
fn direction(&self) -> Direction;
fn is_player(&self) -> bool;
fn ignore_tile_44(&self) -> bool { true }
2020-11-28 19:25:51 +00:00
fn player_left_pressed(&self) -> bool { false }
fn player_right_pressed(&self) -> bool { false }
2021-05-05 16:34:23 +00:00
fn test_block_hit(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
let bounds_x = if self.is_player() { 0x600 } else { 0x600 };
2021-06-21 11:12:58 +00:00
let bounds_top = if self.is_player() { 0x800 } else { 0x600 };
let bounds_bottom = if self.is_player() { 0x800 } else { 0x600 };
let half_tile_size = 16 * 0x100;
2021-05-05 16:34:23 +00:00
// left wall
2021-06-21 11:12:58 +00:00
if (self.y() - self.hit_bounds().top as i32) < ((y * 2 + 1) * half_tile_size - bounds_top)
&& (self.y() + self.hit_bounds().bottom as i32) > ((y * 2 - 1) * half_tile_size + bounds_bottom)
&& (self.x() - self.hit_bounds().right as i32) < (x * 2 + 1) * half_tile_size
&& (self.x() - self.hit_bounds().right as i32) > (x * 2) * half_tile_size {
self.set_x(((x * 2 + 1) * half_tile_size) + self.hit_bounds().right as i32);
if self.is_player() {
if self.vel_x() < -0x180 {
self.set_vel_x(-0x180);
}
2020-11-28 19:25:51 +00:00
if !self.player_left_pressed() && self.vel_x() < 0 {
self.set_vel_x(0);
}
}
self.flags().set_hit_left_wall(true);
}
// right wall
2021-06-21 11:12:58 +00:00
if (self.y() - self.hit_bounds().top as i32) < ((y * 2 + 1) * half_tile_size - bounds_top)
&& (self.y() + self.hit_bounds().bottom as i32) > ((y * 2 - 1) * half_tile_size + bounds_bottom)
&& (self.x() + self.hit_bounds().right as i32) > (x * 2 - 1) * half_tile_size
&& (self.x() + self.hit_bounds().right as i32) < (x * 2) * half_tile_size {
self.set_x(((x * 2 - 1) * half_tile_size) - self.hit_bounds().right as i32);
if self.is_player() {
if self.vel_x() > 0x180 {
self.set_vel_x(0x180);
}
2020-11-28 19:25:51 +00:00
if !self.player_right_pressed() && self.vel_x() > 0 {
self.set_vel_x(0);
}
}
self.flags().set_hit_right_wall(true);
}
// ceiling
2021-06-21 11:12:58 +00:00
if ((self.x() - self.hit_bounds().right as i32) < (x * 2 + 1) * half_tile_size - bounds_x)
&& ((self.x() + self.hit_bounds().right as i32) > (x * 2 - 1) * half_tile_size + bounds_x)
&& (self.y() - self.hit_bounds().top as i32) < (y * 2 + 1) * half_tile_size
&& (self.y() - self.hit_bounds().top as i32) > (y * 2) * half_tile_size {
self.set_y(((y * 2 + 1) * half_tile_size) + self.hit_bounds().top as i32);
if self.is_player() {
if !self.cond().hidden() && self.vel_y() < -0x200 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(3);
2021-01-01 01:46:01 +00:00
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
}
if self.vel_y() < 0 {
self.set_vel_y(0);
}
} else {
self.set_vel_y(0);
}
self.flags().set_hit_top_wall(true);
}
// floor
2021-06-21 11:12:58 +00:00
if ((self.x() - self.hit_bounds().right as i32) < (x * 2 + 1) * half_tile_size - bounds_x)
&& ((self.x() + self.hit_bounds().right as i32) > (x * 2 - 1) * half_tile_size + bounds_x)
&& ((self.y() + self.hit_bounds().bottom as i32) > ((y * 2 - 1) * half_tile_size))
&& ((self.y() + self.hit_bounds().bottom as i32) < (y * 2) * half_tile_size) {
self.set_y(((y * 2 - 1) * half_tile_size) - self.hit_bounds().bottom as i32);
if self.is_player() {
if self.vel_y() > 0x400 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(23);
}
if self.vel_y() > 0 {
self.set_vel_y(0);
}
} else {
self.set_vel_y(0);
}
self.flags().set_hit_bottom_wall(true);
}
}
// upper left slope (bigger half)
2021-05-05 16:34:23 +00:00
fn test_hit_upper_left_slope_high(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
2020-09-09 16:25:39 +00:00
if self.x() < (x * 16 + 8) * 0x200
&& self.x() > (x * 16 - 8) * 0x200
2021-05-05 16:34:23 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 0x2000) - (self.x() - x * 0x2000) / 2 + 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 16 - 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) - ((self.x() - x * 0x2000) / 2) + 0x800 + self.hit_bounds().top as i32);
if self.is_player() && !self.cond().hidden() && self.vel_y() < -0x200 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(3);
2021-01-01 01:46:01 +00:00
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
}
if self.vel_y() < 0 {
self.set_vel_y(0);
}
self.flags().set_hit_top_wall(true);
}
}
// upper left slope (smaller half)
2021-05-05 16:34:23 +00:00
fn test_hit_upper_left_slope_low(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
2020-09-09 16:25:39 +00:00
if self.x() < (x * 16 + 8) * 0x200
&& self.x() > (x * 16 - 8) * 0x200
2021-05-05 16:34:23 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 0x2000) - (self.x() - x * 0x2000) / 2 - 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 16 - 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) - ((self.x() - x * 0x2000) / 2) - 0x800 + self.hit_bounds().top as i32);
if self.is_player() && !self.cond().hidden() && self.vel_y() < -0x200 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(3);
2021-01-01 01:46:01 +00:00
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
}
if self.vel_y() < 0 {
self.set_vel_y(0);
}
self.flags().set_hit_top_wall(true);
}
}
// upper right slope (smaller half)
2021-05-05 16:34:23 +00:00
fn test_hit_upper_right_slope_low(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
2020-09-09 16:25:39 +00:00
if self.x() < (x * 16 + 8) * 0x200
&& self.x() > (x * 16 - 8) * 0x200
2021-05-05 16:34:23 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 0x2000) + (self.x() - x * 0x2000) / 2 - 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 16 - 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) + ((self.x() - x * 0x2000) / 2) - 0x800 + self.hit_bounds().top as i32);
if self.is_player() && !self.cond().hidden() && self.vel_y() < -0x200 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(3);
2021-01-01 01:46:01 +00:00
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
}
if self.vel_y() < 0 {
self.set_vel_y(0);
}
self.flags().set_hit_top_wall(true);
}
}
// upper right slope (bigger half)
2021-05-05 16:34:23 +00:00
fn test_hit_upper_right_slope_high(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
2020-09-09 16:25:39 +00:00
if (self.x() < (x * 16 + 8) * 0x200)
&& (self.x() > (x * 16 - 8) * 0x200)
2021-05-05 16:34:23 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 0x2000) + (self.x() - x * 0x2000) / 2 + 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 16 - 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) + ((self.x() - x * 0x2000) / 2) + 0x800 + self.hit_bounds().top as i32);
if self.is_player() && !self.cond().hidden() && self.vel_y() < -0x200 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(3);
2021-01-01 01:46:01 +00:00
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
state.create_caret(self.x(), self.y() - self.hit_bounds().top as i32, CaretType::LittleParticles, Direction::Left);
}
if self.vel_y() < 0 {
self.set_vel_y(0);
}
self.flags().set_hit_top_wall(true);
}
}
// lower left half (bigger)
2021-05-05 16:34:23 +00:00
fn test_hit_lower_left_slope_high(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
self.flags().set_hit_left_higher_half(true);
2020-09-09 16:25:39 +00:00
if (self.x() < (x * 16 + 8) * 0x200)
&& (self.x() > (x * 16 - 8) * 0x200)
2021-05-05 16:34:23 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 0x2000) + (self.x() - x * 0x2000) / 2 - 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 16 + 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) + ((self.x() - x * 0x2000) / 2) - 0x800 - self.hit_bounds().bottom as i32);
if self.is_player() && self.vel_y() > 0x400 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(23);
}
if self.vel_y() > 0 {
self.set_vel_y(0);
}
self.flags().set_hit_left_slope(true);
self.flags().set_hit_bottom_wall(true);
}
}
// lower left half (smaller)
2021-05-05 16:34:23 +00:00
fn test_hit_lower_left_slope_low(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
self.flags().set_hit_left_lower_half(true);
2020-09-09 16:25:39 +00:00
if (self.x() < (x * 16 + 8) * 0x200)
&& (self.x() > (x * 16 - 8) * 0x200)
2021-05-05 16:34:23 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 0x2000) + (self.x() - x * 0x2000) / 2 + 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 16 + 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) + ((self.x() - x * 0x2000) / 2) + 0x800 - self.hit_bounds().bottom as i32);
if self.is_player() && self.vel_y() > 0x400 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(23);
}
if self.vel_y() > 0 {
self.set_vel_y(0);
}
self.flags().set_hit_left_slope(true);
self.flags().set_hit_bottom_wall(true);
}
}
// lower right half (smaller)
2021-05-05 16:34:23 +00:00
fn test_hit_lower_right_slope_low(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
self.flags().set_hit_right_lower_half(true);
2020-09-09 16:25:39 +00:00
if (self.x() < (x * 16 + 8) * 0x200)
&& (self.x() > (x * 16 - 8) * 0x200)
2021-05-05 16:34:23 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 0x2000) - (self.x() - x * 0x2000) / 2 + 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 16 + 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) - ((self.x() - x * 0x2000) / 2) + 0x800 - self.hit_bounds().bottom as i32);
if self.is_player() && self.vel_y() > 0x400 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(23);
}
if self.vel_y() > 0 {
self.set_vel_y(0);
}
self.flags().set_hit_right_slope(true);
self.flags().set_hit_bottom_wall(true);
}
}
// lower right half (bigger)
2021-05-05 16:34:23 +00:00
fn test_hit_lower_right_slope_high(&mut self, state: &mut SharedGameState, x: i32, y: i32) {
self.flags().set_hit_right_higher_half(true);
2020-09-09 16:25:39 +00:00
if (self.x() < (x * 16 + 8) * 0x200)
&& (self.x() > (x * 16 - 8) * 0x200)
2021-05-05 16:34:23 +00:00
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 0x2000) - (self.x() - x * 0x2000) / 2 - 0x800
2021-01-01 01:46:01 +00:00
&& (self.y() - self.hit_bounds().top as i32) < (y * 16 + 8) * 0x200 {
2021-05-05 16:34:23 +00:00
self.set_y((y * 0x2000) - ((self.x() - x * 0x2000) / 2) - 0x800 - self.hit_bounds().bottom as i32);
if self.is_player() && self.vel_y() > 0x400 {
2020-09-19 13:19:00 +00:00
state.sound_manager.play_sfx(23);
}
if self.vel_y() > 0 {
self.set_vel_y(0);
}
self.flags().set_hit_right_slope(true);
self.flags().set_hit_bottom_wall(true);
}
}
2021-05-05 16:34:23 +00:00
fn test_hit_water(&mut self, x: i32, y: i32) {
2020-09-19 13:19:00 +00:00
let bounds_x = if self.is_player() { 5 } else { 6 };
let bounds_up = if self.is_player() { 5 } else { 6 };
let bounds_down = if self.is_player() { 0 } else { 6 };
2021-01-01 01:46:01 +00:00
if (self.x() - self.hit_bounds().right as i32) < (x * 16 + bounds_x) * 0x200
&& (self.x() + self.hit_bounds().right as i32) > (x * 16 - bounds_x) * 0x200
&& (self.y() - self.hit_bounds().top as i32) < (y * 16 + bounds_up) * 0x200
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 16 - bounds_down) * 0x200 {
self.flags().set_in_water(true);
}
}
2021-05-05 16:34:23 +00:00
fn test_hit_spike(&mut self, x: i32, y: i32, water: bool) {
2020-09-09 16:25:39 +00:00
if (self.x() - 0x800) < (x * 16 + 4) * 0x200
&& (self.x() + 0x800) > (x * 16 - 4) * 0x200
&& (self.y() - 0x800) < (y * 16 + 3) * 0x200
&& (self.y() + 0x800) > (y * 16 - 3) * 0x200 {
self.flags().set_hit_by_spike(true);
2020-09-12 21:41:33 +00:00
if water {
self.flags().set_in_water(true);
}
}
}
2021-05-05 16:34:23 +00:00
fn test_hit_force(&mut self, x: i32, y: i32, direction: Direction, water: bool) {
2021-01-01 01:46:01 +00:00
if (self.x() - self.hit_bounds().left as i32) < (x * 16 + 6) * 0x200
&& (self.x() + self.hit_bounds().right as i32) > (x * 16 - 6) * 0x200
&& (self.y() - self.hit_bounds().top as i32) < (y * 16 + 6) * 0x200
&& (self.y() + self.hit_bounds().bottom as i32) > (y * 16 - 6) * 0x200 {
2020-09-12 21:41:33 +00:00
match direction {
2020-09-30 03:11:25 +00:00
Direction::Left => self.flags().set_force_left(true),
Direction::Up => self.flags().set_force_up(true),
Direction::Right => self.flags().set_force_right(true),
Direction::Bottom => self.flags().set_force_down(true),
Direction::FacingPlayer => unreachable!(),
2020-09-12 21:41:33 +00:00
}
if water {
self.flags().set_in_water(true);
}
}
}
fn tick_map_collisions(&mut self, state: &mut SharedGameState, _npc_list: &NPCList, stage: &mut Stage) {
2020-10-01 03:06:18 +00:00
let hit_rect_size = clamp(self.hit_rect_size(), 1, 4);
let hit_rect_size = hit_rect_size * hit_rect_size;
let x = (self.x() + self.offset_x()) / (0x2000);
let y = (self.y() + self.offset_y()) / (0x2000);
2020-10-01 03:06:18 +00:00
self.flags().0 = 0;
for (idx, (&ox, &oy)) in OFF_X.iter().zip(OFF_Y.iter()).enumerate() {
2020-10-01 03:06:18 +00:00
if idx == hit_rect_size {
break;
}
let attrib = stage.map.get_attribute((x + ox) as usize, (y + oy) as usize);
match attrib {
// Spikes
0x62 | 0x42 if self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_hit_spike(x + ox, y + oy, attrib & 0x20 != 0);
}
// Blocks
2020-09-19 13:19:00 +00:00
0x02 | 0x60 => {
2021-05-05 16:34:23 +00:00
self.test_hit_water(x + ox, y + oy);
}
2020-09-19 13:19:00 +00:00
0x62 if !self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_hit_water(x + ox, y + oy);
2020-09-19 13:19:00 +00:00
}
0x61 => {
2021-05-05 16:34:23 +00:00
self.test_block_hit(state, x + ox, y + oy);
self.test_hit_water(x + ox, y + oy);
2020-09-19 13:19:00 +00:00
}
0x04 | 0x64 if !self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_block_hit(state, x + ox, y + oy);
self.test_hit_water(x + ox, y + oy);
2020-09-19 13:19:00 +00:00
}
0x05 | 0x41 | 0x43 | 0x46 if self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_block_hit(state, x + ox, y + oy);
}
0x03 | 0x05 | 0x41 | 0x43 if !self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_block_hit(state, x + ox, y + oy);
}
0x44 => {
if !self.ignore_tile_44() {
2021-05-05 16:34:23 +00:00
self.test_block_hit(state, x + ox, y + oy);
}
}
// Slopes
0x50 | 0x70 => {
2021-05-05 16:34:23 +00:00
self.test_hit_upper_left_slope_high(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
0x51 | 0x71 => {
2021-05-05 16:34:23 +00:00
self.test_hit_upper_left_slope_low(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
0x52 | 0x72 => {
2021-05-05 16:34:23 +00:00
self.test_hit_upper_right_slope_low(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
0x53 | 0x73 => {
2021-05-05 16:34:23 +00:00
self.test_hit_upper_right_slope_high(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
0x54 | 0x74 => {
2021-05-05 16:34:23 +00:00
self.test_hit_lower_left_slope_high(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
0x55 | 0x75 => {
2021-05-05 16:34:23 +00:00
self.test_hit_lower_left_slope_low(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
0x56 | 0x76 => {
2021-05-05 16:34:23 +00:00
self.test_hit_lower_right_slope_low(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
0x57 | 0x77 => {
2021-05-05 16:34:23 +00:00
self.test_hit_lower_right_slope_high(state, x + ox, y + oy);
if attrib & 0x20 != 0 { self.test_hit_water(x + ox, y + oy); }
}
// Forces
2020-09-19 13:19:00 +00:00
0x80 | 0xa0 if self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_hit_force(x + ox, y + oy, Direction::Left, attrib & 0x20 != 0);
2020-09-19 13:19:00 +00:00
}
0x81 | 0xa1 if self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_hit_force(x + ox, y + oy, Direction::Up, attrib & 0x20 != 0);
2020-09-19 13:19:00 +00:00
}
0x82 | 0xa2 if self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_hit_force(x + ox, y + oy, Direction::Right, attrib & 0x20 != 0);
2020-09-19 13:19:00 +00:00
}
0x83 | 0xa3 if self.is_player() => {
2021-05-05 16:34:23 +00:00
self.test_hit_force(x + ox, y + oy, Direction::Bottom, attrib & 0x20 != 0);
2020-09-19 13:19:00 +00:00
}
0x80 | 0xa0 if !self.is_player() => {
self.flags().set_force_left(true);
if attrib & 0x20 != 0 { self.flags().set_in_water(true); }
}
2020-09-19 13:19:00 +00:00
0x81 | 0xa1 if !self.is_player() => {
self.flags().set_force_up(true);
if attrib & 0x20 != 0 { self.flags().set_in_water(true); }
}
2020-09-19 13:19:00 +00:00
0x82 | 0xa2 if !self.is_player() => {
self.flags().set_force_right(true);
if attrib & 0x20 != 0 { self.flags().set_in_water(true); }
}
2020-09-19 13:19:00 +00:00
0x83 | 0xa3 if !self.is_player() => {
self.flags().set_force_down(true);
if attrib & 0x20 != 0 { self.flags().set_in_water(true); }
}
_ => {}
}
}
}
2020-09-04 23:08:33 +00:00
}