mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-12-01 00:29:58 +00:00
parent
588b0d53dd
commit
8a2e9fa569
|
|
@ -8,6 +8,7 @@ use crate::framework::graphics::screen_insets_scaled;
|
||||||
use crate::inventory::Inventory;
|
use crate::inventory::Inventory;
|
||||||
use crate::player::Player;
|
use crate::player::Player;
|
||||||
use crate::shared_game_state::SharedGameState;
|
use crate::shared_game_state::SharedGameState;
|
||||||
|
use crate::weapon::WeaponType;
|
||||||
|
|
||||||
pub struct HUD {
|
pub struct HUD {
|
||||||
pub alignment: Alignment,
|
pub alignment: Alignment,
|
||||||
|
|
@ -111,12 +112,26 @@ impl GameEntity<(&Player, &mut Inventory)> for HUD {
|
||||||
if player.controller.trigger_next_weapon() {
|
if player.controller.trigger_next_weapon() {
|
||||||
state.sound_manager.play_sfx(4);
|
state.sound_manager.play_sfx(4);
|
||||||
inventory.next_weapon();
|
inventory.next_weapon();
|
||||||
|
|
||||||
|
if let Some(weapon) = inventory.get_current_weapon_mut() {
|
||||||
|
if weapon.wtype == WeaponType::Spur {
|
||||||
|
weapon.reset_xp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.weapon_x_pos = 32;
|
self.weapon_x_pos = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if player.controller.trigger_prev_weapon() {
|
if player.controller.trigger_prev_weapon() {
|
||||||
state.sound_manager.play_sfx(4);
|
state.sound_manager.play_sfx(4);
|
||||||
inventory.prev_weapon();
|
inventory.prev_weapon();
|
||||||
|
|
||||||
|
if let Some(weapon) = inventory.get_current_weapon_mut() {
|
||||||
|
if weapon.wtype == WeaponType::Spur {
|
||||||
|
weapon.reset_xp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.weapon_x_pos = 0;
|
self.weapon_x_pos = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -889,7 +889,7 @@ impl NPC {
|
||||||
self.target_x = player.x;
|
self.target_x = player.x;
|
||||||
|
|
||||||
if player.up {
|
if player.up {
|
||||||
self.target_y = player.y + if grounded { -0x1400 } else { 0x1000 };
|
self.target_y = player.y + if grounded { -0x1800 } else { 0x1000 };
|
||||||
self.anim_num = if grounded { 1 } else { 2 };
|
self.anim_num = if grounded { 1 } else { 2 };
|
||||||
self.direction = if grounded { Direction::Up } else { Direction::Bottom };
|
self.direction = if grounded { Direction::Up } else { Direction::Bottom };
|
||||||
} else if player.down && !grounded {
|
} else if player.down && !grounded {
|
||||||
|
|
@ -926,56 +926,41 @@ impl NPC {
|
||||||
npc_list: &NPCList,
|
npc_list: &NPCList,
|
||||||
bullet_manager: &mut BulletManager,
|
bullet_manager: &mut BulletManager,
|
||||||
) -> GameResult {
|
) -> GameResult {
|
||||||
if self.action_num == 0 {
|
if let Some(npc) = self.get_parent_ref_mut(npc_list) {
|
||||||
if let Some(npc) = self.get_parent_ref_mut(npc_list) {
|
let player = &players[0];
|
||||||
let player = &players[0];
|
|
||||||
|
|
||||||
self.direction = npc.direction;
|
self.direction = npc.direction;
|
||||||
self.x = npc.x;
|
self.x = npc.x;
|
||||||
self.y = npc.y;
|
self.y = npc.y;
|
||||||
|
|
||||||
match self.direction {
|
match self.direction {
|
||||||
Direction::Right => {
|
Direction::Right => {
|
||||||
self.x += 0x1000;
|
self.x += 0x1000;
|
||||||
}
|
|
||||||
Direction::Left => {
|
|
||||||
self.x -= 0x1000;
|
|
||||||
}
|
|
||||||
Direction::Up => {
|
|
||||||
self.y -= 0x1400;
|
|
||||||
}
|
|
||||||
Direction::Bottom => {
|
|
||||||
self.y += 0x1400;
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
Direction::Left => {
|
||||||
if player.controller.trigger_shoot()
|
self.x -= 0x1000;
|
||||||
&& state.control_flags.control_enabled()
|
|
||||||
&& bullet_manager.count_bullets_multi(&[43], TargetPlayer::Player1) < 2
|
|
||||||
{
|
|
||||||
bullet_manager.create_bullet(
|
|
||||||
npc.x,
|
|
||||||
npc.y,
|
|
||||||
43,
|
|
||||||
TargetPlayer::Player1,
|
|
||||||
self.direction,
|
|
||||||
&state.constants,
|
|
||||||
);
|
|
||||||
state.create_caret(npc.x, npc.y, CaretType::Shoot, self.direction);
|
|
||||||
state.sound_manager.play_sfx(117);
|
|
||||||
}
|
}
|
||||||
|
Direction::Up => {
|
||||||
let mut dir_offset = if self.direction == Direction::Left { 0 } else { 3 };
|
self.y -= 0x1400;
|
||||||
if self.direction == Direction::Up {
|
}
|
||||||
dir_offset += 2
|
Direction::Bottom => {
|
||||||
};
|
self.y += 0x1400;
|
||||||
if self.direction == Direction::Bottom {
|
}
|
||||||
dir_offset += 1
|
_ => (),
|
||||||
};
|
|
||||||
|
|
||||||
self.anim_rect = state.constants.npc.n321_curly_nemesis[dir_offset];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if player.controller.trigger_shoot()
|
||||||
|
&& state.control_flags.control_enabled()
|
||||||
|
&& bullet_manager.count_bullets_multi(&[43], TargetPlayer::Player1) < 2
|
||||||
|
{
|
||||||
|
bullet_manager.create_bullet(npc.x, npc.y, 43, TargetPlayer::Player1, self.direction, &state.constants);
|
||||||
|
state.create_caret(npc.x, npc.y, CaretType::Shoot, Direction::Left);
|
||||||
|
state.sound_manager.play_sfx(117);
|
||||||
|
}
|
||||||
|
|
||||||
|
let dir_offset = if player.direction == Direction::Right { 0 } else { 3 };
|
||||||
|
|
||||||
|
self.anim_rect = state.constants.npc.n321_curly_nemesis[npc.anim_num as usize + dir_offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -586,14 +586,15 @@ impl NPC {
|
||||||
self.face_player(player);
|
self.face_player(player);
|
||||||
self.animate(40, 0, 1);
|
self.animate(40, 0, 1);
|
||||||
|
|
||||||
self.action_counter += 1;
|
|
||||||
if player.x > self.x - 0x28000
|
if player.x > self.x - 0x28000
|
||||||
&& player.x < self.x + 0x28000
|
&& player.x < self.x + 0x28000
|
||||||
&& player.y > self.y - 0x14000
|
&& player.y > self.y - 0x14000
|
||||||
&& player.y < self.y + 0x14000
|
&& player.y < self.y + 0x14000
|
||||||
&& self.action_counter > 50
|
|
||||||
{
|
{
|
||||||
self.action_num = 10
|
self.action_counter += 1;
|
||||||
|
if self.action_counter > 50 {
|
||||||
|
self.action_num = 10
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
10 | 11 => {
|
10 | 11 => {
|
||||||
|
|
|
||||||
|
|
@ -1549,12 +1549,8 @@ impl Bullet {
|
||||||
Direction::FacingPlayer => unreachable!(),
|
Direction::FacingPlayer => unreachable!(),
|
||||||
},
|
},
|
||||||
38 => match self.direction {
|
38 => match self.direction {
|
||||||
Direction::Left | Direction::Right => {
|
Direction::Left | Direction::Right => self.enemy_hit_height = 0x800,
|
||||||
self.enemy_hit_height = 0x800;
|
Direction::Up | Direction::Bottom => self.enemy_hit_width = 0x800,
|
||||||
}
|
|
||||||
Direction::Up | Direction::Bottom => {
|
|
||||||
self.enemy_hit_width = 0x800;
|
|
||||||
}
|
|
||||||
Direction::FacingPlayer => unreachable!(),
|
Direction::FacingPlayer => unreachable!(),
|
||||||
},
|
},
|
||||||
39 => {
|
39 => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue