var Background = Container.expand(function () {
var self = Container.call(this);
var backgroundGraphics = self.createAsset('background', 'Background Graphics', 0, 0);
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy Graphics', .5, .5);
self.speed = 5 + Math.floor(LK.ticks / 1800);
self.move = function () {
self.y += self.speed;
};
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.createAsset('star', 'Star Graphics', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero Graphics', .5, .5);
self.move = function (x, y) {
self.x = x;
self.y = y;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var stars = [];
var enemies = [];
var hero = self.addChild(new Hero());
var background = self.addChild(new Background());
hero.x = 2048 / 2;
hero.y = 2732 / 2;
var highscoreList = new Text2('Highscores:\n', {
size: 50,
fill: '#ffffff'
});
highscoreList.anchor.set(0, 0);
LK.gui.bottomLeft.addChild(highscoreList);
var updateHighscoreList = function () {};
updateHighscoreList();
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
var timerTxt = new Text2('60:00', {
size: 100,
fill: "#ffffff"
});
timerTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(timerTxt);
timerTxt.y = scoreTxt.height + 10;
var dragNode = null;
var isGameOver = false;
var tickOffset = 0;
var gameTimer = 60 * 60;
stage.on('move', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
if (dragNode) {
dragNode.move(pos.x, pos.y);
}
});
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
dragNode = hero;
dragNode.move(pos.x, pos.y);
});
LK.on('tick', function () {
for (var b = enemies.length - 1; b >= 0; b--) {
for (var e = 0; e < enemies.length; e++) {
if (hero.intersects(enemies[e])) {
isGameOver = true;
break;
}
}
var enemy = enemies[b];
if (enemy) {
enemy.move();
if (enemy.y > 2732) {
enemy.destroy();
enemies.splice(b, 1);
}
}
}
for (var a = stars.length - 1; a >= 0; a--) {
var star = stars[a];
if (star) {
star.move();
if (star.y > 2732) {
star.destroy();
stars.splice(a, 1);
}
}
}
if (tickOffset++ % 60 == 0) {
var newEnemy = new Enemy();
newEnemy.x = Math.random() * 2048;
newEnemy.y = 0;
enemies.push(newEnemy);
self.addChild(newEnemy);
}
if (tickOffset % 30 == 0) {
var newStar = new Star();
newStar.x = Math.random() * 2048;
newStar.y = 0;
stars.push(newStar);
self.addChild(newStar);
}
for (var i = 0; i < stars.length; i++) {
if (hero.intersects(stars[i])) {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
stars[i].destroy();
stars.splice(i, 1);
}
}
gameTimer--;
var minutes = Math.floor(gameTimer / 3600);
var seconds = Math.floor(gameTimer % 3600 / 60);
timerTxt.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
if (gameTimer <= 0 || isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
});
A child with wings, top down view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Meteor, highly detailed Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Space, highly detailed Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Beautiful Bright Star, highly detailed Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.