var CasinoFloor = Container.expand(function () {
var self = Container.call(this);
var floorGraphics = self.createAsset('casinoFloor', 'Casino Floor Background', 0, 0);
floorGraphics.width = 2048;
floorGraphics.height = 2732;
self.addChild(floorGraphics);
self.bettingTables = [];
for (var i = 0; i < 5; i++) {
var table = self.createAsset('bettingTable', 'Betting Table', 0.5, 0.5);
table.x = Math.random() * (2048 - table.width) + table.width / 2;
table.y = Math.random() * (2732 - table.height) + table.height / 2;
self.bettingTables.push(table);
self.addChild(table);
}
self.repositionTables = function () {
for (var i = 0; i < self.bettingTables.length; i++) {
var table = self.bettingTables[i];
table.x = Math.random() * (2048 - table.width) + table.width / 2;
table.y = Math.random() * (2732 - table.height) + table.height / 2;
}
};
});
var HealthBar = Container.expand(function () {
var self = Container.call(this);
self.tries = 3;
self.healthGraphics = [];
for (var i = 0; i < self.tries; i++) {
var badge = self.createAsset('badge', 'Security Badge', 0, 0);
badge.x = i * (badge.width + 10);
self.healthGraphics.push(badge);
self.addChild(badge);
}
self.removeTry = function () {
if (self.tries > 0) {
self.tries--;
var heart = self.healthGraphics.pop();
heart.destroy();
}
};
self.isGameOver = function () {
return self.tries <= 0;
};
});
var Gambler = Container.expand(function () {
var self = Container.call(this);
var gamblerGraphics = self.createAsset('gambler', 'Genuine Gambler', .5, .5);
self.isCheater = false;
self.targetTable = null;
self.speed = 6;
self.move = function (bettingTables) {
if (!self.targetTable) {
self.targetTable = bettingTables[Math.floor(Math.random() * bettingTables.length)];
}
var dx = self.targetTable.x - self.x;
var dy = self.targetTable.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > self.speed) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
} else {
self.targetTable = null;
}
};
});
var Cheater = Gambler.expand(function () {
var self = Container.call(this);
var gamblerGraphics = self.createAsset('cheater', 'Cheating Gambler', .5, .5);
self.isCheater = true;
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.addGamblers = function () {
for (var i = 0; i < 5; i++) {
var gambler = new Gambler();
gambler.x = Math.random() * 2048;
gambler.y = Math.random() * 2732;
self.addChild(gambler);
gamblers.push(gambler);
gambler.on('down', function (obj) {
healthBar.removeTry();
if (healthBar.isGameOver()) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
}
};
function respawnCheater(cheater) {
do {
cheater.x = Math.random() * (2048 - cheater.width) + cheater.width / 2;
cheater.y = Math.random() * (2732 - cheater.height) + cheater.height / 2;
} while (healthBar.healthGraphics.some(function (badge) {
return cheater.intersects(badge);
}));
}
var gamblers = [];
var cheaters = [];
var score = 0;
var scoreTxt;
var cheaterClickCountdown = 5000;
var countdownTxt = new Text2('5', {
size: 150,
fill: "#ffffff"
});
countdownTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(countdownTxt);
var casinoFloor = new CasinoFloor();
self.addChild(casinoFloor);
var healthBar = new HealthBar();
LK.gui.topLeft.addChild(healthBar);
scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
self.addBettingTable = function () {
if (score % 15 === 0 && score !== 0) {
var table = casinoFloor.createAsset('bettingTable', 'Betting Table', 0.5, 0.5);
table.x = Math.random() * (2048 - table.width) + table.width / 2;
table.y = Math.random() * (2732 - table.height) + table.height / 2;
casinoFloor.bettingTables.push(table);
casinoFloor.addChild(table);
}
};
for (var i = 0; i < 15; i++) {
var gambler = new Gambler();
gambler.x = Math.random() * 2048;
gambler.y = Math.random() * 2732;
self.addChild(gambler);
gamblers.push(gambler);
gambler.on('down', function (obj) {
healthBar.removeTry();
if (healthBar.isGameOver()) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
if (i < 1) {
var cheater = new Cheater();
cheater.x = Math.random() * 2048;
cheater.y = Math.random() * 2732;
self.addChild(cheater);
cheaters.push(cheater);
cheater.on('down', function () {
score += 1;
scoreTxt.setText(score);
self.addBettingTable();
if (score % 10 === 0) {
self.addGamblers();
}
respawnCheater(this);
cheaterClickCountdown = 5000;
});
}
}
LK.on('tick', function () {
for (var i = 0; i < gamblers.length; i++) {
gamblers[i].move(casinoFloor.bettingTables);
}
if (cheaterClickCountdown > 0) {
cheaterClickCountdown -= 1000 / 60;
countdownTxt.setText(Math.ceil(cheaterClickCountdown / 1000).toString());
} else {
countdownTxt.setText('0');
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
LK.setInterval(function () {
casinoFloor.repositionTables();
}, 5000);
});
Top down snowy field with some scattered tries. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Topdown view of a very christmassy country house Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A red christmass tree ball decoration Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
adult Raindeer Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rudolf the adult rednose Raindeer in a full side viewed position Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.