/****
* Classes
****/
var Arrow = Container.expand(function () {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5
});
arrowGraphics.rotation = -135 * (Math.PI / 180);
self.speed = 30 * 0.85;
self.gravity = 0.2 * 1.3 * 0.9 * 0.9 * 0.9 * 0.5;
self.velocityY = 0;
self._move_migrated = function () {
self.x += self.speed * Math.cos(self.rotation);
self.y += self.speed * Math.sin(self.rotation) + self.velocityY;
self.velocityY += self.gravity;
self.rotation += 0.01 * 1.5;
};
});
var Firework = Container.expand(function () {
var self = Container.call(this);
var fireworkGraphics = self.attachAsset('firework', {
anchorX: 0.5,
anchorY: 0.5
});
LK.setTimeout(function () {
self.destroy();
}, 1000);
});
var FireworkParticle = Container.expand(function (startX, startY) {
var self = Container.call(this);
var fireworkGraphics = self.attachAsset('firework', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = startX;
self.y = startY;
var endX = Math.random() * 2048;
var endY = Math.random() * (2732 - 600) + 300;
var travelTime = 50;
var startTime = LK.ticks;
self.animate = function () {
var currentTime = LK.ticks;
var progress = (currentTime - startTime) / travelTime;
if (progress >= 1) {
self.destroy();
}
self.x = startX + (endX - startX) * progress;
self.y = startY + (endY - startY) * progress;
self.scale.x = 1 - progress;
self.scale.y = 1 - progress;
};
LK.on('tick', self.animate);
});
var Player = Container.expand(function () {
var self = Container.call(this);
Player.prototype.easeAndMoveVertical = function (newX, newY) {
var startTime = LK.ticks;
var duration = 30;
var startX = self.x;
var startY = self.y;
var deltaX = newX - startX;
var deltaY = newY - startY;
var easingComplete = false;
LK.on('tick', function () {
var currentTime = LK.ticks;
var progress = (currentTime - startTime) / duration;
if (progress < 1) {
self.x = startX + deltaX * progress;
self.y = startY + deltaY * progress;
} else if (!easingComplete) {
self.x = newX;
self.y = newY;
easingComplete = true;
}
});
};
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
});
var SmokeParticle = Container.expand(function (startX, startY) {
var self = Container.call(this);
var smokeGraphics = self.attachAsset('smoke', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = startX;
self.y = startY;
var scale = 1;
var scaleRate = 1 / (1 * 60);
self.animate = function () {
scale -= scaleRate;
if (scale <= 0) {
self.destroy();
return;
}
self.scale.x = scale;
self.scale.y = scale;
};
LK.on('tick', self.animate);
});
var Target = Container.expand(function () {
var self = Container.call(this);
self.easeAndMoveVertical = function (newX, newY) {
var startTime = LK.ticks;
var duration = 30;
var startX = self.x;
var startY = self.y;
var deltaX = newX - startX;
var deltaY = newY - startY;
var easingComplete = false;
LK.on('tick', function () {
var currentTime = LK.ticks;
var progress = (currentTime - startTime) / duration;
if (progress < 1) {
self.x = startX + deltaX * progress;
self.y = startY + deltaY * progress;
} else if (!easingComplete) {
self.x = newX;
self.y = newY;
easingComplete = true;
self.startVerticalMovement();
}
});
};
self.startVerticalMovement = function () {
self.direction = 1;
self.speed = 4;
};
var targetGraphics = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5
});
targetGraphics.scale.x = -1;
self.speed = 2;
self.direction = 1;
self._move_migrated = function () {
self.y += self.speed * self.direction;
if (self.y >= 2732 * .75 - self.height / 2 || self.y <= 2732 * .24 + self.height / 2) {
self.direction *= -1;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var bg = game.attachAsset('background', {});
bg.width = 2048;
bg.height = 2732;
var arrows = [];
var targets = [];
var score = 0;
var arrowCount = 5;
var arrowCountTxt = new Text2('Arrows: ' + arrowCount, {
size: 100,
fill: "#ffffff"
});
arrowCountTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(arrowCountTxt);
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: "#ffffff"
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
scoreTxt.y = arrowCountTxt.y;
var player = game.addChild(new Player());
player.x = 150;
player.y = 2732 / 2;
var target = game.addChild(new Target());
target.x = 2048 - target.width / 2;
target.y = 2732 / 2;
var arrow;
game.on('move', function (x, y, obj) {
var event = obj;
var pos = game.toLocal(event.global);
var dx = pos.x - player.x;
var dy = pos.y - player.y;
var angle = Math.atan2(dy, dx);
player.rotation = angle;
});
game.on('up', function (x, y, obj) {
if (arrowCount > 0) {
arrow = game.addChild(new Arrow());
arrow.x = player.x;
arrow.y = player.y;
arrow.rotation = player.rotation - Math.PI / 6 + 5 * (Math.PI / 180);
arrows.push(arrow);
}
});
LK.on('tick', function () {
target._move_migrated();
for (var a = arrows.length - 1; a >= 0; a--) {
var smoke = new SmokeParticle(arrows[a].x, arrows[a].y);
game.addChildAt(smoke, game.getChildIndex(arrows[a]));
arrows[a]._move_migrated();
if (arrows[a].x > 2048) {
arrowCount--;
arrows[a].destroy();
arrows.splice(a, 1);
arrowCountTxt.setText('Arrows: ' + arrowCount);
if (arrowCount == 0) {
LK.showGameOver();
}
}
if (arrows[a] && arrows[a].intersects(target) && arrows[a].y > target.y - target.height / 4 && arrows[a].y < target.y + target.height / 4) {
score++;
scoreTxt.setText('Score: ' + score);
if (target.width > 50 && target.height > 50) {
target.scale.x *= 0.95;
target.scale.y *= 0.95;
}
target.speed *= 1.2;
var newX = Math.random() * (2048 * 0.2) + 2048 * 0.7;
var newY = Math.random() * (2732 / 2 + 300 - (2732 / 2 - 300)) + 2732 / 2 - 300;
target.easeAndMoveVertical(newX, newY);
for (var i = 0; i < 10; i++) {
game.addChild(new FireworkParticle(arrows[a].x, arrows[a].y));
}
arrows[a].destroy();
arrows.splice(a, 1);
var newPlayerX = Math.random() * (400 - 100) + 100;
var newPlayerY = Math.random() * (2732 / 2 + 300 - (2732 / 2 - 300)) + 2732 / 2 - 300;
player.easeAndMoveVertical(newPlayerX, newPlayerY);
}
}
});
plain gold star, no outline Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tasty burger. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
small figure of one funny and fat angry man, with brown beard and open mouth, 2d game character. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
star in colors of russian flag, 2d game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Yerevan road from top view, 2d
funny and stupid cock in suit, old, bold head, russian flag, 2d game character. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.