Add audio
This commit is contained in:
parent
0101ef8d55
commit
62b8c74f57
26 changed files with 225 additions and 18 deletions
5
js/game/audio.mjs
Normal file
5
js/game/audio.mjs
Normal file
|
@ -0,0 +1,5 @@
|
|||
import {audio} from '../assets.mjs';
|
||||
|
||||
export function play(name) {
|
||||
audio[name].cloneNode(true).play();
|
||||
}
|
|
@ -87,7 +87,9 @@ function validate() {
|
|||
if (tile.type == 'thruster') thrustersFound++;
|
||||
if (tile.type == 'fuel') fuelFound++;
|
||||
tile.neighbours.forEach(n => {
|
||||
if (unvisited.has(n)) visit(n);
|
||||
if (unvisited.has(n) && n.neighbours.indexOf(tile) > -1) {
|
||||
visit(n);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -111,7 +113,7 @@ function validate() {
|
|||
} else {
|
||||
message = reason;
|
||||
}
|
||||
|
||||
|
||||
return reason;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import * as player from './player.mjs';
|
|||
import * as inventory from './inventory.mjs';
|
||||
import * as particle from '../world/particle.mjs';
|
||||
import * as edit from './edit.mjs';
|
||||
import * as audio from './audio.mjs';
|
||||
|
||||
export let shipLanded = false;
|
||||
|
||||
|
@ -71,6 +72,7 @@ export function endEditing() {
|
|||
let {valid, reason} = edit.end();
|
||||
|
||||
if (valid) {
|
||||
audio.play('endEdit');
|
||||
graphics.changePerspective('universe');
|
||||
game.state.editing = false;
|
||||
game.state.inventory = false;
|
||||
|
@ -91,5 +93,6 @@ export function tossItem() {
|
|||
|
||||
export function collectItem(type, id) {
|
||||
inventory.addItem(type, id);
|
||||
audio.play('itemPickup');
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ let onupdate = () => {};
|
|||
|
||||
export function init() {
|
||||
items.clear();
|
||||
addItem('connector', 'xheavy');
|
||||
}
|
||||
|
||||
export function getTiles() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue