/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Cube = Container.expand(function () {
var self = Container.call(this);
var cubeGraphics = self.attachAsset('cube', {
anchorX: 0.5,
anchorY: 0.5
});
// Randomize cube color
var colors = [0x4CAF50, 0xF44336, 0x2196F3, 0xFF9800, 0x9C27B0, 0xFFEB3B];
cubeGraphics.tint = colors[Math.floor(Math.random() * colors.length)];
// Random velocity
self.vx = (Math.random() - 0.5) * 4;
self.vy = (Math.random() - 0.5) * 4;
// Multiplication timer
self.multiplyTimer = 0;
self.multiplyDelay = Math.floor(Math.random() * 120) + 60; // 1-3 seconds at 60fps
self.update = function () {
// Move cube
self.x += self.vx;
self.y += self.vy;
// Bounce off edges
if (self.x <= 15 || self.x >= 2048 - 15) {
self.vx *= -1;
}
if (self.y <= 15 || self.y >= 2732 - 15) {
self.vy *= -1;
}
// Keep in bounds
self.x = Math.max(15, Math.min(2048 - 15, self.x));
self.y = Math.max(15, Math.min(2732 - 15, self.y));
// Multiplication logic
self.multiplyTimer++;
if (self.multiplyTimer >= self.multiplyDelay && cubes.length < maxCubes) {
self.multiply();
self.multiplyTimer = 0;
self.multiplyDelay = Math.max(30, self.multiplyDelay - multiplicationRate);
}
};
self.multiply = function () {
if (cubes.length >= maxCubes) return;
var newCube = new Cube();
newCube.x = self.x + (Math.random() - 0.5) * 100;
newCube.y = self.y + (Math.random() - 0.5) * 100;
// Keep new cube in bounds
newCube.x = Math.max(15, Math.min(2048 - 15, newCube.x));
newCube.y = Math.max(15, Math.min(2732 - 15, newCube.y));
cubes.push(newCube);
game.addChild(newCube);
// Increase multiplication rate
multiplicationRate += 0.1;
cubeCount++;
updateCounterText();
};
return self;
});
var FPEShop = Container.expand(function () {
var self = Container.call(this);
self.visible = false;
// Shop panel background
var panel = self.attachAsset('fpePanel', {
anchorX: 0.5,
anchorY: 0.5
});
// Shop title
var titleText = new Text2('FPS BOOST SHOP', {
size: 56,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -630;
self.addChild(titleText);
// Cubes display
var cubesText = new Text2('Cubes: 0', {
size: 42,
fill: 0xFFEB3B
});
cubesText.anchor.set(0.5, 0.5);
cubesText.x = 0;
cubesText.y = -540;
self.addChild(cubesText);
// FPS boost items
var items = [{
name: 'FPS 90',
price: 19,
fps: 90,
description: 'Boost to 90 FPS'
}, {
name: 'FPS 120',
price: 50,
fps: 120,
description: 'Boost to 120 FPS'
}, {
name: 'FPS 144',
price: 100,
fps: 144,
description: 'Boost to 144 FPS'
}];
var itemButtons = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
var yPos = -350 + i * 250;
// Item button
var itemButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
itemButton.x = 0;
itemButton.y = yPos;
itemButton.itemIndex = i;
// Item name
var nameText = new Text2(item.name, {
size: 32,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 0;
nameText.y = yPos - 40;
self.addChild(nameText);
// Item description
var descText = new Text2(item.description, {
size: 24,
fill: 0xCCCCCC
});
descText.anchor.set(0.5, 0.5);
descText.x = 0;
descText.y = yPos;
self.addChild(descText);
// Item price
var priceText = new Text2('Price: ' + item.price + ' cubes', {
size: 28,
fill: 0xFFEB3B
});
priceText.anchor.set(0.5, 0.5);
priceText.x = 0;
priceText.y = yPos + 40;
self.addChild(priceText);
itemButtons.push({
button: itemButton,
price: priceText
});
}
// Close button
var closeButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
closeButton.x = 0;
closeButton.y = 630;
closeButton.tint = 0xFF4444;
var closeText = new Text2('CLOSE', {
size: 36,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 0;
closeText.y = 630;
self.addChild(closeText);
self.updateCubesDisplay = function () {
cubesText.setText('Cubes: ' + (storage.cubes || 0));
};
self.down = function (x, y, obj) {
if (!obj || !obj.position) return;
var localPos = self.toLocal(obj.position);
// Check close button
if (Math.abs(localPos.x - closeButton.x) < 90 && Math.abs(localPos.y - 630) < 25) {
self.hide();
return;
}
// Check item buttons
for (var i = 0; i < itemButtons.length; i++) {
var itemBtn = itemButtons[i].button;
if (Math.abs(localPos.x - itemBtn.x) < 90 && Math.abs(localPos.y - itemBtn.y) < 25) {
self.buyItem(i);
break;
}
}
};
self.buyItem = function (index) {
var item = items[index];
var cubes = storage.cubes || 0;
if (cubes >= item.price) {
storage.cubes = cubes - item.price;
storage.targetFPS = item.fps;
self.updateCubesDisplay();
}
};
self.show = function () {
self.visible = true;
self.updateCubesDisplay();
};
self.hide = function () {
self.visible = false;
};
return self;
});
var Shop = Container.expand(function () {
var self = Container.call(this);
self.visible = false;
// Shop panel background
var panel = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5
});
// Shop title
var titleText = new Text2('AUTO CLICKER SHOP', {
size: 56,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -630;
self.addChild(titleText);
// Cubes display
var coinsText = new Text2('Cubes: 0', {
size: 42,
fill: 0xFFEB3B
});
coinsText.anchor.set(0.5, 0.5);
coinsText.x = 0;
coinsText.y = -540;
self.addChild(coinsText);
// Auto clicker items
var items = [{
name: 'Auto Poor',
price: 10,
multiplier: 1,
description: '1 Auto Clicker'
}, {
name: 'Medium Auto',
price: 50,
multiplier: 2,
description: '2x Auto Clickers'
}, {
name: '100 Auto',
price: 500,
multiplier: 999,
description: '999 Auto Clickers'
}];
var itemButtons = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
var yPos = -350 + i * 250;
// Item button
var itemButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
itemButton.x = 0;
itemButton.y = yPos;
itemButton.itemIndex = i;
// Item name
var nameText = new Text2(item.name, {
size: 32,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 0;
nameText.y = yPos - 40;
self.addChild(nameText);
// Item description
var descText = new Text2(item.description, {
size: 24,
fill: 0xCCCCCC
});
descText.anchor.set(0.5, 0.5);
descText.x = 0;
descText.y = yPos;
self.addChild(descText);
// Item price
var priceText = new Text2('Price: ' + item.price + ' cubes', {
size: 28,
fill: 0xFFEB3B
});
priceText.anchor.set(0.5, 0.5);
priceText.x = 0;
priceText.y = yPos + 40;
self.addChild(priceText);
itemButtons.push({
button: itemButton,
price: priceText
});
}
// Close button
var closeButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
closeButton.x = 0;
closeButton.y = 630;
closeButton.tint = 0xFF4444;
var closeText = new Text2('CLOSE', {
size: 36,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 0;
closeText.y = 630;
self.addChild(closeText);
self.updateCoinsDisplay = function () {
coinsText.setText('Cubes: ' + (storage.cubes || 0));
};
self.down = function (x, y, obj) {
if (!obj || !obj.position) return;
var localPos = self.toLocal(obj.position);
// Check close button
if (Math.abs(localPos.x - closeButton.x) < 90 && Math.abs(localPos.y - 630) < 25) {
self.hide();
return;
}
// Check item buttons
for (var i = 0; i < itemButtons.length; i++) {
var itemBtn = itemButtons[i].button;
if (Math.abs(localPos.x - itemBtn.x) < 90 && Math.abs(localPos.y - itemBtn.y) < 25) {
self.buyItem(i);
break;
}
}
};
self.buyItem = function (index) {
var item = items[index];
var cubes = storage.cubes || 0;
if (cubes >= item.price) {
storage.cubes = cubes - item.price;
storage.autoClickers = (storage.autoClickers || 0) + item.multiplier;
self.updateCoinsDisplay();
}
};
self.show = function () {
self.visible = true;
self.updateCoinsDisplay();
};
self.hide = function () {
self.visible = false;
};
return self;
});
var SpawnButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('spawnButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
spawnCube();
// Button press animation
tween(buttonGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
tween(buttonGraphics, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
var cubes = [];
var cubeCount = 0;
var multiplicationRate = 1;
var maxCubes = 2000;
var lastFPSTime = 0;
var frameCount = 0;
var currentFPS = 60;
var autoClickTimer = 0;
// Create spawn button
var spawnButton = game.addChild(new SpawnButton());
spawnButton.x = 1024;
spawnButton.y = 2600;
// Create shop button
var shopButtonContainer = game.addChild(new Container());
var shopButtonGraphics = shopButtonContainer.attachAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopButtonContainer.x = 1800;
shopButtonContainer.y = 2600;
var shopButtonText = new Text2('SHOP', {
size: 36,
fill: 0xFFFFFF
});
shopButtonText.anchor.set(0.5, 0.5);
shopButtonText.x = 1800;
shopButtonText.y = 2600;
game.addChild(shopButtonText);
// Create shop
var shop = game.addChild(new Shop());
shop.x = 1024;
shop.y = 1366;
shopButtonContainer.down = function (x, y, obj) {
shop.show();
};
// Create FPE shop button
var fpeButtonContainer = game.addChild(new Container());
var fpeButtonGraphics = fpeButtonContainer.attachAsset('fpeButton', {
anchorX: 0.5,
anchorY: 0.5
});
fpeButtonContainer.x = 300;
fpeButtonContainer.y = 2600;
var fpeButtonText = new Text2('FPE', {
size: 36,
fill: 0xFFFFFF
});
fpeButtonText.anchor.set(0.5, 0.5);
fpeButtonText.x = 300;
fpeButtonText.y = 2600;
game.addChild(fpeButtonText);
// Create FPE shop
var fpeShop = game.addChild(new FPEShop());
fpeShop.x = 1024;
fpeShop.y = 1366;
fpeButtonContainer.down = function (x, y, obj) {
fpeShop.show();
};
// Create button label
var buttonText = new Text2('SPAWN CUBE', {
size: 32,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
buttonText.x = 1024;
buttonText.y = 2600;
game.addChild(buttonText);
// Create cube counter
var counterText = new Text2('Cubes: 0', {
size: 48,
fill: 0xFFFFFF
});
counterText.anchor.set(0.5, 0);
counterText.x = 1024;
counterText.y = 100;
game.addChild(counterText);
// Create FPS counter
var fpsText = new Text2('FPS: 60', {
size: 72,
fill: 0xFFFF00
});
fpsText.anchor.set(0, 1);
fpsText.x = 20;
fpsText.y = 2712;
game.addChild(fpsText);
function spawnCube() {
if (cubes.length >= maxCubes) return;
var newCube = new Cube();
newCube.x = Math.random() * (2048 - 30) + 15;
newCube.y = Math.random() * (2732 - 30) + 15;
cubes.push(newCube);
game.addChild(newCube);
cubeCount++;
updateCounterText();
// Award cube for spawning cube
storage.cubes = (storage.cubes || 0) + 1;
}
function updateCounterText() {
counterText.setText('Cubes: ' + cubeCount);
}
function updateFPS() {
frameCount++;
var currentTime = Date.now();
if (currentTime - lastFPSTime >= 1000) {
currentFPS = Math.round(frameCount * 1000 / (currentTime - lastFPSTime));
fpsText.setText('FPS: ' + currentFPS);
frameCount = 0;
lastFPSTime = currentTime;
}
}
game.update = function () {
updateFPS();
// FPS control based on purchased FPS boost
var targetFPS = storage.targetFPS || 60;
if (targetFPS > 60) {
// Skip frames to achieve higher FPS effect
var skipFrames = Math.floor(targetFPS / 60) - 1;
if (LK.ticks % (skipFrames + 1) !== 0) {
return;
}
}
// Auto-clicker functionality
var autoClickers = storage.autoClickers || 0;
if (autoClickers > 0) {
autoClickTimer++;
if (autoClickTimer >= 60) {
// Auto-click every second
for (var a = 0; a < autoClickers && a < 10; a++) {
// Limit to 10 per frame for performance
spawnCube();
}
autoClickTimer = 0;
}
}
// Clean up destroyed cubes
for (var i = cubes.length - 1; i >= 0; i--) {
if (!cubes[i].parent) {
cubes.splice(i, 1);
cubeCount--;
updateCounterText();
}
}
// Performance management - slow down multiplication if FPS drops too low
if (currentFPS < 30 && cubes.length > 100) {
// Remove some cubes to maintain performance
for (var j = 0; j < 10 && cubes.length > 100; j++) {
var cubeToRemove = cubes.pop();
cubeToRemove.destroy();
cubeCount--;
}
updateCounterText();
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Cube = Container.expand(function () {
var self = Container.call(this);
var cubeGraphics = self.attachAsset('cube', {
anchorX: 0.5,
anchorY: 0.5
});
// Randomize cube color
var colors = [0x4CAF50, 0xF44336, 0x2196F3, 0xFF9800, 0x9C27B0, 0xFFEB3B];
cubeGraphics.tint = colors[Math.floor(Math.random() * colors.length)];
// Random velocity
self.vx = (Math.random() - 0.5) * 4;
self.vy = (Math.random() - 0.5) * 4;
// Multiplication timer
self.multiplyTimer = 0;
self.multiplyDelay = Math.floor(Math.random() * 120) + 60; // 1-3 seconds at 60fps
self.update = function () {
// Move cube
self.x += self.vx;
self.y += self.vy;
// Bounce off edges
if (self.x <= 15 || self.x >= 2048 - 15) {
self.vx *= -1;
}
if (self.y <= 15 || self.y >= 2732 - 15) {
self.vy *= -1;
}
// Keep in bounds
self.x = Math.max(15, Math.min(2048 - 15, self.x));
self.y = Math.max(15, Math.min(2732 - 15, self.y));
// Multiplication logic
self.multiplyTimer++;
if (self.multiplyTimer >= self.multiplyDelay && cubes.length < maxCubes) {
self.multiply();
self.multiplyTimer = 0;
self.multiplyDelay = Math.max(30, self.multiplyDelay - multiplicationRate);
}
};
self.multiply = function () {
if (cubes.length >= maxCubes) return;
var newCube = new Cube();
newCube.x = self.x + (Math.random() - 0.5) * 100;
newCube.y = self.y + (Math.random() - 0.5) * 100;
// Keep new cube in bounds
newCube.x = Math.max(15, Math.min(2048 - 15, newCube.x));
newCube.y = Math.max(15, Math.min(2732 - 15, newCube.y));
cubes.push(newCube);
game.addChild(newCube);
// Increase multiplication rate
multiplicationRate += 0.1;
cubeCount++;
updateCounterText();
};
return self;
});
var FPEShop = Container.expand(function () {
var self = Container.call(this);
self.visible = false;
// Shop panel background
var panel = self.attachAsset('fpePanel', {
anchorX: 0.5,
anchorY: 0.5
});
// Shop title
var titleText = new Text2('FPS BOOST SHOP', {
size: 56,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -630;
self.addChild(titleText);
// Cubes display
var cubesText = new Text2('Cubes: 0', {
size: 42,
fill: 0xFFEB3B
});
cubesText.anchor.set(0.5, 0.5);
cubesText.x = 0;
cubesText.y = -540;
self.addChild(cubesText);
// FPS boost items
var items = [{
name: 'FPS 90',
price: 19,
fps: 90,
description: 'Boost to 90 FPS'
}, {
name: 'FPS 120',
price: 50,
fps: 120,
description: 'Boost to 120 FPS'
}, {
name: 'FPS 144',
price: 100,
fps: 144,
description: 'Boost to 144 FPS'
}];
var itemButtons = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
var yPos = -350 + i * 250;
// Item button
var itemButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
itemButton.x = 0;
itemButton.y = yPos;
itemButton.itemIndex = i;
// Item name
var nameText = new Text2(item.name, {
size: 32,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 0;
nameText.y = yPos - 40;
self.addChild(nameText);
// Item description
var descText = new Text2(item.description, {
size: 24,
fill: 0xCCCCCC
});
descText.anchor.set(0.5, 0.5);
descText.x = 0;
descText.y = yPos;
self.addChild(descText);
// Item price
var priceText = new Text2('Price: ' + item.price + ' cubes', {
size: 28,
fill: 0xFFEB3B
});
priceText.anchor.set(0.5, 0.5);
priceText.x = 0;
priceText.y = yPos + 40;
self.addChild(priceText);
itemButtons.push({
button: itemButton,
price: priceText
});
}
// Close button
var closeButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
closeButton.x = 0;
closeButton.y = 630;
closeButton.tint = 0xFF4444;
var closeText = new Text2('CLOSE', {
size: 36,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 0;
closeText.y = 630;
self.addChild(closeText);
self.updateCubesDisplay = function () {
cubesText.setText('Cubes: ' + (storage.cubes || 0));
};
self.down = function (x, y, obj) {
if (!obj || !obj.position) return;
var localPos = self.toLocal(obj.position);
// Check close button
if (Math.abs(localPos.x - closeButton.x) < 90 && Math.abs(localPos.y - 630) < 25) {
self.hide();
return;
}
// Check item buttons
for (var i = 0; i < itemButtons.length; i++) {
var itemBtn = itemButtons[i].button;
if (Math.abs(localPos.x - itemBtn.x) < 90 && Math.abs(localPos.y - itemBtn.y) < 25) {
self.buyItem(i);
break;
}
}
};
self.buyItem = function (index) {
var item = items[index];
var cubes = storage.cubes || 0;
if (cubes >= item.price) {
storage.cubes = cubes - item.price;
storage.targetFPS = item.fps;
self.updateCubesDisplay();
}
};
self.show = function () {
self.visible = true;
self.updateCubesDisplay();
};
self.hide = function () {
self.visible = false;
};
return self;
});
var Shop = Container.expand(function () {
var self = Container.call(this);
self.visible = false;
// Shop panel background
var panel = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5
});
// Shop title
var titleText = new Text2('AUTO CLICKER SHOP', {
size: 56,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -630;
self.addChild(titleText);
// Cubes display
var coinsText = new Text2('Cubes: 0', {
size: 42,
fill: 0xFFEB3B
});
coinsText.anchor.set(0.5, 0.5);
coinsText.x = 0;
coinsText.y = -540;
self.addChild(coinsText);
// Auto clicker items
var items = [{
name: 'Auto Poor',
price: 10,
multiplier: 1,
description: '1 Auto Clicker'
}, {
name: 'Medium Auto',
price: 50,
multiplier: 2,
description: '2x Auto Clickers'
}, {
name: '100 Auto',
price: 500,
multiplier: 999,
description: '999 Auto Clickers'
}];
var itemButtons = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
var yPos = -350 + i * 250;
// Item button
var itemButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
itemButton.x = 0;
itemButton.y = yPos;
itemButton.itemIndex = i;
// Item name
var nameText = new Text2(item.name, {
size: 32,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 0;
nameText.y = yPos - 40;
self.addChild(nameText);
// Item description
var descText = new Text2(item.description, {
size: 24,
fill: 0xCCCCCC
});
descText.anchor.set(0.5, 0.5);
descText.x = 0;
descText.y = yPos;
self.addChild(descText);
// Item price
var priceText = new Text2('Price: ' + item.price + ' cubes', {
size: 28,
fill: 0xFFEB3B
});
priceText.anchor.set(0.5, 0.5);
priceText.x = 0;
priceText.y = yPos + 40;
self.addChild(priceText);
itemButtons.push({
button: itemButton,
price: priceText
});
}
// Close button
var closeButton = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
closeButton.x = 0;
closeButton.y = 630;
closeButton.tint = 0xFF4444;
var closeText = new Text2('CLOSE', {
size: 36,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 0;
closeText.y = 630;
self.addChild(closeText);
self.updateCoinsDisplay = function () {
coinsText.setText('Cubes: ' + (storage.cubes || 0));
};
self.down = function (x, y, obj) {
if (!obj || !obj.position) return;
var localPos = self.toLocal(obj.position);
// Check close button
if (Math.abs(localPos.x - closeButton.x) < 90 && Math.abs(localPos.y - 630) < 25) {
self.hide();
return;
}
// Check item buttons
for (var i = 0; i < itemButtons.length; i++) {
var itemBtn = itemButtons[i].button;
if (Math.abs(localPos.x - itemBtn.x) < 90 && Math.abs(localPos.y - itemBtn.y) < 25) {
self.buyItem(i);
break;
}
}
};
self.buyItem = function (index) {
var item = items[index];
var cubes = storage.cubes || 0;
if (cubes >= item.price) {
storage.cubes = cubes - item.price;
storage.autoClickers = (storage.autoClickers || 0) + item.multiplier;
self.updateCoinsDisplay();
}
};
self.show = function () {
self.visible = true;
self.updateCoinsDisplay();
};
self.hide = function () {
self.visible = false;
};
return self;
});
var SpawnButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('spawnButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
spawnCube();
// Button press animation
tween(buttonGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
tween(buttonGraphics, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
var cubes = [];
var cubeCount = 0;
var multiplicationRate = 1;
var maxCubes = 2000;
var lastFPSTime = 0;
var frameCount = 0;
var currentFPS = 60;
var autoClickTimer = 0;
// Create spawn button
var spawnButton = game.addChild(new SpawnButton());
spawnButton.x = 1024;
spawnButton.y = 2600;
// Create shop button
var shopButtonContainer = game.addChild(new Container());
var shopButtonGraphics = shopButtonContainer.attachAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopButtonContainer.x = 1800;
shopButtonContainer.y = 2600;
var shopButtonText = new Text2('SHOP', {
size: 36,
fill: 0xFFFFFF
});
shopButtonText.anchor.set(0.5, 0.5);
shopButtonText.x = 1800;
shopButtonText.y = 2600;
game.addChild(shopButtonText);
// Create shop
var shop = game.addChild(new Shop());
shop.x = 1024;
shop.y = 1366;
shopButtonContainer.down = function (x, y, obj) {
shop.show();
};
// Create FPE shop button
var fpeButtonContainer = game.addChild(new Container());
var fpeButtonGraphics = fpeButtonContainer.attachAsset('fpeButton', {
anchorX: 0.5,
anchorY: 0.5
});
fpeButtonContainer.x = 300;
fpeButtonContainer.y = 2600;
var fpeButtonText = new Text2('FPE', {
size: 36,
fill: 0xFFFFFF
});
fpeButtonText.anchor.set(0.5, 0.5);
fpeButtonText.x = 300;
fpeButtonText.y = 2600;
game.addChild(fpeButtonText);
// Create FPE shop
var fpeShop = game.addChild(new FPEShop());
fpeShop.x = 1024;
fpeShop.y = 1366;
fpeButtonContainer.down = function (x, y, obj) {
fpeShop.show();
};
// Create button label
var buttonText = new Text2('SPAWN CUBE', {
size: 32,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
buttonText.x = 1024;
buttonText.y = 2600;
game.addChild(buttonText);
// Create cube counter
var counterText = new Text2('Cubes: 0', {
size: 48,
fill: 0xFFFFFF
});
counterText.anchor.set(0.5, 0);
counterText.x = 1024;
counterText.y = 100;
game.addChild(counterText);
// Create FPS counter
var fpsText = new Text2('FPS: 60', {
size: 72,
fill: 0xFFFF00
});
fpsText.anchor.set(0, 1);
fpsText.x = 20;
fpsText.y = 2712;
game.addChild(fpsText);
function spawnCube() {
if (cubes.length >= maxCubes) return;
var newCube = new Cube();
newCube.x = Math.random() * (2048 - 30) + 15;
newCube.y = Math.random() * (2732 - 30) + 15;
cubes.push(newCube);
game.addChild(newCube);
cubeCount++;
updateCounterText();
// Award cube for spawning cube
storage.cubes = (storage.cubes || 0) + 1;
}
function updateCounterText() {
counterText.setText('Cubes: ' + cubeCount);
}
function updateFPS() {
frameCount++;
var currentTime = Date.now();
if (currentTime - lastFPSTime >= 1000) {
currentFPS = Math.round(frameCount * 1000 / (currentTime - lastFPSTime));
fpsText.setText('FPS: ' + currentFPS);
frameCount = 0;
lastFPSTime = currentTime;
}
}
game.update = function () {
updateFPS();
// FPS control based on purchased FPS boost
var targetFPS = storage.targetFPS || 60;
if (targetFPS > 60) {
// Skip frames to achieve higher FPS effect
var skipFrames = Math.floor(targetFPS / 60) - 1;
if (LK.ticks % (skipFrames + 1) !== 0) {
return;
}
}
// Auto-clicker functionality
var autoClickers = storage.autoClickers || 0;
if (autoClickers > 0) {
autoClickTimer++;
if (autoClickTimer >= 60) {
// Auto-click every second
for (var a = 0; a < autoClickers && a < 10; a++) {
// Limit to 10 per frame for performance
spawnCube();
}
autoClickTimer = 0;
}
}
// Clean up destroyed cubes
for (var i = cubes.length - 1; i >= 0; i--) {
if (!cubes[i].parent) {
cubes.splice(i, 1);
cubeCount--;
updateCounterText();
}
}
// Performance management - slow down multiplication if FPS drops too low
if (currentFPS < 30 && cubes.length > 100) {
// Remove some cubes to maintain performance
for (var j = 0; j < 10 && cubes.length > 100; j++) {
var cubeToRemove = cubes.pop();
cubeToRemove.destroy();
cubeCount--;
}
updateCounterText();
}
};