diff --git a/lib/sounds/zapsplat_nature_water_pour_medium_amount_deep_sudden_fast_002_52765.mp3 b/lib/sounds/zapsplat_nature_water_pour_medium_amount_deep_sudden_fast_002_52765.mp3 new file mode 100644 index 0000000..66fa08f Binary files /dev/null and b/lib/sounds/zapsplat_nature_water_pour_medium_amount_deep_sudden_fast_002_52765.mp3 differ diff --git a/lib/sounds/zapsplat_warfare_bomb_whizz_in_hit_close_by_explosion_med_003_48060.mp3 b/lib/sounds/zapsplat_warfare_bomb_whizz_in_hit_close_by_explosion_med_003_48060.mp3 new file mode 100644 index 0000000..77d2c5d Binary files /dev/null and b/lib/sounds/zapsplat_warfare_bomb_whizz_in_hit_close_by_explosion_med_003_48060.mp3 differ diff --git a/lib/sounds/zapsplat_warfare_mortar_projectile_launch_002_25232.mp3 b/lib/sounds/zapsplat_warfare_mortar_projectile_launch_002_25232.mp3 new file mode 100644 index 0000000..96cd455 Binary files /dev/null and b/lib/sounds/zapsplat_warfare_mortar_projectile_launch_002_25232.mp3 differ diff --git a/src/components/TopLevel.component.js b/src/components/TopLevel.component.js index b2f5a3d..0ea2448 100644 --- a/src/components/TopLevel.component.js +++ b/src/components/TopLevel.component.js @@ -2,6 +2,7 @@ import {Component} from '../../lib/vues6.js' import {GameState, ShipType} from '../module/util.js' import {instructions} from '../module/lang.js' import game_service from '../services/GameState.service.js' +import {GameSounds} from '../module/sounds.js' const template = `
diff --git a/src/module/sounds.js b/src/module/sounds.js new file mode 100644 index 0000000..0ccf3f9 --- /dev/null +++ b/src/module/sounds.js @@ -0,0 +1,29 @@ +function sound(src) { + + this.sound = document.createElement("audio"); + + this.sound.src = src; + this.sound.setAttribute("preload", "auto"); + this.sound.setAttribute("controls", "none"); + this.sound.style.display = "none"; + document.body.appendChild(this.sound); + this.play = function(){ + this.sound.play(); + } + this.stop = function(){ + this.sound.pause(); + } + +} + +const GameSounds = { + Victory: new sound("/lib/sounds/cartoon_success_fanfair.mp3"), + Fire: new sound("/lib/sounds/zapsplat_warfare_mortar_projectile_launch_002_25232.mp3"), + Hit: new sound("/lib/sounds/zapsplat_warfare_bomb_whizz_in_hit_close_by_explosion_med_003_48060.mp3"), + Miss: new sound("/lib/sounds/zapsplat_nature_water_pour_medium_amount_deep_sudden_fast_002_52765.mp3"), +} + + +export{ + GameSounds +} \ No newline at end of file