var houseAssets = ['house1', 'house2', 'house3', 'house4', 'house5', 'house6', 'house7', 'house8', 'house9', 'house10'];
var Santa = Container.expand(function () {
var self = Container.call(this);
var santaGraphics = self.createAsset('santa', 'Santa character', .5, .5);
self.speed = 10;
self.jump = function () {
if (!this.hasJumped) {
this.direction = {
x: Math.sin(self.rotation),
y: -Math.cos(self.rotation)
};
this.hasJumped = true;
this.firstJump = true;
}
};
self.hasJumped = false;
self.firstJump = false;
self.score = 0;
self.lastHouse = null;
self.scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff",
weight: 800,
dropShadow: true,
dropShadowColor: '#000000',
dropShadowBlur: 4,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6
});
self.scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(self.scoreTxt);
self.move = function (houses) {
if (self.hasJumped) {
self.x += self.direction.x * self.speed;
self.y += self.direction.y * self.speed;
for (var i = 0; i < houses.length; i++) {
var dx = self.x - houses[i].x;
var dy = self.y - houses[i].y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < santaGraphics.width / 2 + houses[i].width / 2 && houses[i] !== self.lastHouse) {
self.hasJumped = false;
self.lastHouse = houses[i];
self.currentHouse = houses[i];
self.rotationOffset = Math.atan2(dy, dx) - houses[i].rotation;
self.score += 1;
self.scoreTxt.setText(self.score);
break;
}
}
}
if (!self.hasJumped && self.currentHouse) {
var angle = self.currentHouse.rotation + self.rotationOffset;
self.x = self.currentHouse.x + Math.cos(angle) * (self.currentHouse.width / 2 + santaGraphics.height / 2);
self.y = self.currentHouse.y + Math.sin(angle) * (self.currentHouse.width / 2 + santaGraphics.height / 2);
self.rotation = angle + Math.PI / 2;
}
};
});
var House = Container.expand(function () {
var self = Container.call(this);
var randomHouseIndex = Math.floor(Math.random() * houseAssets.length);
var houseGraphics = self.createAsset(houseAssets[randomHouseIndex], 'House object', .5, .5);
self.rotationStep = Math.random() * 0.02 - 0.01;
if (self.rotationStep > 0 && self.rotationStep < 0.01) self.rotationStep = 0.01;
if (self.rotationStep < 0 && self.rotationStep > -0.01) self.rotationStep = -0.01;
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Background image', .5, .5);
background.x = 2048 / 2;
background.y = 2732 / 2;
self.addChildAt(background, 0);
LK.stageContainer.setBackgroundColor(0x000000);
var gameContainer = new Container();
self.addChild(gameContainer);
var santa = gameContainer.addChild(new Santa());
santa.x = 2048 / 2;
santa.y = 2732 - 300;
var houses = [];
var houseSpeed = -2;
self.spawnHouse = function () {
var newHouse = new House();
newHouse.rotation = Math.random() * Math.PI * 2;
newHouse.scale.set(Math.random() * 0.5 + 0.5);
if (houses.length === 0) {
newHouse.x = 2048 / 2;
newHouse.y = 2732 / 2;
} else {
var lastHouseY = houses[houses.length - 1].y;
var gameHeightThird = 2732 / 3;
newHouse.y = lastHouseY - (Math.random() * gameHeightThird + gameHeightThird);
newHouse.x = Math.random() * (2048 - 600) + 300;
}
houses.push(newHouse);
gameContainer.addChildAt(newHouse, 0);
};
var isGameOver = false;
for (var i = 0; i < 8; i++) {
self.spawnHouse();
}
stage.on('down', function (obj) {
santa.jump();
});
var tickOffset = 0;
LK.on('tick', function () {
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
} else {
santa.move(houses);
}
for (var a = houses.length - 1; a >= 0; a--) {
if (santa.firstJump) {
houses[a].y -= houseSpeed;
}
houses[a].rotation += houses[a].rotationStep;
if (houses[a].x < -50 || houses[a].y > 2732 + houses[a].height) {
houses[a].destroy();
houses.splice(a, 1);
self.spawnHouse();
}
}
var santaScreenX = santa.x;
var santaScreenY = santa.y + gameContainer.y;
if ((santaScreenX < 0 || santaScreenX > 2048 || santaScreenY < 0) && santa.hasJumped || santa.y > 2732) {
isGameOver = true;
}
});
});
Circular Santa, with gifts on his back. Cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Perfectly round planet looking like a house, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round house planet, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round house planet, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round house planet, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round house planet, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast.
round house planet, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Starry Christmas night sky, cartoon, background