Skip to content
Browse files

use mp3, preload sounds, add geeko sounds

  • Loading branch information...
1 parent 94e905c commit 8acfb621932b57fd5078fd81f44fd3cf693c246c @digitaltom committed
View
3 TODO
@@ -1,9 +1,8 @@
TODO:
- iphone fullscreen
-- sounds + preload
-- theme initializer
- avoid double jumps
+
- different background colors (image)
- startscreen image
- geeko exit
View
3 js/game.js
@@ -414,6 +414,7 @@ function gameOver() {
}
function levelWin() {
+ sound_success()
// todo: winning animation
actors = [];
// todo: level done menu
@@ -439,6 +440,7 @@ function initializeTheme() {
player.spriteMap.src = 'themes/' + theme + '/images/player_sprites.png';
player.sprite.x = 0
player.sprite.y = 32
+ preload_sounds()
}
function gameLoop() {
@@ -495,6 +497,7 @@ function startGame() {
registerControls()
initializeLevel()
initializeTheme()
+ sound_theme()
window.clearInterval(gameInterval);
gameInterval = setInterval(gameLoop, 1000 / speed.fps);
}
View
34 js/sounds.js
@@ -1,24 +1,38 @@
+var sounds = {}
+
+function preload_sounds() {
+ if (sounds[theme] == null) {
+ sounds[theme] = {}
+ sounds[theme]['theme'] = new Audio("themes/" + theme + "/sounds/theme.mp3")
+ sounds[theme]['jump'] = new Audio("themes/" + theme + "/sounds/jump.mp3")
+ sounds[theme]['jump_on_enemy'] = new Audio("themes/" + theme + "/sounds/jump_on_enemy.mp3")
+ sounds[theme]['coin'] = new Audio("themes/" + theme + "/sounds/coin.mp3")
+ sounds[theme]['dead'] = new Audio("themes/" + theme + "/sounds/die.mp3")
+ sounds[theme]['success'] = new Audio("themes/" + theme + "/sounds/success.mp3")
+ }
+}
+
+
function sound_theme() {
- snd = new Audio("themes/" + theme + "/music/theme.wav")
- snd.play()
+ sounds[theme]['theme'].play()
}
function sound_coin() {
- snd = new Audio("themes/" + theme + "/music/coin.wav")
- snd.play()
+ sounds[theme]['coin'].play()
}
function sound_dead() {
- snd = new Audio("themes/" + theme + "/music/dead.wav")
- snd.play()
+ sounds[theme]['dead'].play()
}
function sound_jump() {
- snd = new Audio("themes/" + theme + "/music/jump.wav")
- snd.play()
+ sounds[theme]['jump'].play()
}
function sound_jump_on_enemy() {
- snd = new Audio("themes/" + theme + "/music/jump_on_enemy.wav")
- snd.play()
+ sounds[theme]['jump_on_enemy'].play()
}
+
+function sound_success() {
+ sounds[theme]['success'].play()
+}
View
BIN themes/snoop/sounds/jump.mp3
Binary file not shown.
View
BIN themes/snoop/sounds/jump_on_enemy.mp3
Binary file not shown.
View
BIN themes/snoop/sounds/success.mp3
Binary file not shown.
View
BIN themes/snoop/sounds/theme.mp3
Binary file not shown.
View
BIN themes/super_mario/music/coin.wav
Binary file not shown.
View
BIN themes/super_mario/music/dead.wav
Binary file not shown.
View
BIN themes/super_mario/music/jump.wav
Binary file not shown.
View
BIN themes/super_mario/music/jump_on_enemy.wav
Binary file not shown.
View
BIN themes/super_mario/sounds/coin.mp3
Binary file not shown.
View
BIN themes/super_mario/sounds/dead.mp3
Binary file not shown.
View
BIN themes/super_mario/sounds/jump.mp3
Binary file not shown.
View
BIN themes/super_mario/sounds/jump_on_enemy.mp3
Binary file not shown.
View
0 themes/super_mario/music/smb_bowserfall.wav → themes/super_mario/sounds/smb_bowserfall.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_breakblock.wav → themes/super_mario/sounds/smb_breakblock.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_flagpole.wav → themes/super_mario/sounds/smb_flagpole.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_gameover.wav → themes/super_mario/sounds/smb_gameover.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_mariodie.wav → themes/super_mario/sounds/smb_mariodie.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_pipe.wav → themes/super_mario/sounds/smb_pipe.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_stage_clear.wav → ...es/super_mario/sounds/smb_stage_clear.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_stomp.wav → themes/super_mario/sounds/smb_stomp.wav
File renamed without changes.
View
0 themes/super_mario/music/smb_vine.wav → themes/super_mario/sounds/smb_vine.wav
File renamed without changes.
View
BIN themes/super_mario/sounds/success.mp3
Binary file not shown.
View
BIN themes/super_mario/sounds/theme.mp3
Binary file not shown.
View
BIN themes/suse/sounds/coin.mp3
Binary file not shown.
View
BIN themes/suse/sounds/dead.mp3
Binary file not shown.
View
BIN themes/suse/sounds/jump.mp3
Binary file not shown.
View
BIN themes/suse/sounds/jump_on_enemy.mp3
Binary file not shown.
View
BIN themes/suse/sounds/jump_on_enemy.wav
Binary file not shown.
View
BIN themes/suse/sounds/success.mp3
Binary file not shown.
View
BIN themes/suse/sounds/theme.mp3
Binary file not shown.

0 comments on commit 8acfb62

Please sign in to comment.
Something went wrong with that request. Please try again.