diff --git a/coffee/bot.coffee b/coffee/bot.coffee index dd9b91f..60ad7cb 100644 --- a/coffee/bot.coffee +++ b/coffee/bot.coffee @@ -222,12 +222,8 @@ class Bot extends Pushable relTime = action.getRelativeTime() dltTime = action.getRelativeDelta() - # log "Bot.performAction #{action.name} #{action.current} #{action.last} #{action.duration} id #{action.id}" - # log "Bot.performAction #{action.name} #{relTime} #{dltTime} id #{action.id}" - # cosFac = 1.0 - Math.cos(Math.PI/2 * relTime) cosFac = Math.cos Math.PI/2 - Math.PI/2 * relTime sinFac = Math.sin Math.PI/2 * relTime - # log "bot.performAction peform #{action.name} #{relTime} #{action.current} #{action.getDuration()}" switch action.id when Action.SHOOT if relTime == 0 @@ -240,7 +236,6 @@ class Bot extends Pushable @left_tire_rot += @dir_sgn * dltTime @right_tire_rot += @dir_sgn * dltTime @current_position = @position.plus @getDir().mul(relTime) - # log 'bot.forward', @current_position return when Action.JUMP diff --git a/coffee/pushable.coffee b/coffee/pushable.coffee index d8fc138..0aa8b75 100644 --- a/coffee/pushable.coffee +++ b/coffee/pushable.coffee @@ -18,6 +18,8 @@ class Pushable extends Item super @pusher = null @direction = Vector.minusY + @landing_sound = 'STONE_LAND' + @pushing_sound = 'STONE_MOVE' @addAction new Action @, Action.NOOP, "noop" @addAction new Action @, Action.PUSH, "push" @@ -43,6 +45,7 @@ class Pushable extends Item initAction: (action) -> switch action.id when Action.PUSH, Action.FALL + world.playSound @pushing_sound if action.id == Action.PUSH world.objectWillMoveToPos @, @position.plus(@direction), action.getDuration() performAction: (action) -> diff --git a/coffee/sound.coffee b/coffee/sound.coffee new file mode 100644 index 0000000..ce31e10 --- /dev/null +++ b/coffee/sound.coffee @@ -0,0 +1,69 @@ +# 0000000 0000000 000 000 000 000 0000000 +# 000 000 000 000 000 0000 000 000 000 +# 0000000 000 000 000 000 000 0 000 000 000 +# 000 000 000 000 000 000 0000 000 000 +# 0000000 0000000 0000000 000 000 0000000 + +log = require '/Users/kodi/s/ko/js/tools/log' +Howler = require 'howler' +Howl = Howler.Howl + +class Sound + + @sounds = + BOT_MOVE: file: "bot_move.wav", volume: 0.2 + BOT_JUMP: file: "bot_jump.wav", volume: 0.7 + BOT_LAND: file: "bot_land.wav", volume: 0.7 + BOT_SPIKED: file: "bot_move.wav", volume: 1.0 + BOT_HEALTH_ALERT: file: "bot_health_alert.wav", volume: 1.0 + BOT_DEATH: file: "bot_death.wav", volume: 1.0 + BOT_NO_ENERGY: file: "bot_no_energy.wav", volume: 1.0 + BULLET_SHOT: file: "bullet_shot.wav", volume: 1.0 + BULLET_HIT_WALL: file: "bullet_hit_wall.wav", volume: 1.0 + BULLET_HIT_OBJECT: file: "bullet_hit_object.wav", volume: 1.0 + BULLET_HIT_PLAYER: file: "bullet_hit_player.wav", volume: 1.0 + BULLET_HIT_MUTANT: file: "bullet_hit_mutant.wav", volume: 1.0 + STONE_MOVE: file: "stone_move.wav", volume: 1.0 + STONE_LAND: file: "stone_land.wav", volume: 1.0 + SWITCH_ON: file: "switch_on.wav", volume: 1.0 + SWITCH_OFF: file: "switch_on.wav", volume: 0.5 + ATOM_BIRTH: file: "atom_digest.wav", volume: 1.0 + ATOM_DIGEST: file: "atom_digest.wav", volume: 1.0 + SPIKES_START: file: "bot_move.wav", volume: 1.0 + MENU_FADE: file: "menu_fade.wav", volume: 1.0 + MENU_ITEM: file: "menu_item.wav", volume: 1.0 + MENU_SELECT: file: "menu_select.wav", volume: 1.0 + MENU_ABORT: file: "menu_abort.wav", volume: 1.0 + GATE_OPEN: file: "gate_open.wav", volume: 1.0 + GATE_CLOSE: file: "gate_close.wav", volume: 1.0 + GATE_WARP: file: "gate_warp.wav", volume: 1.0 + BOMB_EXPLODE: file: "bomb_explode.wav", volume: 1.0 + BOMB_SPLITTER: file: "bomb_splitter.wav", volume: 1.0 + GEAR_ON: file: "gear_on.wav", volume: 1.0 + GEAR_OFF: file: "gear_off.wav", volume: 1.0 + GENERATOR_ON: file: "generator_on.wav", volume: 1.0 + GENERATOR_OFF: file: "generator_off.wav", volume: 1.0 + MOTOR: file: "bomb_splitter.wav", volume: 1.0 + + @play: (sound, pos, time) -> + log "Sound.playSound #{sound} #{time}", pos + # Howler.volume 1 + howl = new Howl src: ["#{__dirname}/../sound/#{@sounds[sound].file}"] + if world.projection? + p = world.projection.getPosition() + Howler.Howler.pos p.x, p.y, p.z + f = world.projection.getZVector() + u = world.projection.getYVector() + Howler.Howler.orientation f.x, f.y, f.z, u.x, u.y, u.z + howl.pannerAttr + maxDistance: 10 + refDistance: 1 + rolloffFactor: 1 + distanceModel: 'exponential' + id = howl.play() + # log "sound id #{id}" + howl.volume @sounds[sound].volume, id + if pos? + howl.pos pos.x, pos.y, pos.z, id + +module.exports = Sound diff --git a/coffee/world.coffee b/coffee/world.coffee index c480871..e725103 100644 --- a/coffee/world.coffee +++ b/coffee/world.coffee @@ -18,6 +18,7 @@ Gate = require './gate' Light = require './light' Levels = require './levels' Player = require './player' +Sound = require './sound' Cage = require './cage' Timer = require './timer' Actor = require './actor' @@ -898,7 +899,7 @@ class World extends Actor when World.CAMERA_FOLLOW then @projection = @player.getFollowProjection() @projection - playSound: (sound, pos, time) -> # log "World.playSound #{sound} #{time}", pos + playSound: (sound, pos, time) -> Sound.play sound, pos, time # 000 000 00000000 000 000 # 000 000 000 000 000 diff --git a/sound/atom_digest.wav b/sound/atom_digest.wav new file mode 100644 index 0000000..990a104 Binary files /dev/null and b/sound/atom_digest.wav differ diff --git a/sound/bomb_explode.wav b/sound/bomb_explode.wav new file mode 100644 index 0000000..7c303b9 Binary files /dev/null and b/sound/bomb_explode.wav differ diff --git a/sound/bomb_splitter.wav b/sound/bomb_splitter.wav new file mode 100644 index 0000000..85f36c8 Binary files /dev/null and b/sound/bomb_splitter.wav differ diff --git a/sound/bot_death.wav b/sound/bot_death.wav new file mode 100644 index 0000000..166e09d Binary files /dev/null and b/sound/bot_death.wav differ diff --git a/sound/bot_health_alert.wav b/sound/bot_health_alert.wav new file mode 100644 index 0000000..e61d3da Binary files /dev/null and b/sound/bot_health_alert.wav differ diff --git a/sound/bot_jump.wav b/sound/bot_jump.wav new file mode 100644 index 0000000..1f69beb Binary files /dev/null and b/sound/bot_jump.wav differ diff --git a/sound/bot_land.wav b/sound/bot_land.wav new file mode 100644 index 0000000..08dd105 Binary files /dev/null and b/sound/bot_land.wav differ diff --git a/sound/bot_move.wav b/sound/bot_move.wav new file mode 100644 index 0000000..ceab486 Binary files /dev/null and b/sound/bot_move.wav differ diff --git a/sound/bot_no_energy.wav b/sound/bot_no_energy.wav new file mode 100644 index 0000000..6fb7e9e Binary files /dev/null and b/sound/bot_no_energy.wav differ diff --git a/sound/bullet_hit_mutant.wav b/sound/bullet_hit_mutant.wav new file mode 100644 index 0000000..67fc940 Binary files /dev/null and b/sound/bullet_hit_mutant.wav differ diff --git a/sound/bullet_hit_object.wav b/sound/bullet_hit_object.wav new file mode 100644 index 0000000..daf16ca Binary files /dev/null and b/sound/bullet_hit_object.wav differ diff --git a/sound/bullet_hit_player.wav b/sound/bullet_hit_player.wav new file mode 100644 index 0000000..9c6522c Binary files /dev/null and b/sound/bullet_hit_player.wav differ diff --git a/sound/bullet_hit_wall.wav b/sound/bullet_hit_wall.wav new file mode 100644 index 0000000..37a504d Binary files /dev/null and b/sound/bullet_hit_wall.wav differ diff --git a/sound/bullet_shot.wav b/sound/bullet_shot.wav new file mode 100644 index 0000000..c5ae36e Binary files /dev/null and b/sound/bullet_shot.wav differ diff --git a/sound/gate_close.wav b/sound/gate_close.wav new file mode 100644 index 0000000..4304e83 Binary files /dev/null and b/sound/gate_close.wav differ diff --git a/sound/gate_open.wav b/sound/gate_open.wav new file mode 100644 index 0000000..b85997d Binary files /dev/null and b/sound/gate_open.wav differ diff --git a/sound/gate_warp.wav b/sound/gate_warp.wav new file mode 100644 index 0000000..e89d096 Binary files /dev/null and b/sound/gate_warp.wav differ diff --git a/sound/gear_off.wav b/sound/gear_off.wav new file mode 100644 index 0000000..e14de00 Binary files /dev/null and b/sound/gear_off.wav differ diff --git a/sound/gear_on.wav b/sound/gear_on.wav new file mode 100644 index 0000000..6bb7beb Binary files /dev/null and b/sound/gear_on.wav differ diff --git a/sound/generator_off.wav b/sound/generator_off.wav new file mode 100644 index 0000000..6695ac9 Binary files /dev/null and b/sound/generator_off.wav differ diff --git a/sound/generator_on.wav b/sound/generator_on.wav new file mode 100644 index 0000000..970e784 Binary files /dev/null and b/sound/generator_on.wav differ diff --git a/sound/menu_abort.wav b/sound/menu_abort.wav new file mode 100644 index 0000000..2c4f034 Binary files /dev/null and b/sound/menu_abort.wav differ diff --git a/sound/menu_fade.wav b/sound/menu_fade.wav new file mode 100644 index 0000000..b2a9fec Binary files /dev/null and b/sound/menu_fade.wav differ diff --git a/sound/menu_item.wav b/sound/menu_item.wav new file mode 100644 index 0000000..f5be861 Binary files /dev/null and b/sound/menu_item.wav differ diff --git a/sound/menu_select.wav b/sound/menu_select.wav new file mode 100644 index 0000000..eb4ccf3 Binary files /dev/null and b/sound/menu_select.wav differ diff --git a/sound/stone_land.wav b/sound/stone_land.wav new file mode 100644 index 0000000..d913f86 Binary files /dev/null and b/sound/stone_land.wav differ diff --git a/sound/stone_move.wav b/sound/stone_move.wav new file mode 100644 index 0000000..4321855 Binary files /dev/null and b/sound/stone_move.wav differ diff --git a/sound/switch_on.wav b/sound/switch_on.wav new file mode 100644 index 0000000..6038333 Binary files /dev/null and b/sound/switch_on.wav differ