var SlowCloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.createAsset('cloud', 'Cloud Graphics', .5, .5);
cloudGraphics.scale.x *= 2;
cloudGraphics.scale.y *= 2;
self.speed = (Math.random() * 1 + 1) * 2;
self.move = function () {
self.x -= self.speed;
if (self.x <= -cloudGraphics.width) {
self.x = 2048 + cloudGraphics.width;
self.y = Math.random() * 2732;
}
};
});
var MediumCloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.createAsset('cloud', 'Cloud Graphics', .5, .5);
cloudGraphics.scale.x *= 4;
cloudGraphics.scale.y *= 4;
self.speed = (Math.random() * 2 + 1) * 4;
self.move = function () {
self.x -= self.speed;
if (self.x <= -cloudGraphics.width) {
self.x = 2048 + cloudGraphics.width;
self.y = Math.random() * 2732;
}
};
});
var FastCloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.createAsset('cloud', 'Cloud Graphics', .5, .5);
cloudGraphics.scale.x *= 6;
cloudGraphics.scale.y *= 6;
self.speed = (Math.random() * 3 + 1) * 6;
self.move = function () {
self.x -= self.speed;
if (self.x <= -cloudGraphics.width) {
self.x = 2048 + cloudGraphics.width;
self.y = Math.random() * 2732;
}
};
});
var Explosion = Container.expand(function () {
var self = Container.call(this);
var explosionGraphics = self.createAsset('explosion', 'Explosion Graphics', .5, .5);
explosionGraphics.scale.x *= 2;
explosionGraphics.scale.y *= 2;
self.duration = 30;
self.tick = function () {
self.duration--;
if (self.duration <= 0) {
self.destroy();
}
};
});
var Missile = Container.expand(function () {
var self = Container.call(this);
var missileGraphics = self.createAsset('missile', 'Missile Graphics', .5, .5);
missileGraphics.scale.x *= -4;
missileGraphics.scale.y *= 4;
self.gameDuration = 0;
self.speed = -20 - self.gameDuration * 5;
self.move = function () {
self.speed = -20 - self.gameDuration * 2.5;
self.x += self.speed;
};
});
var Superman = Container.expand(function () {
var self = Container.call(this);
var supermanGraphics = self.createAsset('superman', 'Superman Graphics', .5, .5);
self.hitCount = 0;
self.move = function (x, y) {
self.x = x;
self.y = y;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
LK.stageContainer.setBackgroundColor(0x0000ff);
var clouds = [];
for (var i = 0; i < 3; i++) {
var slowCloud = new SlowCloud();
slowCloud.x = Math.random() * 2048;
slowCloud.y = Math.random() * 2732;
clouds.push(slowCloud);
self.addChild(slowCloud);
}
for (var i = 0; i < 3; i++) {
var mediumCloud = new MediumCloud();
mediumCloud.x = Math.random() * 2048;
mediumCloud.y = Math.random() * 2732;
clouds.push(mediumCloud);
self.addChild(mediumCloud);
}
for (var i = 0; i < 3; i++) {
var fastCloud = new FastCloud();
fastCloud.x = Math.random() * 2048;
fastCloud.y = Math.random() * 2732;
clouds.push(fastCloud);
self.addChild(fastCloud);
}
var superman = self.addChild(new Superman());
var missiles = [];
superman.x = 100;
superman.y = 2732 / 2;
var isGameOver = false;
var tickOffset = 0;
var gameDuration = 0;
var gameDurationText = new Text2('0', {
size: 150,
fill: '#ffffff'
});
gameDurationText.anchor.set(.5, 0);
LK.gui.topCenter.addChild(gameDurationText);
LK.on('tick', function () {
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
for (var a = missiles.length - 1; a >= 0; a--) {
if (missiles[a]) {
missiles[a].move();
if (missiles[a].x < -50) {
missiles[a].destroy();
missiles.splice(a, 1);
}
if (superman.intersects(missiles[a])) {
var explosion = new Explosion();
explosion.x = missiles[a].x;
explosion.y = missiles[a].y;
self.addChild(explosion);
missiles[a].destroy();
missiles.splice(a, 1);
superman.hitCount += 1;
if (superman.hitCount >= 4) {
isGameOver = true;
}
}
}
}
clouds.forEach(function (cloud) {
cloud.move();
});
if (tickOffset++ % 60 == 0) {
gameDuration++;
gameDurationText.setText(gameDuration);
}
if (tickOffset % 30 == 0) {
var newMissile = new Missile();
newMissile.x = 2048;
newMissile.y = Math.random() * 2732;
newMissile.gameDuration = gameDuration;
missiles.push(newMissile);
self.addChild(newMissile);
}
self.children.forEach(function (child) {
if (child instanceof Explosion) {
child.tick();
}
});
});
var dragNode = null;
stage.on('down', function (obj) {
dragNode = superman;
});
function handleMove(obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
if (dragNode) {
dragNode.move(pos.x, pos.y);
}
}
stage.on('move', handleMove);
stage.on('up', function (obj) {
dragNode = null;
});
});
Side view of superman flying from left to right, with his fist pushed out in front of him. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a missile flying parallel to the ground Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A sky with clouds, tileable Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An explosion Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a puffy white cloud Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.