Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some sounds.

  • Loading branch information...
commit a27047acf2d943463d7153fa8070f49b8df7e76e 1 parent 7690982
@Osmose authored
View
BIN  audio/get_blocks.ogg
Binary file not shown
View
BIN  audio/push_blocks.ogg
Binary file not shown
View
BIN  audio/st2_die.ogg
Binary file not shown
View
23 js/game/player.js
@@ -1,8 +1,12 @@
define(function(require) {
var Entity = require('flux/entity');
+ var Sound = require('flux/sound');
var TiledGraphic = require('flux/graphics/tiled');
var loader = require('game/loader');
+ loader.register('get_blocks', 'audio/get_blocks.ogg', 'audio');
+ loader.register('push_blocks', 'audio/push_blocks.ogg', 'audio');
+
function Player(x, y) {
Entity.call(this, x, y);
this.col = 6;
@@ -16,6 +20,12 @@ define(function(require) {
this.grabkey = true;
this.throwkey = true;
+
+ this.get_blocks_sound = new Sound(loader.get('get_blocks'));
+ this.push_blocks_sound = new Sound(loader.get('push_blocks'));
+
+ this.get_blocks_sound.audio.volume = 0.05;
+ this.push_blocks_sound.audio.volume = 0.05;
}
Player.prototype = Object.create(Entity.prototype);
@@ -33,14 +43,20 @@ define(function(require) {
if (kb.check(kb.D) && !this.grabkey) {
this.grabkey = true;
+ var addblocks;
if (this.heldblocks.length === 0) {
- var addblocks = this.world.getBlocks(this.col);
+ addblocks = this.world.getBlocks(this.col);
this.heldblocks = this.heldblocks.concat(addblocks);
} else {
// Let them pick up more of the same color if they want
- var addblocks = this.world.getBlocks(this.col, this.heldblocks[0]);
+ addblocks = this.world.getBlocks(this.col, this.heldblocks[0]);
this.heldblocks = this.heldblocks.concat(addblocks);
}
+
+ if (addblocks.length > 0) {
+ this.get_blocks_sound.stop();
+ this.get_blocks_sound.play();
+ }
}
if (!kb.check(kb.D)){
this.grabkey = false;
@@ -57,6 +73,9 @@ define(function(require) {
if (this.heldblocks.length > 0) {
this.world.pushBlocks(this.heldblocks, this.col);
this.heldblocks = [];
+
+ this.push_blocks_sound.stop();
+ this.push_blocks_sound.play();
}
}
if (!kb.check(kb.F)) {
View
14 js/game/world.js
@@ -6,6 +6,7 @@ define(function(require) {
var loader = require('game/loader');
loader.register('stage_music', 'audio/show_no_tears.ogg', 'audio');
+ loader.register('ball_sound', 'audio/st2_die.ogg', 'audio');
var SHOW_MATCH_LENGTH = 32;
@@ -39,7 +40,12 @@ define(function(require) {
}
this.music = new Sound(loader.get('stage_music'));
+ this.music.audio.volume = 0.04; // wtf I hate volume control
this.running = false;
+
+ this.ball_sound = new Sound(loader.get('ball_sound'));
+ this.ball_sound.audio.volume = 0.06;
+ this.play_ball_sound = false;
}
BallWorld.prototype = Object.create(DefaultWorld.prototype);
@@ -137,6 +143,7 @@ define(function(require) {
var matches = this.resolveColumn(col);
if (matches) {
this.show_match_count = SHOW_MATCH_LENGTH;
+ this.play_ball_sound = true;
}
this.checkGameOver();
@@ -167,6 +174,7 @@ define(function(require) {
if (affected[k]) {
if (this.resolveColumn(k)) {
this.show_match_count = SHOW_MATCH_LENGTH;
+ this.play_ball_sound = true;
}
}
}
@@ -187,6 +195,12 @@ define(function(require) {
this.generateRow();
}
}
+
+ if (this.play_ball_sound) {
+ this.play_ball_sound = false;
+ this.ball_sound.stop();
+ this.ball_sound.play();
+ }
};
BallWorld.prototype.render = function(ctx) {
Please sign in to comment.
Something went wrong with that request. Please try again.