var Coal = Container.expand(function () {
var self = Container.call(this);
var coalGraphics = self.createAsset('coal', 'Coal Graphics', .5, .5);
self.speed = 7;
self.move = function () {
self.speed += 0.6;
self.y += self.speed;
};
});
var Paddle = Container.expand(function () {
var self = Container.call(this);
var paddleGraphics = self.createAsset('paddle', 'Paddle Graphics', .5, 1);
self.speed = 20;
self.move = function () {
if (self.x - paddleGraphics.width / 2 <= 0) {
self.x = paddleGraphics.width / 2;
self.speed = Math.abs(self.speed);
} else if (self.x + paddleGraphics.width / 2 >= 2048) {
self.x = 2048 - paddleGraphics.width / 2;
self.speed = -Math.abs(self.speed);
}
self.speed += self.speed > 0 ? 0.05 : -0.05;
self.speed = Math.min(Math.max(self.speed, -50), 50);
self.x += self.speed;
};
});
var Gift = Container.expand(function () {
var self = Container.call(this);
var giftGraphics = self.createAsset('gift', 'Gift Graphics', .5, .5);
self.speed = 7;
self.move = function () {
self.speed += 0.6;
self.y += self.speed;
};
});
var Santa = Container.expand(function () {
var self = Container.call(this);
var santaGraphics = self.createAsset('santa', 'Santa Graphics', .5, .5);
self.speed = 10;
var santaTickOffset = 0;
self.move = function () {
if (self.x + santaGraphics.width / 2 >= 2048) {
santaGraphics.scale.x = -1;
self.x = 2048 - santaGraphics.width / 2;
self.speed = -Math.abs(self.speed);
} else if (self.x - santaGraphics.width / 2 <= 0) {
santaGraphics.scale.x = 1;
self.x = santaGraphics.width / 2;
self.speed = Math.abs(self.speed);
}
self.x += self.speed;
if (++santaTickOffset % 30 == 0) {
self.speed *= -1;
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Game Background', 0, 0);
background.width = 2048;
background.height = 2732;
self.addChildAt(background, 0);
var paddle = self.addChild(new Paddle());
self.on('down', function (obj) {
paddle.speed = paddle.speed > 0 ? -25 : 25;
});
paddle.x = 2048 / 2;
paddle.y = 2732 - paddle.height + 450;
var gifts = [];
var santa;
var tickOffset = 0;
var santaTickOffset = 0;
var tickOffset = 0;
var santaTickOffset = 0;
var isGameOver = false;
LK.on('tick', function () {
if (santa && santa.move) {
santa.move();
}
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
for (var a = gifts.length - 1; a >= 0; a--) {
if (gifts[a]) {
gifts[a].move();
if (gifts[a].y > 2732) {
gifts[a].destroy();
gifts.splice(a, 1);
} else if (gifts[a].intersects(paddle)) {
if (gifts[a] instanceof Gift) {
gifts[a].destroy();
gifts.splice(a, 1);
} else if (gifts[a] instanceof Coal) {
gifts[a].destroy();
gifts.splice(a, 1);
isGameOver = true;
}
}
}
}
paddle.move();
if (tickOffset++ % 60 == 0) {
if (santa && santa.y < 2732 / 3.5) {
santa.y += 5;
}
var newObject;
if (tickOffset == 1) {
newObject = new Gift();
} else {
newObject = Math.random() < 0.5 ? new Gift() : new Coal();
}
newObject.x = santa ? santa.x : 2048 / 2;
newObject.y = santa ? santa.y : 300;
gifts.push(newObject);
if (santa && self.children.includes(santa)) {
self.addChildAt(newObject, self.getChildIndex(santa));
if (newObject instanceof Gift) {
var hoAsset = self.createAsset('HO', 'HO Graphic', .5, 1);
hoAsset.x = santa.x;
hoAsset.y = santa.y - santa.height / 2 + 100;
self.addChild(hoAsset);
LK.setTimeout(function () {
hoAsset.destroy();
}, 600);
}
} else {
self.addChild(newObject);
}
}
if (tickOffset % 30 == 0 && santa) {
santa.speed *= -1;
}
if (!santa) {
santa = self.addChild(new Santa());
santa.x = 2048 / 2;
santa.y = 300;
}
});
});
black coal. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated. 8 bit
white snowy valley background. Single Game Texture. In-Game asset. 2d. High contrast. No shadows. pixelated. 8 bit
santa sled. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated. 8 bit
Christmas gift. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated. 8 bit
text saying "HO". mistletoe themed. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated. 8 bit
excited kid seen from the front, holding both of his hands extended upwards expecting to catch.looking upward. dressed for Christmas. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated. 8 bit