var elapsedTime = 0; var startTime = Date.now(); var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.createAsset('cloud', 'Cloud in the sky', 0.5, 0.5); cloudGraphics.scale.set(2); cloudGraphics.alpha = 0.8; self.move = function () { self.x -= 2; if (self.x + self.width / 2 < 0) { self.x = 2048 + self.width / 2; self.y = Math.random() * (2732 - self.height); } }; }); var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.createAsset('character', 'Main character', .5, .5); characterGraphics.scale.set(1.5); self.velocityY = 0; self.jump = function () { self.velocityY = -25; }; self.fall = function () { self.velocityY += 1.2; self.y += self.velocityY; if (self.y > 2732 - self.height / 2 || self.y < self.height / 2) { LK.showGameOver(); } }; }); var Castle = Container.expand(function () { var self = Container.call(this); var castleGraphics = self.createAsset('castle', 'Castle obstacle', .5, .5); castleGraphics.scale.set(2.5); self.move = function () { self.x -= elapsedTime > 120 ? 8 : 5; }; }); var EnhancedCastle = Container.expand(function () { var self = Container.call(this); var castleGraphics = self.createAsset('castle', 'Enhanced Castle obstacle', .5, .5); castleGraphics.scale.set(3.5); self.move = function () { self.x -= elapsedTime > 120 ? 10 : 5; }; }); var Game = Container.expand(function () { var self = Container.call(this); var clouds = []; for (var i = 0; i < 5; i++) { var cloud = new Cloud(); cloud.x = Math.random() * 2048; cloud.y = Math.random() * (2732 - cloud.height); clouds.push(cloud); self.addChild(cloud); } LK.on('tick', function () { for (var i = 0; i < clouds.length; i++) { clouds[i].move(); } }); LK.stageContainer.setBackgroundColor(0x87CEEB); var character = self.addChild(new Character()); var castles = []; character.x = 2048 / 2; character.y = 2732 / 2; var timerTxt = new Text2('0:00', { size: 150, fill: "#ffffff" }); timerTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timerTxt); stage.on('down', function (obj) { character.jump(); }); LK.on('tick', function () { character.fall(); for (var i = 0; i < castles.length; i++) { castles[i].move(); if (castles[i].x + castles[i].width / 2 < 0) { castles[i].destroy(); castles.splice(i, 1); } else if (character.intersects(castles[i])) { LK.showGameOver(); } } elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2); timerTxt.setText(elapsedTime + 's'); if (elapsedTime > 180) { LK.showGameOver(); } else if (elapsedTime > 60) { if (LK.ticks % 60 == 0) { var newCastle = new EnhancedCastle(); newCastle.x = 2048 + newCastle.width / 2; newCastle.y = Math.random() * (2732 - newCastle.height); castles.push(newCastle); self.addChild(newCastle); } } else { if (LK.ticks % 80 == 0) { var newCastle = new Castle(); newCastle.x = 2048 + newCastle.width / 2; newCastle.y = Math.random() * (2732 - newCastle.height); castles.push(newCastle); self.addChild(newCastle); } } }); });
var elapsedTime = 0;
var startTime = Date.now();
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.createAsset('cloud', 'Cloud in the sky', 0.5, 0.5);
cloudGraphics.scale.set(2);
cloudGraphics.alpha = 0.8;
self.move = function () {
self.x -= 2;
if (self.x + self.width / 2 < 0) {
self.x = 2048 + self.width / 2;
self.y = Math.random() * (2732 - self.height);
}
};
});
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.createAsset('character', 'Main character', .5, .5);
characterGraphics.scale.set(1.5);
self.velocityY = 0;
self.jump = function () {
self.velocityY = -25;
};
self.fall = function () {
self.velocityY += 1.2;
self.y += self.velocityY;
if (self.y > 2732 - self.height / 2 || self.y < self.height / 2) {
LK.showGameOver();
}
};
});
var Castle = Container.expand(function () {
var self = Container.call(this);
var castleGraphics = self.createAsset('castle', 'Castle obstacle', .5, .5);
castleGraphics.scale.set(2.5);
self.move = function () {
self.x -= elapsedTime > 120 ? 8 : 5;
};
});
var EnhancedCastle = Container.expand(function () {
var self = Container.call(this);
var castleGraphics = self.createAsset('castle', 'Enhanced Castle obstacle', .5, .5);
castleGraphics.scale.set(3.5);
self.move = function () {
self.x -= elapsedTime > 120 ? 10 : 5;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var clouds = [];
for (var i = 0; i < 5; i++) {
var cloud = new Cloud();
cloud.x = Math.random() * 2048;
cloud.y = Math.random() * (2732 - cloud.height);
clouds.push(cloud);
self.addChild(cloud);
}
LK.on('tick', function () {
for (var i = 0; i < clouds.length; i++) {
clouds[i].move();
}
});
LK.stageContainer.setBackgroundColor(0x87CEEB);
var character = self.addChild(new Character());
var castles = [];
character.x = 2048 / 2;
character.y = 2732 / 2;
var timerTxt = new Text2('0:00', {
size: 150,
fill: "#ffffff"
});
timerTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(timerTxt);
stage.on('down', function (obj) {
character.jump();
});
LK.on('tick', function () {
character.fall();
for (var i = 0; i < castles.length; i++) {
castles[i].move();
if (castles[i].x + castles[i].width / 2 < 0) {
castles[i].destroy();
castles.splice(i, 1);
} else if (character.intersects(castles[i])) {
LK.showGameOver();
}
}
elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2);
timerTxt.setText(elapsedTime + 's');
if (elapsedTime > 180) {
LK.showGameOver();
} else if (elapsedTime > 60) {
if (LK.ticks % 60 == 0) {
var newCastle = new EnhancedCastle();
newCastle.x = 2048 + newCastle.width / 2;
newCastle.y = Math.random() * (2732 - newCastle.height);
castles.push(newCastle);
self.addChild(newCastle);
}
} else {
if (LK.ticks % 80 == 0) {
var newCastle = new Castle();
newCastle.x = 2048 + newCastle.width / 2;
newCastle.y = Math.random() * (2732 - newCastle.height);
castles.push(newCastle);
self.addChild(newCastle);
}
}
});
});
Flying, Cute black cat with blue eyes. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Golden star. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cloud. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Meat on the bone. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.