===================================================================
--- original.js
+++ change.js
@@ -1,11 +1,11 @@
/****
* Classes
****/
// Marshmallow character class
-var Marshmallow = Container.expand(function () {
+var Character = Container.expand(function () {
var self = Container.call(this);
- var marshmallowGraphics = self.createAsset('marshmallow_clipart', 'Fluffy marshmallow character clipart', 0.5, 1);
+ var characterGraphics = self.createAsset('marshmallow_clipart', 'Fluffy marshmallow character clipart', 0.5, 1);
self.velocity = {
x: 0,
y: 0
};
@@ -18,10 +18,10 @@
};
self.update = function () {
self.y += self.velocity.y;
self.velocity.y += 0.5; // gravity effect
- if (self.y > game.height - marshmallowGraphics.height) {
- self.y = game.height - marshmallowGraphics.height;
+ if (self.y > game.height - characterGraphics.height) {
+ self.y = game.height - characterGraphics.height;
self.isJumping = false;
}
};
});
@@ -47,20 +47,20 @@
/****
* Game Code
****/
-var marshmallow = game.addChild(new Marshmallow());
-marshmallow.x = game.width / 4;
-marshmallow.y = game.height - 100;
+var character = game.addChild(new Character());
+character.x = game.width / 4;
+character.y = game.height - 100;
var traps = [];
var scoreTxt = new Text2('0', {
size: 150,
fill: "#000000"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
game.on('down', function (obj) {
- marshmallow.jump();
+ character.jump();
});
var spawnTrap = function spawnTrap() {
var trap = new Trap();
trap.x = game.width;
@@ -76,15 +76,15 @@
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
};
LK.on('tick', function () {
- marshmallow.update();
+ character.update();
for (var i = traps.length - 1; i >= 0; i--) {
traps[i].move();
if (traps[i].isOffScreen()) {
traps[i].destroy();
traps.splice(i, 1);
- } else if (marshmallow.intersects(traps[i])) {
+ } else if (character.intersects(traps[i])) {
gameOver();
}
}
if (LK.ticks % 120 == 0) {