diff --git a/js/game.js b/js/game.js index cd6026a..65d58b2 100644 --- a/js/game.js +++ b/js/game.js @@ -296,7 +296,12 @@ export class Cell extends Array { if (actor === level.player) { level._set_tile_prop(actor, 'is_pushing', true); } - if (! level.attempt_out_of_turn_step(tile, direction)) { + if (level.attempt_out_of_turn_step(tile, direction)) { + if (actor === level.player) { + level.sfx.play_once('push'); + } + } + else { // If the push failed and the obstacle is in the middle of a slide, // remember this as the next move it'll make. if (tile.slide_mode !== null && tile.movement_cooldown > 0) { @@ -1174,7 +1179,9 @@ export class Level extends LevelInterface { this.p1_released &= ~INPUT_BITS.cycle; } if ((new_input & INPUT_BITS.drop) && may_move) { - this.drop_item(this.player); + if (this.drop_item(this.player)) { + this.sfx.play_once('drop'); + } this.p1_released &= ~INPUT_BITS.drop; } if ((new_input & INPUT_BITS.swap) && this.remaining_players > 1) { @@ -1510,10 +1517,6 @@ export class Level extends LevelInterface { } } - if (actor === this.player && goal_cell[0].type.name === 'floor') { - this.sfx.play_once('step-floor'); - } - // Announce we're approaching. Slide mode is set here, since it's about the tile we're // moving towards and needs to last through our next decision this.make_slide(actor, null); @@ -1597,6 +1600,39 @@ export class Level extends LevelInterface { tile.type.on_arrive(tile, this, actor); } } + + // Play step sound + if (actor === this.player) { + let terrain = cell.get_terrain(); + if (actor.slide_mode === 'ice') { + this.sfx.play_once('slide-ice'); + } + else if (actor.slide_mode === 'force') { + this.sfx.play_once('slide-force'); + } + else if (terrain.type.name === 'floor') { + this.sfx.play_once('step-floor'); + } + else if (terrain.type.name === 'gravel' || terrain.type.name === 'railroad') { + this.sfx.play_once('step-gravel'); + } + else if (terrain.type.name === 'water') { + if (actor.ignores(terrain.type.name)) { + this.sfx.play_once('step-water'); + } + } + else if (terrain.type.name === 'fire') { + if (actor.has_item('fire_boots')) { + this.sfx.play_once('step-fire'); + } + } + else if (terrain.type.slide_mode === 'force') { + this.sfx.play_once('step-force'); + } + else if (terrain.type.slide_mode === 'ice') { + this.sfx.play_once('step-ice'); + } + } } attempt_teleport(actor) { diff --git a/js/main.js b/js/main.js index 17f0c0f..7379c08 100644 --- a/js/main.js +++ b/js/main.js @@ -141,23 +141,49 @@ class SFXPlayer { 'button-release': 'sfx/button-release.ogg', // https://jummbus.bitbucket.io/#j2N04doorn110s0k0l00e00t3Mmfa3g00j07i0r1O_U00o30T0v0zL0OD0Ou00q0d1f8y0z2C0w2c0h0T2v0pL0OD0Ou02q0d1f8y3ziC0w1b4gp1f0aqEQ0lCNzrYUY0 door: 'sfx/door.ogg', + // https://jummbus.bitbucket.io/#j3N04dropn100s0k0l00e00t3Mm6a3g00j07i0r1O_U0o2T0v0pL0OaD0Ou00q1d1f4y2z9C0w2c0h0b4p1bGqKHGjner00 + drop: 'sfx/drop.ogg', + // https://jummbus.bitbucket.io/#j3N09get-bonusn100s1k0l00e00t50mba3g00j07i0r1O_U0o4T0v0pL0OaD0Ou00q1d5f8y0z2C1w0c0h8b4p1iFyWAxoHwmacOem8s60 + 'get-bonus': 'sfx/get-bonus.ogg', // https://jummbus.bitbucket.io/#j2N08get-chipn100s0k0l00e00t3Mmca3g00j07i0r1O_U0o4T0v0zL0OD0Ou00q1d1f6y1z2C0wac0h0b4p1dFyW7czgUK7aw0 'get-chip': 'sfx/get-chip.ogg', // https://jummbus.bitbucket.io/#j2N07get-keyn100s0k0l00e00t3Mmfa3g00j07i0r1O_U0o5T0v0pL0OD0Ou00q1d5f8y0z2C0w1c0h0b4p1dFyW85CbwwzBg0 'get-key': 'sfx/get-key.ogg', // https://jummbus.bitbucket.io/#j2N08get-tooln100s0k0l00e00t3Mm6a3g00j07i0r1O_U0o2T0v0pL0OD0Ou00q1d1f4y2z9C0w2c0h0b4p1bGqKNW4isVk0 'get-tool': 'sfx/get-tool.ogg', + // https://jummbus.bitbucket.io/#j3N04pushn110s0k0l00e00t3Mm3a3g00j07i0r1O_U00o30T5v0pL0OaD0Ou50q1d5f8y1z6C1c0h0H-JJAArrqiih999T2v01L0OaD0Ou02q2d2f6y1zhC0w0h0b4gp1f0bkoUzCcqy1FMo0 + // TODO less sure about this one + push: 'sfx/push.ogg', // https://jummbus.bitbucket.io/#j2N06socketn110s0k0l00e00t3Mm4a3g00j07i0r1O_U00o30T5v0pL0OD0Ou05q1d1f8y1z7C1c0h0HU7000U0006000ET2v0pL0OD0Ou02q1d6f5y3z2C0w0b4gp1xGoKHGhFBcn2FyPkxk0rE2AGcNCQyHwUY0 socket: 'sfx/socket.ogg', - // https://jummbus.bitbucket.io/#j2N06splashn110s0k0l00e00t3Mm5a3g00j07i0r1O_U00o20T0v0pL0OD0Ou00q0d0fay0z0C0w9c0h8T2v05L0OD0Ou02q2d6fay0z1C0w0b4gp1lGqKQy02gUY1qh7D1wb2Y0 // https://jummbus.bitbucket.io/#j2N06splashn110s0k0l00e00t3Mm5a3g00j07i0r1O_U00o20T0v0pL0OD0Ou00q0d0fay0z0C0w9c0h8T2v05L0OD0Ou02q2d6fay0z1C0w0b4gp1lGqKQxw_zzM5F4us60IbM0 splash: 'sfx/splash.ogg', + // https://jummbus.bitbucket.io/#j3N0csplash-slimen110s0k0l00e00t3Mm2a3g00j07i0r1O_U00o20T0v0pL0OaD0Ou00q3d7f3y2z1C0w9c3h0T2v01L0OaD0Ou02q2d7f2y1z0C0w0h0b4gp1nJ5nqgGgGusu0J0zjb0i9Hw0 + 'splash-slime': 'sfx/splash-slime.ogg', + // https://jummbus.bitbucket.io/#j3N0bslide-forcen110s1k0l00e00t4Im3a3g00j07i0r1O_U00o40T1v05L0OaD0Ou01q0d7f3y0z1C0c0h0A0F0B0V1Q0000Pff00E0711T2v01L0OaD0Ou02q2d7fay5z1C0w0h0b4gp1bJ8n55isS000 + 'slide-force': 'sfx/slide-force.ogg', + // https://jummbus.bitbucket.io/#j3N09slide-icen110s0k0l00e00t3Mm3a3g00j07i0r1O_U00o50T0v0fL0OaD0Ou00q2d2f8y0z1C0w9c3h0T2v01L0OaD0Ou02q2d3fay5z5C0w0h0b4gp1jGgKb8er0l5mlg84Ddw0 + // https://jummbus.bitbucket.io/#j3N09slide-icen110s1k0l00e00t4Im3a3g00j07i0r1O_U00o50T1v0aL0OaD0Ou01q3d7f5y0z9C0c0h0A9F3B2VdQ5428Paa74E0019T2v01L0OaD0Ou02q2d7fay5z1C0w0h0b4gp1kLwb2HbEBer0l0l509Po0 + 'slide-ice': 'sfx/slide-ice.ogg', + // https://jummbus.bitbucket.io/#j3N09step-firen110s0k0l00e00t3Mm6a3g00j07i0r1O_U00o10T0v05L0OaD0Ou10q0d0f8y0z1C2w2c0Gc0h0T2v0pL0OaD0Ou02q3d7fay3z1C0w1h0b4gp1b0ayH2w40VI0 + 'step-fire': 'sfx/step-fire.ogg', + // https://jummbus.bitbucket.io/#j3N0astep-forcen110s0k0l00e00t3Mm4a3g00j07i0r1O_U00o30T0v0aL0OaD0Ou00q1d1fay2z6C1wdc0h3T2v01L0OaD0zu02q0d1f9y2z1C1w8h0b4gp1mJdlagwgQsu0J5mqhK0qsu0 + 'step-force': 'sfx/step-force.ogg', // https://jummbus.bitbucket.io/#j2N0astep-floorn100s0k0l00e00t3Mm6a3g00j07i0r1O_U0o1T0v05L0OD0Ou00q0d2f1y1zjC2w0c0h0b4p1aGaKaxqer00 'step-floor': 'sfx/step-floor.ogg', + // https://jummbus.bitbucket.io/#j3N0bstep-graveln110s0k0l00e00t3Mm6a3g00j07i0r1O_U00o50T0v05L0OaD0Ou00q0d1f7y4z2C0wic0h0T2v05L0OaD0Ou02q0d2f2y0z0C1w0h0b4gp1lLp719LjCM5EGOEJ3per00 + // https://jummbus.bitbucket.io/#j3N0bstep-graveln110s0k0l00e00t3Mm6a3g00j07i0r1O_U00o50T0v05L0OaD0Ou00q0d1f7y4z2C0wic0h0T2v01L0OaD0zu02q0d1f9y2z1C2w0Gc0h0b4gp1d0bhlCAmxID7w0 + 'step-gravel': 'sfx/step-gravel.ogg', + // https://jummbus.bitbucket.io/#j3N08step-icen100s0k0l00e00t3Mm6a3g00j07i0r1O_U0o5T0v05L0OaD0Ou00q0d1f7y4z2C0wic0h0b4p1aLp719LjCM0 + 'step-ice': 'sfx/step-ice.ogg', + // https://jummbus.bitbucket.io/#j3N0astep-watern100s0k0l00e00t3Mm2a3g00j07i0r1O_U0o3T0v0kL0OaD0Ou00q1d6f2y0z0C1w9c0h3b4p1dJ5moMMAa16sG0 + 'step-water': 'sfx/step-water.ogg', // https://jummbus.bitbucket.io/#j2N08teleportn110s1k0l00e00t3Mm7a3g00j07i0r1O_U00o50T0v0pL0OD0Ou00q1d1f8y4z6C2w5c4h0T2v0kL0OD0Ou02q1d7f8y4z3C1w4b4gp1wF2Uzh5wdC18yHH4hhBhHwaATXu0Asds0 teleport: 'sfx/teleport.ogg', // https://jummbus.bitbucket.io/#j2N05thiefn100s1k0l00e00t3Mm3a3g00j07i0r1O_U0o1T0v0pL0OD0Ou00q1d1f5y1z8C2w2c0h0b4p1fFyUBBr9mGkKKds0 thief: 'sfx/thief.ogg', + // https://jummbus.bitbucket.io/#j3N0ctransmogrifyn110s1k0l00e00t3Mm7a3g00j07i0r1O_U00o50T0v0pL0OaD0Ou00q1d0f8y4z6C1w1c1h0T2v05L0OaD0Ou02q1d7f8y4zcC1w4h0b4gp1BINp2j8mhPcn1R8xQSAb8oyUiPt0l9LOYq0qU0 + transmogrify: 'sfx/transmogrify.ogg', // handcrafted lose: 'sfx/bummer.ogg', diff --git a/js/tiletypes.js b/js/tiletypes.js index 51a8ca9..54a8087 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -186,6 +186,7 @@ const TILE_TYPES = { // Blobs spread slime onto floor if (other.previous_cell && other.previous_cell.has('slime')) { level.transmute_tile(me, 'slime'); + level.sfx.play_once('splash-slime', me.cell); } } }, @@ -588,6 +589,9 @@ const TILE_TYPES = { if (other.type.name === 'ghost' && ! other.has_item('hiking_boots')) return; level.transmute_tile(me, 'floor'); + if (other === level.player) { + level.sfx.play_once('step-gravel', me.cell); + } }, }, gravel: { @@ -619,8 +623,9 @@ const TILE_TYPES = { return; } else if (other.type.name === 'ice_block') { - level.transmute_tile(other, 'explosion'); + level.transmute_tile(other, 'splash'); level.transmute_tile(me, 'water'); + level.sfx.play_once('splash', me.cell); } else if (other.type.is_real_player) { level.fail('burned'); @@ -665,8 +670,8 @@ const TILE_TYPES = { blocks_collision: COLLISION.ghost | COLLISION.fireball, on_depart(me, level, other) { level.transmute_tile(me, 'water'); - // TODO feels like we should spawn water underneath us, then transmute ourselves into the splash? level.spawn_animation(me.cell, 'splash'); + level.sfx.play_once('splash', me.cell); }, }, ice: { @@ -833,18 +838,20 @@ const TILE_TYPES = { slime: { draw_layer: DRAW_LAYERS.terrain, on_arrive(me, level, other) { + if (other.type.name === 'ghost' || other.type.name === 'blob') { + // No effect + return; + } + + + level.sfx.play_once('splash-slime', me.cell); if (other.type.name === 'dirt_block' || other.type.name === 'ice_block') { level.transmute_tile(me, 'floor'); } - else if (other.type.name === 'ghost' || other.type.name === 'blob') { - // No effect - } else if (other.type.is_real_player) { level.fail('slimed'); } else { - // FIXME needs a sound effect - level.sfx.play_once('splash', me.cell); level.transmute_tile(other, 'splash_slime'); } }, @@ -957,14 +964,14 @@ const TILE_TYPES = { frame_block: true, }, on_bumped(me, level, other) { - // Fireballs melt ice blocks on regular floor + // Fireballs melt ice blocks on regular floor FIXME and water! // XXX what if i'm in motion? if (other.type.name === 'fireball') { let terrain = me.cell.get_terrain(); if (terrain.type.name === 'floor') { - level.remove_tile(me); + level.transmute_tile(me, 'splash'); level.transmute_tile(terrain, 'water'); - // FIXME splash? + level.sfx.play_once('splash', me.cell); } } }, @@ -1210,6 +1217,7 @@ const TILE_TYPES = { return; } level.spawn_animation(me.cell, 'transmogrify_flash'); + level.sfx.play_once('transmogrify', me.cell); }, on_power(me, level) { // No need to do anything, we just need this here as a signal that our .powered_edges @@ -2557,6 +2565,7 @@ const TILE_TYPES = { on_arrive(me, level, other) { if (other.type.is_real_player) { level.adjust_bonus(10); + level.sfx.play_once('get-bonus', me.cell); } // TODO turn this into a flag on those types?? idk if (other.type.is_player || other.type.name === 'rover' || other.type.name === 'bowling_ball') { @@ -2570,6 +2579,7 @@ const TILE_TYPES = { on_arrive(me, level, other) { if (other.type.is_real_player) { level.adjust_bonus(100); + level.sfx.play_once('get-bonus', me.cell); } if (other.type.is_player || other.type.name === 'rover' || other.type.name === 'bowling_ball') { level.remove_tile(me); @@ -2582,6 +2592,7 @@ const TILE_TYPES = { on_arrive(me, level, other) { if (other.type.is_real_player) { level.adjust_bonus(1000); + level.sfx.play_once('get-bonus', me.cell); } if (other.type.is_player || other.type.name === 'rover' || other.type.name === 'bowling_ball') { level.remove_tile(me); @@ -2594,6 +2605,7 @@ const TILE_TYPES = { on_arrive(me, level, other) { if (other.type.is_real_player) { level.adjust_bonus(0, 2); + level.sfx.play_once('get-bonus', me.cell); } if (other.type.is_player || other.type.name === 'rover' || other.type.name === 'bowling_ball') { level.remove_tile(me); diff --git a/sfx/drop.ogg b/sfx/drop.ogg new file mode 100644 index 0000000..7376c82 Binary files /dev/null and b/sfx/drop.ogg differ diff --git a/sfx/get-bonus.ogg b/sfx/get-bonus.ogg new file mode 100644 index 0000000..5b9ffd7 Binary files /dev/null and b/sfx/get-bonus.ogg differ diff --git a/sfx/push.ogg b/sfx/push.ogg new file mode 100644 index 0000000..3bae120 Binary files /dev/null and b/sfx/push.ogg differ diff --git a/sfx/slide-force.ogg b/sfx/slide-force.ogg new file mode 100644 index 0000000..015b47b Binary files /dev/null and b/sfx/slide-force.ogg differ diff --git a/sfx/slide-ice.ogg b/sfx/slide-ice.ogg new file mode 100644 index 0000000..efc80dc Binary files /dev/null and b/sfx/slide-ice.ogg differ diff --git a/sfx/splash-slime.ogg b/sfx/splash-slime.ogg new file mode 100644 index 0000000..2a58fbe Binary files /dev/null and b/sfx/splash-slime.ogg differ diff --git a/sfx/step-fire.ogg b/sfx/step-fire.ogg new file mode 100644 index 0000000..c1b2cf4 Binary files /dev/null and b/sfx/step-fire.ogg differ diff --git a/sfx/step-force.ogg b/sfx/step-force.ogg new file mode 100644 index 0000000..195c0c0 Binary files /dev/null and b/sfx/step-force.ogg differ diff --git a/sfx/step-gravel.ogg b/sfx/step-gravel.ogg new file mode 100644 index 0000000..f965aa6 Binary files /dev/null and b/sfx/step-gravel.ogg differ diff --git a/sfx/step-ice.ogg b/sfx/step-ice.ogg new file mode 100644 index 0000000..e303025 Binary files /dev/null and b/sfx/step-ice.ogg differ diff --git a/sfx/step-water.ogg b/sfx/step-water.ogg new file mode 100644 index 0000000..22535c9 Binary files /dev/null and b/sfx/step-water.ogg differ diff --git a/sfx/transmogrify.ogg b/sfx/transmogrify.ogg new file mode 100644 index 0000000..5a5e801 Binary files /dev/null and b/sfx/transmogrify.ogg differ