diff --git a/melonjs-tutorial/boilerplate-master/data/map/area01.tmx b/melonjs-tutorial/boilerplate-master/data/map/area01.tmx index ef82c20..378312b 100644 --- a/melonjs-tutorial/boilerplate-master/data/map/area01.tmx +++ b/melonjs-tutorial/boilerplate-master/data/map/area01.tmx @@ -161,7 +161,7 @@ - jQAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAAAAAACNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAAAAAAAAjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAAAAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAA diff --git a/melonjs-tutorial/boilerplate-master/data/sfx/die.mp3 b/melonjs-tutorial/boilerplate-master/data/sfx/die.mp3 new file mode 100644 index 0000000..fb02556 Binary files /dev/null and b/melonjs-tutorial/boilerplate-master/data/sfx/die.mp3 differ diff --git a/melonjs-tutorial/boilerplate-master/js/entities/entities.js b/melonjs-tutorial/boilerplate-master/js/entities/entities.js index 2c4e6b4..015cff1 100755 --- a/melonjs-tutorial/boilerplate-master/js/entities/entities.js +++ b/melonjs-tutorial/boilerplate-master/js/entities/entities.js @@ -76,12 +76,14 @@ game.PlayerEntity = me.Entity.extend({ this.die(); } } else if (response.b.body.collisionType == me.collision.types.ACTION_OBJECT) { + game.data.collectedCoins = []; game.data.current_level = response.b.nextlevel; } }, die: function() { if (this.alive) { + me.audio.play("die"); game.data.lives--; this.alive = false; } @@ -106,7 +108,7 @@ game.CoinEntity = me.CollectableEntity.extend({ onCollision: function() { game.data.score += 3; game.data.coinsNotCollected--; - + game.data.collectedCoins.push(this.pos); me.audio.play("cling"); this.body.setCollisionMask(me.collision.types.NO_OBJECT); diff --git a/melonjs-tutorial/boilerplate-master/js/game.js b/melonjs-tutorial/boilerplate-master/js/game.js index 9c1fa2a..31f4362 100755 --- a/melonjs-tutorial/boilerplate-master/js/game.js +++ b/melonjs-tutorial/boilerplate-master/js/game.js @@ -10,6 +10,7 @@ var game = { lives : 3, // This is programmatically determined on level loads. coinsNotCollected : 0, + collectedCoins : [], // current level current_level: "area03", // reset function @@ -18,6 +19,7 @@ var game = { this.lives = 3; this.current_level = "area01"; this.coinsNotCollected = 0; + this.collectedCoins = []; } }, @@ -83,6 +85,19 @@ var game = { // exit the level. var coins = me.game.world.getChildByName("CoinEntity"); game.data.coinsNotCollected = coins.length; + + // Remove the coins that we already collected + for (var i = 0; i < game.data.collectedCoins.length; i++) { + for (var x = 0; x < coins.length; x++) { + var pos = game.data.collectedCoins[i]; + if (coins[x].pos.x === pos.x && + coins[x].pos.y === pos.y) { + console.log("removing coin at " + pos.x + ", " + pos.y); + me.game.world.removeChild(coins[x]); + game.data.coinsNotCollected--; + } + } + } }, "shouldCollide" : function(a, b) { diff --git a/melonjs-tutorial/boilerplate-master/js/resources.js b/melonjs-tutorial/boilerplate-master/js/resources.js index 8fa2748..c88c457 100755 --- a/melonjs-tutorial/boilerplate-master/js/resources.js +++ b/melonjs-tutorial/boilerplate-master/js/resources.js @@ -54,5 +54,6 @@ game.resources = [ */ {name: "cling", type: "audio", src: "data/sfx/"}, {name: "stomp", type: "audio", src: "data/sfx/"}, + {name: "die", type: "audio", src: "data/sfx/"}, {name: "jump", type: "audio", src: "data/sfx/"} ];