1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-02-11 11:53:01 +00:00

add missing caret

This commit is contained in:
Alula 2020-12-05 22:44:15 +01:00
parent d2c5f2161a
commit f00f0e39cc
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
2 changed files with 41 additions and 4 deletions

View file

@ -1,7 +1,7 @@
use std::fs::read_to_string;
use crate::bitfield;
use crate::common::{Condition, Direction, Rect};
use crate::common::{Condition, Direction, Rect, CDEG_RAD};
use crate::engine_constants::EngineConstants;
use crate::rng::RNG;
@ -40,6 +40,7 @@ pub struct Caret {
pub cond: Condition,
pub direction: Direction,
pub anim_rect: Rect<u16>,
action_num: u16,
anim_num: u16,
anim_counter: u16,
}
@ -61,6 +62,7 @@ impl Caret {
cond: Condition(0x80),
direction: direct,
anim_rect: Rect::new(0, 0, 0, 0),
action_num: 0,
anim_num: 0,
anim_counter: 0,
}
@ -233,7 +235,31 @@ impl Caret {
_ => {}
}
}
CaretType::HurtParticles => {}
CaretType::HurtParticles => {
if self.action_num == 0 {
self.action_num = 1;
let angle = rng.range(0..255) as f64 * CDEG_RAD;
self.vel_x = (angle.cos() * 1024.0) as isize;
self.vel_y = (angle.sin() * 1024.0) as isize;
}
self.x += self.vel_x;
self.y += self.vel_y;
if self.anim_counter == 0 {
self.anim_rect = constants.caret.hurt_particles_rects[self.anim_num as usize];
}
self.anim_counter += 1;
if self.anim_counter > 2 {
self.anim_counter = 0;
self.anim_num += 1;
if self.anim_num >= constants.caret.hurt_particles_rects.len() as u16 {
self.cond.set_alive(false);
}
}
}
CaretType::Explosion => {
if self.anim_counter == 0 {
self.anim_rect = constants.caret.explosion_rects[self.anim_num as usize];

View file

@ -2,11 +2,11 @@ use case_insensitive_hashmap::CaseInsensitiveHashMap;
use log::info;
use crate::case_insensitive_hashmap;
use crate::common::{Flag, Rect, BulletFlag};
use crate::common::{BulletFlag, Flag, Rect};
use crate::engine_constants::npcs::NPCConsts;
use crate::player::ControlMode;
use crate::str;
use crate::text_script::TextScriptEncoding;
use crate::engine_constants::npcs::NPCConsts;
mod npcs;
@ -59,6 +59,7 @@ pub struct CaretConsts {
pub drowned_quote_right_rect: Rect<u16>,
pub level_up_rects: Vec<Rect<u16>>,
pub level_down_rects: Vec<Rect<u16>>,
pub hurt_particles_rects: Vec<Rect<u16>>,
pub explosion_rects: Vec<Rect<u16>>,
pub little_particles_rects: Vec<Rect<u16>>,
pub exhaust_rects: Vec<Rect<u16>>,
@ -81,6 +82,7 @@ impl Clone for CaretConsts {
drowned_quote_right_rect: self.drowned_quote_right_rect,
level_up_rects: self.level_up_rects.clone(),
level_down_rects: self.level_down_rects.clone(),
hurt_particles_rects: self.hurt_particles_rects.clone(),
explosion_rects: self.explosion_rects.clone(),
little_particles_rects: self.little_particles_rects.clone(),
exhaust_rects: self.exhaust_rects.clone(),
@ -383,6 +385,15 @@ impl EngineConstants {
Rect { left: 0, top: 96, right: 56, bottom: 112 },
Rect { left: 0, top: 112, right: 56, bottom: 128 },
],
hurt_particles_rects: vec![
Rect { left: 56, top: 8, right: 64, bottom: 16 },
Rect { left: 64, top: 8, right: 72, bottom: 16 },
Rect { left: 72, top: 8, right: 80, bottom: 16 },
Rect { left: 80, top: 8, right: 88, bottom: 16 },
Rect { left: 88, top: 8, right: 96, bottom: 16 },
Rect { left: 96, top: 8, right: 104, bottom: 16 },
Rect { left: 104, top: 8, right: 112, bottom: 16 },
],
explosion_rects: vec![
Rect { left: 112, top: 0, right: 144, bottom: 32 },
Rect { left: 144, top: 0, right: 176, bottom: 32 },