mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-10-31 19:44:20 +00:00
minor tweaks
This commit is contained in:
parent
f87ccaf694
commit
fc7d47a262
|
@ -1,3 +1,5 @@
|
|||
use std::cmp::Ordering;
|
||||
|
||||
use num_traits::clamp;
|
||||
|
||||
use crate::common::Direction;
|
||||
|
@ -16,11 +18,11 @@ impl NPC {
|
|||
}
|
||||
|
||||
if self.action_num == 1 {
|
||||
if self.target_y < self.y {
|
||||
self.vel_y -= 8;
|
||||
} else if self.target_y > self.y {
|
||||
self.vel_y += 8;
|
||||
}
|
||||
self.vel_y += match self.target_y.cmp(&self.y) {
|
||||
Ordering::Less => { -8 }
|
||||
Ordering::Equal => { 0 }
|
||||
Ordering::Greater => { 8 }
|
||||
};
|
||||
|
||||
self.vel_y = clamp(self.vel_y, -0x100, 0x100);
|
||||
}
|
||||
|
|
|
@ -754,11 +754,13 @@ impl Scene for GameScene {
|
|||
}
|
||||
|
||||
if state.key_trigger.weapon_next() {
|
||||
state.sound_manager.play_sfx(4);
|
||||
self.inventory.next_weapon();
|
||||
self.weapon_x_pos = 32;
|
||||
}
|
||||
|
||||
if state.key_trigger.weapon_prev() {
|
||||
state.sound_manager.play_sfx(4);
|
||||
self.inventory.prev_weapon();
|
||||
self.weapon_x_pos = 0;
|
||||
}
|
||||
|
|
|
@ -293,6 +293,6 @@ fn run<T>(rx: Receiver<PlaybackMessage>, bank: SoundBank,
|
|||
stream.play()?;
|
||||
|
||||
loop {
|
||||
std::thread::sleep(Duration::from_millis(1));
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,13 +277,13 @@ impl PixTonePlayback {
|
|||
break;
|
||||
} else {
|
||||
let pos = state.1 as usize;
|
||||
//let s1 = (sample[pos] as f32) / 32768.0;
|
||||
//let s2 = (sample[clamp(pos + 1, 0, sample.len() - 1)] as f32) / 32768.0;
|
||||
//let s3 = (sample[clamp(pos + 2, 0, sample.len() - 1)] as f32) / 32768.0;
|
||||
//let s4 = (sample[pos.saturating_sub(1)] as f32) / 32768.0;
|
||||
let s1 = (sample[pos] as f32) / 32768.0;
|
||||
let s2 = (sample[clamp(pos + 1, 0, sample.len() - 1)] as f32) / 32768.0;
|
||||
let s3 = (sample[clamp(pos + 2, 0, sample.len() - 1)] as f32) / 32768.0;
|
||||
let s4 = (sample[pos.saturating_sub(1)] as f32) / 32768.0;
|
||||
|
||||
//let s = cubic_interp(s1, s2, s4, s3, state.1.fract()) * 32768.0;
|
||||
let s = sample[pos] as f32;
|
||||
let s = cubic_interp(s1, s2, s4, s3, state.1.fract()) * 32768.0;
|
||||
// let s = sample[pos] as f32;
|
||||
let sam = (*result ^ 0x8000) as i16;
|
||||
*result = sam.saturating_add(s as i16) as u16 ^ 0x8000;
|
||||
|
||||
|
|
Loading…
Reference in a new issue