/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var score = 0n;
var identifiers = ['', 'k', 'm', 'b'].concat(Array.from({
length: 23
}, function (_, i) {
return String.fromCharCode(97 + i);
})).concat(['aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj']);
function formatScore(score) {
if (score < 99999n) {
return score;
}
var i = 0;
while (score >= 1000n) {
score /= 1000n;
i++;
}
return "".concat(score, ".").concat(score % 10n).concat(identifiers[i] || '??');
}
// Initialize score display
var scoreTxt = new Text2(score.toString(), {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Retrieve a non-attached LK asset named 'centerbutton'.
// Set its anchor and pivot point to center (x: 0.5, y: 0.5).
var centerButton = LK.getAsset('centerbutton', {
anchorX: 0.5,
anchorY: 0.5
});
//Manually attach asset to element, rather than using self.attachAsset
game.addChild(centerButton);
//Move button to center of screen.
centerButton.x = 2048 / 2;
centerButton.y = 2732 / 2;
centerButton.down = function () {
if (!score) {
score += 1337n;
} else {
score *= 5n;
}
scoreTxt.setText(formatScore(score));
console.log(score);
}; /****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var score = 0n;
var identifiers = ['', 'k', 'm', 'b'].concat(Array.from({
length: 23
}, function (_, i) {
return String.fromCharCode(97 + i);
})).concat(['aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj']);
function formatScore(score) {
if (score < 99999n) {
return score;
}
var i = 0;
while (score >= 1000n) {
score /= 1000n;
i++;
}
return "".concat(score, ".").concat(score % 10n).concat(identifiers[i] || '??');
}
// Initialize score display
var scoreTxt = new Text2(score.toString(), {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Retrieve a non-attached LK asset named 'centerbutton'.
// Set its anchor and pivot point to center (x: 0.5, y: 0.5).
var centerButton = LK.getAsset('centerbutton', {
anchorX: 0.5,
anchorY: 0.5
});
//Manually attach asset to element, rather than using self.attachAsset
game.addChild(centerButton);
//Move button to center of screen.
centerButton.x = 2048 / 2;
centerButton.y = 2732 / 2;
centerButton.down = function () {
if (!score) {
score += 1337n;
} else {
score *= 5n;
}
scoreTxt.setText(formatScore(score));
console.log(score);
};