Skip to content

Commit

Permalink
More work on coins.
Browse files Browse the repository at this point in the history
  • Loading branch information
ripsawridge committed Nov 22, 2014
1 parent 260480f commit c339a59
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion melonjs-tutorial/boilerplate-master/data/map/area01.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
</layer>
<layer name="collision" width="40" height="15" opacity="0.5">
<data encoding="base64">
jQAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAAAAAACNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAAAAAAAAjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAAAAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAAjQAAAI0AAACNAAAA
</data>
</layer>
</map>
Binary file not shown.
4 changes: 3 additions & 1 deletion melonjs-tutorial/boilerplate-master/js/entities/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions melonjs-tutorial/boilerplate-master/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,6 +19,7 @@ var game = {
this.lives = 3;
this.current_level = "area01";
this.coinsNotCollected = 0;
this.collectedCoins = [];
}
},

Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions melonjs-tutorial/boilerplate-master/js/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/"}
];

0 comments on commit c339a59

Please sign in to comment.