minor tweaks

This commit is contained in:
Alula 2020-09-21 16:15:14 +02:00
parent f87ccaf694
commit fc7d47a262
No known key found for this signature in database
GPG Key ID: 3E00485503A1D8BA
4 changed files with 16 additions and 12 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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));
}
}

View File

@ -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;