var SmokeParticle = Container.expand(function (startX, startY) {
var self = Container.call(this);
var smokeGraphics = self.createAsset('smoke', 'Smoke Graphics', .5, .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 FireworkParticle = Container.expand(function (startX, startY) {
var self = Container.call(this);
var fireworkGraphics = self.createAsset('firework', 'Firework Graphics', .5, .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 Firework = Container.expand(function () {
var self = Container.call(this);
var fireworkGraphics = self.createAsset('firework', 'Firework Graphics', .5, .5);
LK.setTimeout(function () {
self.destroy();
}, 1000);
});
var Player = Container.expand(function () {
var self = Container.call(this);
Player.prototype.easeAndMoveVertical = function (newX, newY) {
var self = this;
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.createAsset('player', 'Player Graphics', .5, .5);
});
var Arrow = Container.expand(function () {
var self = Container.call(this);
var arrowGraphics = self.createAsset('arrow', 'Arrow Graphics', .5, .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 = 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 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.createAsset('target', 'Target Graphics', .5, .5);
targetGraphics.scale.x = -1;
self.speed = 2;
self.direction = 1;
self.move = 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;
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var bg = self.createAsset('background', 'Background Image', 0, 0);
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.topCenter.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 = self.addChild(new Player());
player.x = 150;
player.y = 2732 / 2;
var target = self.addChild(new Target());
target.x = 2048 - target.width / 2;
target.y = 2732 / 2;
var arrow;
stage.on('move', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
var dx = pos.x - player.x;
var dy = pos.y - player.y;
var angle = Math.atan2(dy, dx);
player.rotation = angle;
});
stage.on('up', function (obj) {
if (arrowCount > 0) {
arrow = self.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();
for (var a = arrows.length - 1; a >= 0; a--) {
var smoke = new SmokeParticle(arrows[a].x, arrows[a].y);
self.addChildAt(smoke, self.getChildIndex(arrows[a]));
arrows[a].move();
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++) {
self.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.