/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var CentralObject = Container.expand(function () {
var self = Container.call(this);
var circleGraphics = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4
});
// Pulse animation for the central object
function pulse() {
tween(circleGraphics, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(circleGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}
self.down = function (x, y, obj) {
pulse();
createWave(self.x, self.y);
LK.getSound('pulse').play();
// Destroy the central object
self.destroy();
// Remove reference from the game to prevent errors
game.dragNode = null;
};
return self;
});
var RebirthButton = Container.expand(function () {
var self = Container.call(this);
// Create button background
var buttonBg = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0xFF0000
});
// Create button text
var buttonText = new Text2("REBIRTH", {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
// Create price text
var priceText = new Text2("1000", {
size: 40,
fill: 0xFFFFFF
});
priceText.anchor.set(0.5, 0.5);
priceText.y = 60;
self.addChild(priceText);
// Button press handler
self.down = function (x, y, obj) {
// Rebirth logic is handled in game code
performRebirth();
};
return self;
});
var UpgradeButton = Container.expand(function () {
var self = Container.call(this);
// Create button background
var buttonBg = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0x00AA00
});
// Create button text
var buttonText = new Text2("UPGRADE", {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
// Create price text
var priceText = new Text2("50", {
size: 40,
fill: 0xFFFFFF
});
priceText.anchor.set(0.5, 0.5);
priceText.y = 60;
self.addChild(priceText);
// Update the price text
self.updatePrice = function (price) {
priceText.setText(price.toString());
};
// Button press handler
self.down = function (x, y, obj) {
// Logic for handling purchase in the main game code
if (score >= upgradePrice) {
// Purchase logic is handled in game code
purchaseUpgrade();
}
};
return self;
});
var Wave = Container.expand(function () {
var self = Container.call(this);
var waveGraphics = self.attachAsset('wave', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8,
scaleX: 0.25,
scaleY: 0.25
});
self.fadeOut = function () {
tween(waveGraphics, {
alpha: 0,
scaleX: 12.5,
scaleY: 12.5
}, {
duration: 2500,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
var index = waves.indexOf(self);
if (index > -1) {
waves.splice(index, 1);
}
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game dimensions
var gameWidth = 2048;
var gameHeight = 2732;
// Set background color to black
game.setBackgroundColor(0x000000);
// Array to store all active waves
var waves = [];
// Score tracking
var score = 0;
// Upgrade variables
var clickValue = 1;
var upgradePrice = 50;
var upgradeMultiplier = 2;
// Rebirth variables
var rebirthCount = 0;
var rebirthMultiplier = 2;
// Central object removed as requested
var centralObject = null;
// Create score text
var scoreText = new Text2("0", {
size: 150,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create upgrade button
var upgradeBtn = new UpgradeButton();
upgradeBtn.x = gameWidth / 2;
upgradeBtn.y = gameHeight - 150;
game.addChild(upgradeBtn);
// Create rebirth button
var rebirthBtn = new RebirthButton();
rebirthBtn.x = gameWidth / 2 + 400;
rebirthBtn.y = gameHeight - 150;
game.addChild(rebirthBtn);
// Function to handle upgrade purchase
function purchaseUpgrade() {
// Check if player has enough score
if (score >= upgradePrice) {
// Deduct the price
score -= upgradePrice;
scoreText.setText(score.toString());
// Increase click value
clickValue++;
// Update price (2x the previous price)
upgradePrice = Math.floor(upgradePrice * upgradeMultiplier);
upgradeBtn.updatePrice(upgradePrice);
}
}
// Function to perform rebirth
function performRebirth() {
// Check if player has enough score
if (score >= 1000) {
// Reset score
score = 0;
scoreText.setText(score.toString());
// Increment rebirth counter
rebirthCount++;
// Reset upgrade price
upgradePrice = 50;
upgradeBtn.updatePrice(upgradePrice);
// Set new click value based on rebirth count
clickValue = rebirthCount * rebirthMultiplier + 1;
// Clear all waves
for (var i = waves.length - 1; i >= 0; i--) {
waves[i].destroy();
}
waves = [];
}
}
// Function to create a new wave
function createWave(x, y) {
var wave = new Wave();
wave.x = x;
wave.y = y;
wave.fadeOut();
waves.push(wave);
game.addChild(wave);
// Increment score by clickValue and update score display
score += clickValue;
scoreText.setText(score.toString());
}
// Track the object being dragged
game.dragNode = null;
// Handle tap anywhere on the screen
game.down = function (x, y, obj) {
// Create waves for all taps since central object is removed
createWave(x, y);
// Play pulse sound
LK.getSound('pulse').play();
};
// Handle move event for dragging
game.move = function (x, y, obj) {
if (game.dragNode) {
game.dragNode.x = x;
game.dragNode.y = y;
}
};
// Handle up event to stop dragging
game.up = function (x, y, obj) {
game.dragNode = null;
};
// Start background music
LK.playMusic('ambient', {
fade: {
start: 0,
end: 0.3,
duration: 1000
}
});
// Pulse timer removed since central object no longer exists
// Update function
game.update = function () {
// No need for additional updates as tweens handle the animations
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var CentralObject = Container.expand(function () {
var self = Container.call(this);
var circleGraphics = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4
});
// Pulse animation for the central object
function pulse() {
tween(circleGraphics, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(circleGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}
self.down = function (x, y, obj) {
pulse();
createWave(self.x, self.y);
LK.getSound('pulse').play();
// Destroy the central object
self.destroy();
// Remove reference from the game to prevent errors
game.dragNode = null;
};
return self;
});
var RebirthButton = Container.expand(function () {
var self = Container.call(this);
// Create button background
var buttonBg = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0xFF0000
});
// Create button text
var buttonText = new Text2("REBIRTH", {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
// Create price text
var priceText = new Text2("1000", {
size: 40,
fill: 0xFFFFFF
});
priceText.anchor.set(0.5, 0.5);
priceText.y = 60;
self.addChild(priceText);
// Button press handler
self.down = function (x, y, obj) {
// Rebirth logic is handled in game code
performRebirth();
};
return self;
});
var UpgradeButton = Container.expand(function () {
var self = Container.call(this);
// Create button background
var buttonBg = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0x00AA00
});
// Create button text
var buttonText = new Text2("UPGRADE", {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
// Create price text
var priceText = new Text2("50", {
size: 40,
fill: 0xFFFFFF
});
priceText.anchor.set(0.5, 0.5);
priceText.y = 60;
self.addChild(priceText);
// Update the price text
self.updatePrice = function (price) {
priceText.setText(price.toString());
};
// Button press handler
self.down = function (x, y, obj) {
// Logic for handling purchase in the main game code
if (score >= upgradePrice) {
// Purchase logic is handled in game code
purchaseUpgrade();
}
};
return self;
});
var Wave = Container.expand(function () {
var self = Container.call(this);
var waveGraphics = self.attachAsset('wave', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8,
scaleX: 0.25,
scaleY: 0.25
});
self.fadeOut = function () {
tween(waveGraphics, {
alpha: 0,
scaleX: 12.5,
scaleY: 12.5
}, {
duration: 2500,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
var index = waves.indexOf(self);
if (index > -1) {
waves.splice(index, 1);
}
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game dimensions
var gameWidth = 2048;
var gameHeight = 2732;
// Set background color to black
game.setBackgroundColor(0x000000);
// Array to store all active waves
var waves = [];
// Score tracking
var score = 0;
// Upgrade variables
var clickValue = 1;
var upgradePrice = 50;
var upgradeMultiplier = 2;
// Rebirth variables
var rebirthCount = 0;
var rebirthMultiplier = 2;
// Central object removed as requested
var centralObject = null;
// Create score text
var scoreText = new Text2("0", {
size: 150,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create upgrade button
var upgradeBtn = new UpgradeButton();
upgradeBtn.x = gameWidth / 2;
upgradeBtn.y = gameHeight - 150;
game.addChild(upgradeBtn);
// Create rebirth button
var rebirthBtn = new RebirthButton();
rebirthBtn.x = gameWidth / 2 + 400;
rebirthBtn.y = gameHeight - 150;
game.addChild(rebirthBtn);
// Function to handle upgrade purchase
function purchaseUpgrade() {
// Check if player has enough score
if (score >= upgradePrice) {
// Deduct the price
score -= upgradePrice;
scoreText.setText(score.toString());
// Increase click value
clickValue++;
// Update price (2x the previous price)
upgradePrice = Math.floor(upgradePrice * upgradeMultiplier);
upgradeBtn.updatePrice(upgradePrice);
}
}
// Function to perform rebirth
function performRebirth() {
// Check if player has enough score
if (score >= 1000) {
// Reset score
score = 0;
scoreText.setText(score.toString());
// Increment rebirth counter
rebirthCount++;
// Reset upgrade price
upgradePrice = 50;
upgradeBtn.updatePrice(upgradePrice);
// Set new click value based on rebirth count
clickValue = rebirthCount * rebirthMultiplier + 1;
// Clear all waves
for (var i = waves.length - 1; i >= 0; i--) {
waves[i].destroy();
}
waves = [];
}
}
// Function to create a new wave
function createWave(x, y) {
var wave = new Wave();
wave.x = x;
wave.y = y;
wave.fadeOut();
waves.push(wave);
game.addChild(wave);
// Increment score by clickValue and update score display
score += clickValue;
scoreText.setText(score.toString());
}
// Track the object being dragged
game.dragNode = null;
// Handle tap anywhere on the screen
game.down = function (x, y, obj) {
// Create waves for all taps since central object is removed
createWave(x, y);
// Play pulse sound
LK.getSound('pulse').play();
};
// Handle move event for dragging
game.move = function (x, y, obj) {
if (game.dragNode) {
game.dragNode.x = x;
game.dragNode.y = y;
}
};
// Handle up event to stop dragging
game.up = function (x, y, obj) {
game.dragNode = null;
};
// Start background music
LK.playMusic('ambient', {
fade: {
start: 0,
end: 0.3,
duration: 1000
}
});
// Pulse timer removed since central object no longer exists
// Update function
game.update = function () {
// No need for additional updates as tweens handle the animations
};