Skip to content

Commit

Permalink
Add music
Browse files Browse the repository at this point in the history
  • Loading branch information
voithos committed Dec 31, 2013
1 parent 8b30fec commit 3b64b2f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
9 changes: 7 additions & 2 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ Attribution

Organized by asset:

- `assets/sounds/empty_rooms.mp3` made by `_ghost` from ccmixter
- `assets/tiles/*` made by `www.kenney.nl`, taken from OpenGameArt
- `assets/sprites/*` made by `www.kenney.nl`, taken from OpenGameArt
- `assets/sounds/happy.*` made by `rezoner`, taken from OpenGameArt
- `assets/sounds/air.wav` made by `remaxim`, taken from OpenGameArt
- `assets/sounds/water.wav` made by `kurt`, taken from OpenGameArt
- `assets/sounds/earth.wav` made by `qubodup`, taken from OpenGameArt
- `assets/sounds/fire.wav` made by `p0ss`, taken from OpenGameArt
- `assets/sounds/pickup.wav` made by `p0ss`, taken from OpenGameArt
Binary file removed assets/sounds/empty_rooms.mp3
Binary file not shown.
Binary file added assets/sounds/happy.mp3
Binary file not shown.
Binary file added assets/sounds/happy.ogg
Binary file not shown.
20 changes: 16 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function preload() {
game.load.spritesheet('blocks', 'assets/tilesets/tiles_spritesheet.png', cfg.TILE_WIDTH, cfg.TILE_HEIGHT);
game.load.atlasXML('particles', 'assets/sprites/particles.png', 'assets/sprites/particles.xml');

game.load.audio('theme', ['assets/sounds/happy.mp3', 'assets/sounds/happy.ogg'], true);

game.load.audio('jumpsound', 'assets/sounds/jump.wav', true);
game.load.audio('pickupsound', 'assets/sounds/pickup.wav', true);
game.load.audio('airsound', 'assets/sounds/air.wav', true);
Expand All @@ -61,14 +63,14 @@ function preload() {
}

var map, tileset, surface, background,
player, goal, clouds, items, backgroundItems, blocks,
elemEmitters = {}, sfx = {},
player, goal, clouds, items, backgroundItems, blocks, theme,
sfx = {}, elemEmitters = {},
cursors, elemButton, acquireButton, dropButton;

function create() {
game.stage.backgroundColor = cfg.BACKGROUND;

createSfx();
createAudio();

map = game.add.tilemap(game.level);
tileset = game.add.tileset('tiles');
Expand Down Expand Up @@ -118,9 +120,19 @@ function create() {
elemButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
acquireButton = game.input.keyboard.addKey(Phaser.Keyboard.Z);
dropButton = game.input.keyboard.addKey(Phaser.Keyboard.X);

if (!theme.isPlaying) {
theme.play('', 0, 0.6, true);
}
}

function createSfx() {
function createAudio() {
// Avoid recreating the music
if (theme) {
return;
}
theme = game.add.audio('theme');

// Add sfx
['jumpsound', 'pickupsound'].forEach(function(s) {
sfx[s] = game.add.audio(s);
Expand Down

0 comments on commit 3b64b2f

Please sign in to comment.