mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-12-02 09:30:20 +00:00
Add Quote teleportation animations
This commit is contained in:
parent
2542376362
commit
f892128328
|
|
@ -224,6 +224,8 @@ pub struct NPCConsts {
|
||||||
pub n097_fan_up: [Rect<usize>; 3],
|
pub n097_fan_up: [Rect<usize>; 3],
|
||||||
pub n098_fan_right: [Rect<usize>; 3],
|
pub n098_fan_right: [Rect<usize>; 3],
|
||||||
pub n099_fan_down: [Rect<usize>; 3],
|
pub n099_fan_down: [Rect<usize>; 3],
|
||||||
|
pub n111_quote_teleport_out: [Rect<usize>; 4],
|
||||||
|
pub n112_quote_teleport_in: [Rect<usize>; 4],
|
||||||
pub n129_fireball_snake_trail: [Rect<usize>; 18],
|
pub n129_fireball_snake_trail: [Rect<usize>; 18],
|
||||||
pub n149_horizontal_moving_block: Rect<usize>,
|
pub n149_horizontal_moving_block: Rect<usize>,
|
||||||
pub n157_vertical_moving_block: Rect<usize>,
|
pub n157_vertical_moving_block: Rect<usize>,
|
||||||
|
|
@ -1225,6 +1227,18 @@ impl EngineConstants {
|
||||||
Rect { left: 288, top: 168, right: 304, bottom: 184 },
|
Rect { left: 288, top: 168, right: 304, bottom: 184 },
|
||||||
Rect { left: 304, top: 168, right: 320, bottom: 184 },
|
Rect { left: 304, top: 168, right: 320, bottom: 184 },
|
||||||
],
|
],
|
||||||
|
n111_quote_teleport_out: [
|
||||||
|
Rect { left: 0, top: 0, right: 16, bottom: 16 }, // left
|
||||||
|
Rect { left: 16, top: 0, right: 32, bottom: 16 },
|
||||||
|
Rect { left: 0, top: 16, right: 16, bottom: 32 }, // right
|
||||||
|
Rect { left: 16, top: 16, right: 32, bottom: 32 },
|
||||||
|
],
|
||||||
|
n112_quote_teleport_in: [
|
||||||
|
Rect { left: 0, top: 0, right: 16, bottom: 16 }, // left
|
||||||
|
Rect { left: 16, top: 0, right: 32, bottom: 16 },
|
||||||
|
Rect { left: 0, top: 16, right: 16, bottom: 32 }, // right
|
||||||
|
Rect { left: 16, top: 16, right: 32, bottom: 32 },
|
||||||
|
],
|
||||||
n129_fireball_snake_trail: [
|
n129_fireball_snake_trail: [
|
||||||
Rect { left: 128, top: 48, right: 144, bottom: 64 },
|
Rect { left: 128, top: 48, right: 144, bottom: 64 },
|
||||||
Rect { left: 144, top: 48, right: 160, bottom: 64 },
|
Rect { left: 144, top: 48, right: 160, bottom: 64 },
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ pub mod mimiga_village;
|
||||||
pub mod misc;
|
pub mod misc;
|
||||||
pub mod misery;
|
pub mod misery;
|
||||||
pub mod pickups;
|
pub mod pickups;
|
||||||
|
pub mod quote;
|
||||||
pub mod sand_zone;
|
pub mod sand_zone;
|
||||||
pub mod santa;
|
pub mod santa;
|
||||||
pub mod sue;
|
pub mod sue;
|
||||||
|
|
@ -220,6 +221,8 @@ impl GameEntity<(&mut Player, &HashMap<u16, RefCell<NPC>>, &mut Stage)> for NPC
|
||||||
97 => self.tick_n097_fan_up(state, player),
|
97 => self.tick_n097_fan_up(state, player),
|
||||||
98 => self.tick_n098_fan_right(state, player),
|
98 => self.tick_n098_fan_right(state, player),
|
||||||
99 => self.tick_n099_fan_down(state, player),
|
99 => self.tick_n099_fan_down(state, player),
|
||||||
|
111 => self.tick_n111_quote_teleport_out(state, player),
|
||||||
|
112 => self.tick_n112_quote_teleport_in(state, player),
|
||||||
129 => self.tick_n129_fireball_snake_trail(state),
|
129 => self.tick_n129_fireball_snake_trail(state),
|
||||||
149 => self.tick_n149_horizontal_moving_block(state, player),
|
149 => self.tick_n149_horizontal_moving_block(state, player),
|
||||||
157 => self.tick_n157_vertical_moving_block(state, player),
|
157 => self.tick_n157_vertical_moving_block(state, player),
|
||||||
|
|
|
||||||
134
src/npc/quote.rs
Normal file
134
src/npc/quote.rs
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
use crate::ggez::GameResult;
|
||||||
|
use crate::npc::NPC;
|
||||||
|
use crate::shared_game_state::SharedGameState;
|
||||||
|
use crate::common::Direction;
|
||||||
|
use crate::player::Player;
|
||||||
|
|
||||||
|
impl NPC {
|
||||||
|
pub fn tick_n111_quote_teleport_out(&mut self, state: &mut SharedGameState, player: &Player) -> GameResult {
|
||||||
|
match self.action_num {
|
||||||
|
0 => {
|
||||||
|
self.action_num = 1;
|
||||||
|
self.anim_num = 0;
|
||||||
|
self.y -= 16 * 0x200;
|
||||||
|
}
|
||||||
|
1 => {
|
||||||
|
self.action_counter += 1;
|
||||||
|
if self.action_counter > 20 {
|
||||||
|
self.action_num = 2;
|
||||||
|
self.action_counter = 0;
|
||||||
|
self.anim_num = 1;
|
||||||
|
self.vel_y = -0x2ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2 => {
|
||||||
|
if self.vel_y > 0 {
|
||||||
|
self.hit_bounds.bottom = 16 * 0x200;
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.flags.hit_bottom_wall() {
|
||||||
|
self.action_counter = 0;
|
||||||
|
self.action_num = 3;
|
||||||
|
self.anim_num = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
3 => {
|
||||||
|
self.action_counter += 1;
|
||||||
|
if self.action_counter > 40 {
|
||||||
|
self.action_counter = 64;
|
||||||
|
self.action_num = 4;
|
||||||
|
|
||||||
|
state.sound_manager.play_sfx(29);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
4 => {
|
||||||
|
self.anim_num = 0;
|
||||||
|
if self.action_counter > 0 {
|
||||||
|
self.action_counter -= 1;
|
||||||
|
} else {
|
||||||
|
self.cond.set_alive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.vel_y += 0x40;
|
||||||
|
self.y += self.vel_y;
|
||||||
|
|
||||||
|
let dir_offset = if self.direction == Direction::Left { 0 } else { 2 };
|
||||||
|
self.anim_rect = state.constants.npc.n111_quote_teleport_out[self.anim_num as usize + dir_offset];
|
||||||
|
|
||||||
|
if player.equip.has_mimiga_mask() {
|
||||||
|
self.anim_rect.top += 32;
|
||||||
|
self.anim_rect.bottom += 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.action_num == 4 {
|
||||||
|
self.anim_rect.bottom = self.anim_rect.top + self.action_counter as usize / 4;
|
||||||
|
|
||||||
|
if self.action_counter / 2 % 2 != 0 {
|
||||||
|
self.anim_rect.left += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn tick_n112_quote_teleport_in(&mut self, state: &mut SharedGameState, player: &Player) -> GameResult {
|
||||||
|
match self.action_num {
|
||||||
|
0 => {
|
||||||
|
self.action_num = 1;
|
||||||
|
self.anim_num = 0;
|
||||||
|
self.anim_counter = 0;
|
||||||
|
self.x += 16 * 0x200;
|
||||||
|
self.y += 8 * 0x200;
|
||||||
|
|
||||||
|
state.sound_manager.play_sfx(29);
|
||||||
|
}
|
||||||
|
1 => {
|
||||||
|
self.action_counter += 1;
|
||||||
|
if self.action_counter >= 64 {
|
||||||
|
self.action_num = 2;
|
||||||
|
self.action_counter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2 => {
|
||||||
|
self.action_counter += 1;
|
||||||
|
if self.action_counter > 20 {
|
||||||
|
self.action_num = 3;
|
||||||
|
self.anim_num = 1;
|
||||||
|
self.hit_bounds.bottom = 8 * 0x200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
3 => {
|
||||||
|
if self.flags.hit_bottom_wall() {
|
||||||
|
self.action_counter = 0;
|
||||||
|
self.action_num = 4;
|
||||||
|
self.anim_num = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.vel_y += 0x40;
|
||||||
|
self.y += self.vel_y;
|
||||||
|
|
||||||
|
let dir_offset = if self.direction == Direction::Left { 0 } else { 2 };
|
||||||
|
self.anim_rect = state.constants.npc.n111_quote_teleport_out[self.anim_num as usize + dir_offset];
|
||||||
|
|
||||||
|
if player.equip.has_mimiga_mask() {
|
||||||
|
self.anim_rect.top += 32;
|
||||||
|
self.anim_rect.bottom += 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.action_num == 1 {
|
||||||
|
self.anim_rect.bottom = self.anim_rect.top + self.action_counter as usize / 4;
|
||||||
|
|
||||||
|
if self.action_counter / 2 % 2 != 0 {
|
||||||
|
self.anim_rect.left += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue