/**** * Classes ****/ var Ascend = Container.expand(function () { var self = Container.call(this); self.hasAscended = false; // Initialize hasAscended flag // Create and attach an ascend asset var ascendGraphics = self.attachAsset('Ascend', { anchorX: 0.5, anchorY: 0.5 }); // Add multiplier text to the ascend button var multiplierTxt = new Text2('x' + (LK.getScore() / 100000).toFixed(2), { size: 50, fill: 0x000000 }); self.updateMultiplierText = function () { var multiplier = Math.pow(LK.getScore(), 0.25); if (multiplier > 1e+20) { multiplierTxt.setText('x' + multiplier.toExponential(2)); } else { multiplierTxt.setText('x' + multiplier.toFixed(2)); } }; multiplierTxt.anchor.set(0.5, 0.5); self.addChild(multiplierTxt); // Event handler for when the ascend is clicked self.down = function (x, y, obj) { // Check if the score is over 100000 before allowing ascend if (LK.getScore() > 100000) { var multiplier = Math.pow(LK.getScore(), 0.25); circle.coinsPerClick = 1; // Reset coinsPerClick to base value circle.ascendMultiplier = multiplier; // Store the multiplier for future use LK.setScore(0); // Reset score after applying multiplier self.hasAscended = true; // Set flag to true after first ascend self.updateMultiplierText(); } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define a ClickableCircle class var ClickableCircle = Container.expand(function () { var self = Container.call(this); self.coinsPerClick = 1; // Create and attach a circle asset var circleGraphics = self.attachAsset('circle', { anchorX: 0.5, anchorY: 0.5 }); // Event handler for when the circle is clicked self.down = function (x, y, obj) { // Increase score by coinsPerClick when the circle is clicked var ascendMultiplier = circle.ascendMultiplier || 1; // Use stored multiplier or default to 1 LK.setScore(LK.getScore() + self.coinsPerClick * ascendMultiplier); var score = LK.getScore(); scoreTxt.setText(score > 1e+20 ? score.toExponential(2) : score); }; }); var Upgrade = Container.expand(function () { var self = Container.call(this); self.cost = 20; // Create and attach an upgrade asset var upgradeGraphics = self.attachAsset('Upgrade', { anchorX: 0.5, anchorY: 0.5 }); // Add cost text to the upgrade button var costTxt = new Text2(self.cost.toString(), { size: 100, fill: 0x000000 }); costTxt.anchor.set(0.5, 0.5); self.addChild(costTxt); // Event handler for when the upgrade is clicked self.down = function (x, y, obj) { // Check if the player has enough score to purchase the upgrade if (LK.getScore() >= self.cost) { // Deduct the cost of the upgrade from the score LK.setScore(LK.getScore() - self.cost); scoreTxt.setText(LK.getScore()); // Increase coins per click by 1 when the upgrade is clicked circle.coinsPerClick += 1; // Update the cost text costTxt.setText(self.cost.toString()); } }; }); var Upgrade2 = Container.expand(function () { var self = Container.call(this); self.cost = 200; // Create and attach an upgrade2 asset var upgrade2Graphics = self.attachAsset('Upgrade2', { anchorX: 0.5, anchorY: 0.5 }); // Add cost text to the upgrade2 button var costTxt = new Text2(self.cost.toString(), { size: 100, fill: 0x000000 }); costTxt.anchor.set(0.5, 0.5); self.addChild(costTxt); // Event handler for when the upgrade2 is clicked self.down = function (x, y, obj) { // Check if the player has enough score to purchase the upgrade2 if (LK.getScore() >= self.cost) { // Deduct the cost of the upgrade2 from the score LK.setScore(LK.getScore() - self.cost); scoreTxt.setText(LK.getScore()); // Increase coins per click by 5 when the upgrade2 is clicked circle.coinsPerClick += 5; // Update the cost text costTxt.setText(self.cost.toString()); } }; }); var Upgrade3 = Container.expand(function () { var self = Container.call(this); self.cost = 2500; // Create and attach an upgrade3 asset var upgrade3Graphics = self.attachAsset('Upgrade3', { anchorX: 0.5, anchorY: 0.5 }); // Add cost text to the upgrade3 button var costTxt = new Text2(self.cost.toString(), { size: 100, fill: 0x000000 }); costTxt.anchor.set(0.5, 0.5); self.addChild(costTxt); // Event handler for when the upgrade3 is clicked self.down = function (x, y, obj) { // Check if the player has enough score to purchase the upgrade3 if (LK.getScore() >= self.cost) { // Deduct the cost of the upgrade3 from the score LK.setScore(LK.getScore() - self.cost); scoreTxt.setText(LK.getScore()); // Increase coins per click by 25 when the upgrade3 is clicked circle.coinsPerClick += 25; // Update the cost text costTxt.setText(self.cost.toString()); } }; }); var Upgrade4 = Container.expand(function () { var self = Container.call(this); self.cost = 25000; // Create and attach an upgrade4 asset var upgrade4Graphics = self.attachAsset('Upgrade4', { anchorX: 0.5, anchorY: 0.5 }); // Add cost text to the upgrade4 button var costTxt = new Text2(self.cost.toString(), { size: 100, fill: 0x000000 }); costTxt.anchor.set(0.5, 0.5); self.addChild(costTxt); // Event handler for when the upgrade4 is clicked self.down = function (x, y, obj) { // Check if the player has enough score to purchase the upgrade4 if (LK.getScore() >= self.cost) { // Deduct the cost of the upgrade4 from the score LK.setScore(LK.getScore() - self.cost); scoreTxt.setText(LK.getScore()); // Increase coins per click by 100 when the upgrade4 is clicked circle.coinsPerClick += 100; // Update the cost text costTxt.setText(self.cost.toString()); } }; }); var Upgrade5 = Container.expand(function () { var self = Container.call(this); self.cost = 100000; // Create and attach an upgrade5 asset var upgrade5Graphics = self.attachAsset('Upgrade5', { anchorX: 0.5, anchorY: 0.5 }); // Add cost text to the upgrade5 button var costTxt = new Text2(self.cost.toString(), { size: 100, fill: 0x000000 }); costTxt.anchor.set(0.5, 0.5); self.addChild(costTxt); // Event handler for when the upgrade5 is clicked self.down = function (x, y, obj) { // Check if the player has enough score to purchase the upgrade5 if (LK.getScore() >= self.cost) { // Deduct the cost of the upgrade5 from the score LK.setScore(LK.getScore() - self.cost); scoreTxt.setText(LK.getScore()); // Multiply coins per click by 1.1 when the upgrade5 is clicked circle.coinsPerClick *= 1.1; // Update the cost text costTxt.setText(self.cost.toString()); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize score text var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create a clickable circle and add it to the game var circle = game.addChild(new ClickableCircle()); circle.x = 2048 / 2; circle.y = 2732 / 2; // Create an upgrade and add it to the game var upgrade = game.addChild(new Upgrade()); upgrade.x = 2048 / 2 - 700; upgrade.y = 2732 / 3; // Create an upgrade2 and add it to the game var upgrade2 = game.addChild(new Upgrade2()); upgrade2.x = upgrade.x + upgrade.width + 50; upgrade2.y = upgrade.y; // Update function called every game tick // Create an upgrade3 and add it to the game var upgrade3 = game.addChild(new Upgrade3()); upgrade3.x = upgrade2.x + upgrade2.width + 50; upgrade3.y = upgrade2.y; // Create an upgrade4 and add it to the game var upgrade4 = game.addChild(new Upgrade4()); upgrade4.x = upgrade3.x + upgrade3.width + 50; upgrade4.y = upgrade3.y; // Create an upgrade5 and add it to the game var upgrade5 = game.addChild(new Upgrade5()); upgrade5.x = upgrade4.x + upgrade4.width + 50; upgrade5.y = upgrade4.y; // Create an ascend and add it to the game var ascend = game.addChild(new Ascend()); ascend.x = 2048 / 2; ascend.y = upgrade5.y + upgrade5.height + 650; game.update = function () { ascend.updateMultiplierText(); };
/****
* Classes
****/
var Ascend = Container.expand(function () {
var self = Container.call(this);
self.hasAscended = false; // Initialize hasAscended flag
// Create and attach an ascend asset
var ascendGraphics = self.attachAsset('Ascend', {
anchorX: 0.5,
anchorY: 0.5
});
// Add multiplier text to the ascend button
var multiplierTxt = new Text2('x' + (LK.getScore() / 100000).toFixed(2), {
size: 50,
fill: 0x000000
});
self.updateMultiplierText = function () {
var multiplier = Math.pow(LK.getScore(), 0.25);
if (multiplier > 1e+20) {
multiplierTxt.setText('x' + multiplier.toExponential(2));
} else {
multiplierTxt.setText('x' + multiplier.toFixed(2));
}
};
multiplierTxt.anchor.set(0.5, 0.5);
self.addChild(multiplierTxt);
// Event handler for when the ascend is clicked
self.down = function (x, y, obj) {
// Check if the score is over 100000 before allowing ascend
if (LK.getScore() > 100000) {
var multiplier = Math.pow(LK.getScore(), 0.25);
circle.coinsPerClick = 1; // Reset coinsPerClick to base value
circle.ascendMultiplier = multiplier; // Store the multiplier for future use
LK.setScore(0); // Reset score after applying multiplier
self.hasAscended = true; // Set flag to true after first ascend
self.updateMultiplierText();
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Define a ClickableCircle class
var ClickableCircle = Container.expand(function () {
var self = Container.call(this);
self.coinsPerClick = 1;
// Create and attach a circle asset
var circleGraphics = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5
});
// Event handler for when the circle is clicked
self.down = function (x, y, obj) {
// Increase score by coinsPerClick when the circle is clicked
var ascendMultiplier = circle.ascendMultiplier || 1; // Use stored multiplier or default to 1
LK.setScore(LK.getScore() + self.coinsPerClick * ascendMultiplier);
var score = LK.getScore();
scoreTxt.setText(score > 1e+20 ? score.toExponential(2) : score);
};
});
var Upgrade = Container.expand(function () {
var self = Container.call(this);
self.cost = 20;
// Create and attach an upgrade asset
var upgradeGraphics = self.attachAsset('Upgrade', {
anchorX: 0.5,
anchorY: 0.5
});
// Add cost text to the upgrade button
var costTxt = new Text2(self.cost.toString(), {
size: 100,
fill: 0x000000
});
costTxt.anchor.set(0.5, 0.5);
self.addChild(costTxt);
// Event handler for when the upgrade is clicked
self.down = function (x, y, obj) {
// Check if the player has enough score to purchase the upgrade
if (LK.getScore() >= self.cost) {
// Deduct the cost of the upgrade from the score
LK.setScore(LK.getScore() - self.cost);
scoreTxt.setText(LK.getScore());
// Increase coins per click by 1 when the upgrade is clicked
circle.coinsPerClick += 1;
// Update the cost text
costTxt.setText(self.cost.toString());
}
};
});
var Upgrade2 = Container.expand(function () {
var self = Container.call(this);
self.cost = 200;
// Create and attach an upgrade2 asset
var upgrade2Graphics = self.attachAsset('Upgrade2', {
anchorX: 0.5,
anchorY: 0.5
});
// Add cost text to the upgrade2 button
var costTxt = new Text2(self.cost.toString(), {
size: 100,
fill: 0x000000
});
costTxt.anchor.set(0.5, 0.5);
self.addChild(costTxt);
// Event handler for when the upgrade2 is clicked
self.down = function (x, y, obj) {
// Check if the player has enough score to purchase the upgrade2
if (LK.getScore() >= self.cost) {
// Deduct the cost of the upgrade2 from the score
LK.setScore(LK.getScore() - self.cost);
scoreTxt.setText(LK.getScore());
// Increase coins per click by 5 when the upgrade2 is clicked
circle.coinsPerClick += 5;
// Update the cost text
costTxt.setText(self.cost.toString());
}
};
});
var Upgrade3 = Container.expand(function () {
var self = Container.call(this);
self.cost = 2500;
// Create and attach an upgrade3 asset
var upgrade3Graphics = self.attachAsset('Upgrade3', {
anchorX: 0.5,
anchorY: 0.5
});
// Add cost text to the upgrade3 button
var costTxt = new Text2(self.cost.toString(), {
size: 100,
fill: 0x000000
});
costTxt.anchor.set(0.5, 0.5);
self.addChild(costTxt);
// Event handler for when the upgrade3 is clicked
self.down = function (x, y, obj) {
// Check if the player has enough score to purchase the upgrade3
if (LK.getScore() >= self.cost) {
// Deduct the cost of the upgrade3 from the score
LK.setScore(LK.getScore() - self.cost);
scoreTxt.setText(LK.getScore());
// Increase coins per click by 25 when the upgrade3 is clicked
circle.coinsPerClick += 25;
// Update the cost text
costTxt.setText(self.cost.toString());
}
};
});
var Upgrade4 = Container.expand(function () {
var self = Container.call(this);
self.cost = 25000;
// Create and attach an upgrade4 asset
var upgrade4Graphics = self.attachAsset('Upgrade4', {
anchorX: 0.5,
anchorY: 0.5
});
// Add cost text to the upgrade4 button
var costTxt = new Text2(self.cost.toString(), {
size: 100,
fill: 0x000000
});
costTxt.anchor.set(0.5, 0.5);
self.addChild(costTxt);
// Event handler for when the upgrade4 is clicked
self.down = function (x, y, obj) {
// Check if the player has enough score to purchase the upgrade4
if (LK.getScore() >= self.cost) {
// Deduct the cost of the upgrade4 from the score
LK.setScore(LK.getScore() - self.cost);
scoreTxt.setText(LK.getScore());
// Increase coins per click by 100 when the upgrade4 is clicked
circle.coinsPerClick += 100;
// Update the cost text
costTxt.setText(self.cost.toString());
}
};
});
var Upgrade5 = Container.expand(function () {
var self = Container.call(this);
self.cost = 100000;
// Create and attach an upgrade5 asset
var upgrade5Graphics = self.attachAsset('Upgrade5', {
anchorX: 0.5,
anchorY: 0.5
});
// Add cost text to the upgrade5 button
var costTxt = new Text2(self.cost.toString(), {
size: 100,
fill: 0x000000
});
costTxt.anchor.set(0.5, 0.5);
self.addChild(costTxt);
// Event handler for when the upgrade5 is clicked
self.down = function (x, y, obj) {
// Check if the player has enough score to purchase the upgrade5
if (LK.getScore() >= self.cost) {
// Deduct the cost of the upgrade5 from the score
LK.setScore(LK.getScore() - self.cost);
scoreTxt.setText(LK.getScore());
// Multiply coins per click by 1.1 when the upgrade5 is clicked
circle.coinsPerClick *= 1.1;
// Update the cost text
costTxt.setText(self.cost.toString());
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize score text
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create a clickable circle and add it to the game
var circle = game.addChild(new ClickableCircle());
circle.x = 2048 / 2;
circle.y = 2732 / 2;
// Create an upgrade and add it to the game
var upgrade = game.addChild(new Upgrade());
upgrade.x = 2048 / 2 - 700;
upgrade.y = 2732 / 3;
// Create an upgrade2 and add it to the game
var upgrade2 = game.addChild(new Upgrade2());
upgrade2.x = upgrade.x + upgrade.width + 50;
upgrade2.y = upgrade.y;
// Update function called every game tick
// Create an upgrade3 and add it to the game
var upgrade3 = game.addChild(new Upgrade3());
upgrade3.x = upgrade2.x + upgrade2.width + 50;
upgrade3.y = upgrade2.y;
// Create an upgrade4 and add it to the game
var upgrade4 = game.addChild(new Upgrade4());
upgrade4.x = upgrade3.x + upgrade3.width + 50;
upgrade4.y = upgrade3.y;
// Create an upgrade5 and add it to the game
var upgrade5 = game.addChild(new Upgrade5());
upgrade5.x = upgrade4.x + upgrade4.width + 50;
upgrade5.y = upgrade4.y;
// Create an ascend and add it to the game
var ascend = game.addChild(new Ascend());
ascend.x = 2048 / 2;
ascend.y = upgrade5.y + upgrade5.height + 650;
game.update = function () {
ascend.updateMultiplierText();
};