1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-07-18 10:02:20 +00:00

add sound effects

This commit is contained in:
Alula 2020-09-16 21:53:53 +02:00
parent bc0a33cd7e
commit 65a6e193db
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
7 changed files with 376 additions and 25 deletions

View file

@ -326,7 +326,7 @@ impl Bullet {
pub fn vanish(&mut self, state: &mut SharedGameState) {
if self.btype != 37 && self.btype != 38 && self.btype != 39 {
// todo play sound 28
state.sound_manager.play_sfx(28);
} else {
state.create_caret(self.x, self.y, CaretType::ProjectileDissipation, Direction::Up);
}
@ -337,8 +337,8 @@ impl Bullet {
fn judge_hit_block_destroy(&mut self, x: isize, y: isize, hit_attribs: &[u8; 4], state: &mut SharedGameState) {
let mut hits = [false; 4];
let mut block_x = (x * 16 + 8) * 0x200;
let mut block_y = (y * 16 + 8) * 0x200;
let block_x = (x * 16 + 8) * 0x200;
let block_y = (y * 16 + 8) * 0x200;
for (i, &attr) in hit_attribs.iter().enumerate() {
if self.flags.snack_destroy() {
@ -541,7 +541,7 @@ impl PhysicalEntity for Bullet {
}
state.create_caret(self.x, self.y, CaretType::ProjectileDissipation, Direction::Left);
// todo play sound 12
state.sound_manager.play_sfx(12);
for _ in 0..4 {
let mut npc = NPCMap::create_npc(4, &state.npc_table);

View file

@ -142,7 +142,7 @@ impl NPC {
}
self.vel_y = -0x5ff;
// todo play sound 30
state.sound_manager.play_sfx(30);
if self.direction == Direction::Left {
self.vel_x = -0x100;
@ -157,7 +157,7 @@ impl NPC {
self.action_counter = 0;
self.action_num = 1;
// tood play sound 23
state.sound_manager.play_sfx(23);
if self.anim_num != 0 {
self.anim_num = 0;

View file

@ -71,6 +71,7 @@ pub struct NPC {
pub direction: Direction,
pub display_bounds: Rect<usize>,
pub hit_bounds: Rect<usize>,
pub hurt_sound: u8,
pub action_num: u16,
pub anim_num: u16,
pub flag_num: u16,
@ -275,9 +276,9 @@ impl NPCMap {
pub fn create_npc_from_data(&mut self, table: &NPCTable, data: &NPCData) -> &mut NPC {
let display_bounds = table.get_display_bounds(data.npc_type);
let hit_bounds = table.get_hit_bounds(data.npc_type);
let (size, life, damage, flags, exp) = match table.get_entry(data.npc_type) {
Some(entry) => { (entry.size, entry.life, entry.damage as u16, entry.npc_flags, entry.experience as u16) }
None => { (1, 0, 0, NPCFlag(0), 0) }
let (size, life, damage, flags, exp, hurt_sound) = match table.get_entry(data.npc_type) {
Some(entry) => { (entry.size, entry.life, entry.damage as u16, entry.npc_flags, entry.experience as u16, entry.hurt_sound) }
None => { (1, 0, 0, NPCFlag(0), 0, 0) }
};
let npc_flags = NPCFlag(data.flags | flags.0);
@ -305,6 +306,7 @@ impl NPCMap {
npc_flags,
display_bounds,
hit_bounds,
hurt_sound,
action_counter: 0,
action_counter2: 0,
anim_counter: 0,
@ -320,9 +322,9 @@ impl NPCMap {
pub fn create_npc(npc_type: u16, table: &NPCTable) -> NPC {
let display_bounds = table.get_display_bounds(npc_type);
let hit_bounds = table.get_hit_bounds(npc_type);
let (size, life, damage, flags, exp) = match table.get_entry(npc_type) {
Some(entry) => { (entry.size, entry.life, entry.damage as u16, entry.npc_flags, entry.experience as u16) }
None => { (1, 0, 0, NPCFlag(0), 0) }
let (size, life, damage, flags, exp, hurt_sound) = match table.get_entry(npc_type) {
Some(entry) => { (entry.size, entry.life, entry.damage as u16, entry.npc_flags, entry.experience as u16, entry.hurt_sound) }
None => { (1, 0, 0, NPCFlag(0), 0, 0) }
};
let npc_flags = NPCFlag(flags.0);
@ -350,6 +352,7 @@ impl NPCMap {
npc_flags,
display_bounds,
hit_bounds,
hurt_sound,
action_counter: 0,
action_counter2: 0,
anim_counter: 0,

View file

@ -71,14 +71,14 @@ impl NPC {
}
if self.flags.hit_bottom_wall() {
// todo play sound 45
state.sound_manager.play_sfx(45);
self.vel_y = -0x280;
self.vel_x = 2 * self.vel_x / 3;
}
if self.flags.hit_left_wall() || self.flags.hit_right_wall() || self.flags.hit_bottom_wall() {
// todo play sound 45
state.sound_manager.play_sfx(45);
self.action_counter2 += 1;
if self.action_counter2 > 2 {

View file

@ -627,7 +627,7 @@ impl GameScene {
}
} else {
if npc.shock < 14 {
// todo play hurt sound
state.sound_manager.play_sfx(npc.hurt_sound);
npc.shock = 16;
}
@ -639,7 +639,7 @@ impl GameScene {
&& bullet.btype != 13 && bullet.btype != 14 && bullet.btype != 15
&& bullet.btype != 28 && bullet.btype != 29 && bullet.btype != 30 {
state.create_caret((bullet.x + npc.x) / 2, (bullet.y + npc.y) / 2, CaretType::ProjectileDissipation, Direction::Right);
// todo play sound 31
state.sound_manager.play_sfx(31);
bullet.life = 0;
continue;
}
@ -692,7 +692,7 @@ impl Scene for GameScene {
self.player.target_y = self.player.y;
self.frame.immediate_update(state, &self.player, &self.stage);
//self.inventory.add_weapon(WeaponType::PolarStar, 0);
self.inventory.add_weapon(WeaponType::PolarStar, 0);
//self.player.equip.set_booster_2_0(true);
Ok(())
}

View file

@ -1,7 +1,7 @@
use crate::sound::pixtone::{Channel, Envelope, PixToneParameters, Waveform};
pub static PIXTONE_TABLE: [PixToneParameters; 17] = [
PixToneParameters::empty(),
pub static PIXTONE_TABLE: [PixToneParameters; 51] = [
PixToneParameters::empty(), // 0
PixToneParameters {
channels: [
Channel {
@ -79,9 +79,71 @@ pub static PIXTONE_TABLE: [PixToneParameters; 17] = [
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(), // 10
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters {
channels: [Channel {
enabled: true,
length: 10000,
carrier: Waveform {
waveform_type: 5,
pitch: 7.3,
level: 32,
offset: 0,
},
frequency: Waveform {
waveform_type: 5,
pitch: 0.2,
level: 29,
offset: 0,
},
amplitude: Waveform {
waveform_type: 0,
pitch: 0.0,
level: 32,
offset: 0,
},
envelope: Envelope {
initial: 63,
time_a: 91,
value_a: 63,
time_b: 149,
value_b: 25,
time_c: 255,
value_c: 0,
},
}, Channel {
enabled: true,
length: 1000,
carrier: Waveform {
waveform_type: 0,
pitch: 6.0,
level: 32,
offset: 0,
},
frequency: Waveform {
waveform_type: 3,
pitch: 1.0,
level: 32,
offset: 0,
},
amplitude: Waveform {
waveform_type: 0,
pitch: 0.0,
level: 32,
offset: 0,
},
envelope: Envelope {
initial: 63,
time_a: 64,
value_a: 63,
time_b: 128,
value_b: 63,
time_c: 255,
value_c: 63,
},
}, Channel::disabled(), Channel::disabled()]
},
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters {
@ -179,5 +241,291 @@ pub static PIXTONE_TABLE: [PixToneParameters; 17] = [
value_c: 32,
},
}, Channel::disabled(), Channel::disabled()]
}
},
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(), // 20
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters {
channels: [Channel {
enabled: true,
length: 3000,
carrier: Waveform {
waveform_type: 1,
pitch: 17.0,
level: 34,
offset: 0,
},
frequency: Waveform {
waveform_type: 3,
pitch: 2.0,
level: 40,
offset: 0,
},
amplitude: Waveform {
waveform_type: 4,
pitch: 1.0,
level: 31,
offset: 0,
},
envelope: Envelope {
initial: 63,
time_a: 64,
value_a: 63,
time_b: 225,
value_b: 63,
time_c: 255,
value_c: 0,
},
}, Channel::disabled(), Channel::disabled(), Channel::disabled()]
},
PixToneParameters {
channels: [Channel {
enabled: true,
length: 1000,
carrier: Waveform {
waveform_type: 1,
pitch: 5.0,
level: 32,
offset: 0,
},
frequency: Waveform {
waveform_type: 3,
pitch: 1.0,
level: 63,
offset: 0,
},
amplitude: Waveform {
waveform_type: 0,
pitch: 0.0,
level: 0,
offset: 0,
},
envelope: Envelope {
initial: 63,
time_a: 64,
value_a: 63,
time_b: 128,
value_b: 31,
time_c: 255,
value_c: 0,
},
}, Channel::disabled(), Channel::disabled(), Channel::disabled()]
},
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters {
channels: [Channel {
enabled: true,
length: 3000,
carrier: Waveform {
waveform_type: 0,
pitch: 13.0,
level: 24,
offset: 0,
},
frequency: Waveform {
waveform_type: 3,
pitch: 2.0,
level: 40,
offset: 0,
},
amplitude: Waveform {
waveform_type: 4,
pitch: 1.0,
level: 31,
offset: 0,
},
envelope: Envelope {
initial: 63,
time_a: 64,
value_a: 63,
time_b: 225,
value_b: 63,
time_c: 255,
value_c: 0,
},
}, Channel {
enabled: true,
length: 3000,
carrier: Waveform {
waveform_type: 5,
pitch: 6.0,
level: 32,
offset: 0,
},
frequency: Waveform {
waveform_type: 5,
pitch: 1.0,
level: 32,
offset: 0,
},
amplitude: Waveform {
waveform_type: 3,
pitch: 6.0,
level: 0,
offset: 0,
},
envelope: Envelope {
initial: 0,
time_a: 0,
value_a: 63,
time_b: 45,
value_b: 23,
time_c: 255,
value_c: 0,
},
}, Channel::disabled(), Channel::disabled()]
},
PixToneParameters::empty(),
PixToneParameters { // 30
channels: [Channel {
enabled: true,
length: 10000,
carrier: Waveform {
waveform_type: 2,
pitch: 168.0,
level: 32,
offset: 0,
},
frequency: Waveform {
waveform_type: 0,
pitch: 0.5,
level: 29,
offset: 173,
},
amplitude: Waveform {
waveform_type: 0,
pitch: 0.0,
level: 32,
offset: 0,
},
envelope: Envelope {
initial: 0,
time_a: 13,
value_a: 63,
time_b: 68,
value_b: 35,
time_c: 255,
value_c: 0,
},
}, Channel::disabled(), Channel::disabled(), Channel::disabled()]
},
PixToneParameters::empty(),
PixToneParameters {
channels: [Channel {
enabled: true,
length: 5000,
carrier: Waveform {
waveform_type: 5,
pitch: 10.0,
level: 32,
offset: 0,
},
frequency: Waveform {
waveform_type: 4,
pitch: 4.0,
level: 32,
offset: 0,
},
amplitude: Waveform {
waveform_type: 0,
pitch: 0.0,
level: 63,
offset: 0,
},
envelope: Envelope {
initial: 63,
time_a: 6,
value_a: 63,
time_b: 45,
value_b: 8,
time_c: 119,
value_c: 46,
},
}, Channel {
enabled: true,
length: 1000,
carrier: Waveform {
waveform_type: 0,
pitch: 4.0,
level: 32,
offset: 0,
},
frequency: Waveform {
waveform_type: 3,
pitch: 1.0,
level: 63,
offset: 0,
},
amplitude: Waveform {
waveform_type: 0,
pitch: 0.0,
level: 63,
offset: 0,
},
envelope: Envelope {
initial: 63,
time_a: 64,
value_a: 63,
time_b: 128,
value_b: 63,
time_c: 255,
value_c: 63,
},
}, Channel::disabled(), Channel::disabled()]
},
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(), // 40
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters {
channels: [Channel {
enabled: true,
length: 5000,
carrier: Waveform {
waveform_type: 0,
pitch: 880.0,
level: 19,
offset: 0,
},
frequency: Waveform {
waveform_type: 0,
pitch: 0.0,
level: 32,
offset: 0,
},
amplitude: Waveform {
waveform_type: 0,
pitch: 8.0,
level: 32,
offset: 0,
},
envelope: Envelope {
initial: 0,
time_a: 11,
value_a: 63,
time_b: 34,
value_b: 25,
time_c: 255,
value_c: 0,
},
}, Channel::disabled(), Channel::disabled(), Channel::disabled()]
},
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(),
PixToneParameters::empty(), // 50
];

View file

@ -85,7 +85,7 @@ impl Weapon {
};
if !self.consume_ammo(1) {
// todo: play sound 37
state.sound_manager.play_sfx(37);
return;
}
@ -128,9 +128,9 @@ impl Weapon {
}
if self.level == WeaponLevel::Level3 {
// todo play sound 49
state.sound_manager.play_sfx(49);
} else {
// todo play sound 32
state.sound_manager.play_sfx(32);
}
}
}