/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// FallingPeanut class to represent peanuts that continuously fall
var FallingPeanut = Container.expand(function () {
var self = Container.call(this);
var peanutGraphics = self.attachAsset('Peanut1', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial speed for falling peanuts
self.speed = 3;
// Event handler for when a falling peanut is clicked
self.down = function (x, y, obj) {
// Add special effects when clicking
// Scale up effect
tween(peanutGraphics, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
// Scale back to normal
tween(peanutGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 150,
easing: tween.easeInOut
});
}
});
// Rotation effect
tween(peanutGraphics, {
rotation: peanutGraphics.rotation + Math.PI * 0.25
}, {
duration: 200,
easing: tween.easeInOut
});
// Flash effect with tint
tween(peanutGraphics, {
tint: 0xFFFF00
}, {
duration: 100,
easing: tween.linear,
onFinish: function onFinish() {
tween(peanutGraphics, {
tint: 0xFFFFFF
}, {
duration: 100,
easing: tween.linear
});
}
});
// Give 2x more score than regular click (2x click power * level)
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
LK.setScore(LK.getScore() + clickPower * currentLevel * 2);
scoreTxt.setText(LK.getScore());
// Level up logic
if (LK.getScore() % 100 === 0) {
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
levelTxt.setText('Level: ' + currentLevel);
}
};
// Update function to move peanuts downwards
self.update = function () {
self.y += self.speed;
self.x += self.horizontalSpeed; // Move horizontally
if (self.y > 2732) {
// Reset position to top if it goes off screen
self.y = -self.height;
}
};
});
//<Assets used in the game will automatically appear here>
// Peanut class to represent each peanut on the screen
var Peanut = Container.expand(function () {
var self = Container.call(this);
var peanutGraphics = self.attachAsset('Peanut1', {
anchorX: 0.5,
anchorY: 0.5
});
// Event handler for when a peanut is tapped
self.down = function (x, y, obj) {
// Add special effects when clicking
// Scale up effect
tween(peanutGraphics, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
// Scale back to normal
tween(peanutGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 150,
easing: tween.easeInOut
});
}
});
// Rotation effect
tween(peanutGraphics, {
rotation: peanutGraphics.rotation + Math.PI * 0.25
}, {
duration: 200,
easing: tween.easeInOut
});
// Flash effect with tint
tween(peanutGraphics, {
tint: 0xFFFF00
}, {
duration: 100,
easing: tween.linear,
onFinish: function onFinish() {
tween(peanutGraphics, {
tint: 0xFFFFFF
}, {
duration: 100,
easing: tween.linear
});
}
});
// Increase score with level multiplier and click power
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
LK.setScore(LK.getScore() + clickPower * currentLevel);
scoreTxt.setText(LK.getScore());
// Level up logic
if (LK.getScore() % 100 === 0) {
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
levelTxt.setText('Level: ' + currentLevel);
}
// Do not destroy the peanut to prevent disappearance
};
});
// Shop class to handle shop interface and upgrades
var Shop = Container.expand(function () {
var self = Container.call(this);
// Shop background
var shopBg = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 12,
tint: 0x333333
});
// Shop title
var shopTitle = new Text2('SHOP', {
size: 80,
fill: 0xFFFFFF
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 0;
shopTitle.y = -400;
self.addChild(shopTitle);
// Upgrade 1: Click Power (+1 per click)
var upgrade1Btn = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0x4CAF50
});
upgrade1Btn.x = 0;
upgrade1Btn.y = -200;
var upgrade1Text = new Text2('Click Power +1\nLevel: 0/100\nCost: 500', {
size: 40,
fill: 0xFFFFFF
});
upgrade1Text.anchor.set(0.5, 0.5);
upgrade1Text.x = 0;
upgrade1Text.y = -200;
self.addChild(upgrade1Text);
// Upgrade 2: Auto Clicker
var upgrade2Btn = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0x2196F3
});
upgrade2Btn.x = 0;
upgrade2Btn.y = 0;
var upgrade2Text = new Text2('Auto Clicker\nLevel: 0/100\nCost: 1000', {
size: 40,
fill: 0xFFFFFF
});
upgrade2Text.anchor.set(0.5, 0.5);
upgrade2Text.x = 0;
upgrade2Text.y = 0;
self.addChild(upgrade2Text);
// Close button
var closeBtn = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1,
tint: 0xFF5722
});
closeBtn.x = 0;
closeBtn.y = 300;
var closeText = new Text2('CLOSE', {
size: 50,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 0;
closeText.y = 300;
self.addChild(closeText);
// Event handlers
upgrade1Btn.down = function () {
if (LK.getScore() >= 500 && clickPowerLevel < 100) {
LK.setScore(LK.getScore() - 500);
clickPower += 1;
clickPowerLevel += 1;
scoreTxt.setText(LK.getScore());
// Update button text
upgrade1Text.setText('Click Power +1\nLevel: ' + clickPowerLevel + '/100\nCost: 500');
// Change color to gray if maxed out
if (clickPowerLevel >= 100) {
upgrade1Btn.tint = 0x666666;
}
}
};
upgrade2Btn.down = function () {
if (LK.getScore() >= 1000 && autoClickerLevel < 100) {
LK.setScore(LK.getScore() - 1000);
autoClickerActive = true;
autoClickerLevel += 1;
scoreTxt.setText(LK.getScore());
// Update button text
upgrade2Text.setText('Auto Clicker\nLevel: ' + autoClickerLevel + '/100\nCost: 1000');
// Change color to gray if maxed out
if (autoClickerLevel >= 100) {
upgrade2Btn.tint = 0x666666;
}
}
};
closeBtn.down = function () {
shopVisible = false;
self.visible = false;
};
// Method to update shop display
self.updateDisplay = function () {
// Update click power display
upgrade1Text.setText('Click Power +1\nLevel: ' + clickPowerLevel + '/100\nCost: 500');
if (clickPowerLevel >= 100) {
upgrade1Btn.tint = 0x666666;
} else {
upgrade1Btn.tint = 0x4CAF50;
}
// Update auto clicker display
upgrade2Text.setText('Auto Clicker\nLevel: ' + autoClickerLevel + '/100\nCost: 1000');
if (autoClickerLevel >= 100) {
upgrade2Btn.tint = 0x666666;
} else {
upgrade2Btn.tint = 0x2196F3;
}
};
return self;
});
// ShopButton class for the shop access button
var ShopButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1,
tint: 0xFFD700
});
var buttonText = new Text2('SHOP', {
size: 40,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function () {
if (currentPlayerLevel >= 3) {
shopVisible = true;
shopInterface.visible = true;
shopInterface.updateDisplay(); // Update display when opening shop
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize score display
var scoreTxt = new Text2('000000', {
size: 150,
fill: 0xFFFFFF
});
// Initialize level display
var levelTxt = new Text2('Level: 1', {
size: 50,
fill: 0xFFFFFF
});
levelTxt.anchor.set(1, 1);
LK.gui.bottomRight.addChild(levelTxt);
// Initialize shop system
shopInterface = new Shop();
shopInterface.x = 400;
shopInterface.y = 2332;
shopInterface.visible = false;
game.addChild(shopInterface);
// Initialize shop button
shopButton = new ShopButton();
shopButton.x = 200;
shopButton.y = 2632;
shopButton.visible = false;
game.addChild(shopButton);
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Array to keep track of peanuts
var peanuts = [];
// Shop system variables
var shopVisible = false;
var clickPower = 1;
var autoClickerActive = false;
var currentPlayerLevel = 1;
var shopInterface;
var shopButton;
var clickPowerLevel = 0; // Track click power upgrade level (max 100)
var autoClickerLevel = 0; // Track auto clicker upgrade level (max 100)
// Function to spawn a new falling peanut
function spawnFallingPeanut() {
var newPeanut = new FallingPeanut();
newPeanut.horizontalSpeed = (Math.random() - 0.5) * 2; // Random horizontal speed between -1 and 1
do {
newPeanut.x = Math.random() * 2048; // Random x position
} while (Math.abs(newPeanut.x - 2048 / 2) < 150); // Ensure no overlap with peanut1
newPeanut.y = -newPeanut.height; // Start above the screen
peanuts.push(newPeanut);
game.addChild(newPeanut);
}
// Set interval to spawn falling peanuts every 3 seconds
var peanutSpawnInterval = LK.setInterval(spawnFallingPeanut, 3000);
// Update function called every tick
game.update = function () {
// Update all falling peanuts
for (var i = 0; i < peanuts.length; i++) {
peanuts[i].update();
}
// Update current player level
currentPlayerLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
// Show shop button when player reaches level 3
if (currentPlayerLevel >= 3 && !shopButton.visible) {
shopButton.visible = true;
}
// Auto clicker functionality
if (autoClickerActive && LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + clickPower * currentPlayerLevel);
scoreTxt.setText(LK.getScore());
}
};
// Function to spawn a new peanut
function spawnPeanut() {
var newPeanut = new Peanut();
newPeanut.x = 2048 / 2; // Center x position
newPeanut.y = 2732 / 2; // Center y position
game.addChild(newPeanut);
}
// Add Cloud123 as background
var backgroundCloud = game.attachAsset('cloud123', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 18.48,
// Scale to cover full width (2048/100)
scaleY: 27.32 // Scale to cover full height (2732/100)
});
backgroundCloud.x = 2048 / 2; // Center horizontally
backgroundCloud.y = 2732 / 2; // Center vertically
// Start the game by spawning the first peanut
spawnPeanut();
; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// FallingPeanut class to represent peanuts that continuously fall
var FallingPeanut = Container.expand(function () {
var self = Container.call(this);
var peanutGraphics = self.attachAsset('Peanut1', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial speed for falling peanuts
self.speed = 3;
// Event handler for when a falling peanut is clicked
self.down = function (x, y, obj) {
// Add special effects when clicking
// Scale up effect
tween(peanutGraphics, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
// Scale back to normal
tween(peanutGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 150,
easing: tween.easeInOut
});
}
});
// Rotation effect
tween(peanutGraphics, {
rotation: peanutGraphics.rotation + Math.PI * 0.25
}, {
duration: 200,
easing: tween.easeInOut
});
// Flash effect with tint
tween(peanutGraphics, {
tint: 0xFFFF00
}, {
duration: 100,
easing: tween.linear,
onFinish: function onFinish() {
tween(peanutGraphics, {
tint: 0xFFFFFF
}, {
duration: 100,
easing: tween.linear
});
}
});
// Give 2x more score than regular click (2x click power * level)
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
LK.setScore(LK.getScore() + clickPower * currentLevel * 2);
scoreTxt.setText(LK.getScore());
// Level up logic
if (LK.getScore() % 100 === 0) {
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
levelTxt.setText('Level: ' + currentLevel);
}
};
// Update function to move peanuts downwards
self.update = function () {
self.y += self.speed;
self.x += self.horizontalSpeed; // Move horizontally
if (self.y > 2732) {
// Reset position to top if it goes off screen
self.y = -self.height;
}
};
});
//<Assets used in the game will automatically appear here>
// Peanut class to represent each peanut on the screen
var Peanut = Container.expand(function () {
var self = Container.call(this);
var peanutGraphics = self.attachAsset('Peanut1', {
anchorX: 0.5,
anchorY: 0.5
});
// Event handler for when a peanut is tapped
self.down = function (x, y, obj) {
// Add special effects when clicking
// Scale up effect
tween(peanutGraphics, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
// Scale back to normal
tween(peanutGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 150,
easing: tween.easeInOut
});
}
});
// Rotation effect
tween(peanutGraphics, {
rotation: peanutGraphics.rotation + Math.PI * 0.25
}, {
duration: 200,
easing: tween.easeInOut
});
// Flash effect with tint
tween(peanutGraphics, {
tint: 0xFFFF00
}, {
duration: 100,
easing: tween.linear,
onFinish: function onFinish() {
tween(peanutGraphics, {
tint: 0xFFFFFF
}, {
duration: 100,
easing: tween.linear
});
}
});
// Increase score with level multiplier and click power
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
LK.setScore(LK.getScore() + clickPower * currentLevel);
scoreTxt.setText(LK.getScore());
// Level up logic
if (LK.getScore() % 100 === 0) {
var currentLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
levelTxt.setText('Level: ' + currentLevel);
}
// Do not destroy the peanut to prevent disappearance
};
});
// Shop class to handle shop interface and upgrades
var Shop = Container.expand(function () {
var self = Container.call(this);
// Shop background
var shopBg = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 12,
tint: 0x333333
});
// Shop title
var shopTitle = new Text2('SHOP', {
size: 80,
fill: 0xFFFFFF
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 0;
shopTitle.y = -400;
self.addChild(shopTitle);
// Upgrade 1: Click Power (+1 per click)
var upgrade1Btn = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0x4CAF50
});
upgrade1Btn.x = 0;
upgrade1Btn.y = -200;
var upgrade1Text = new Text2('Click Power +1\nLevel: 0/100\nCost: 500', {
size: 40,
fill: 0xFFFFFF
});
upgrade1Text.anchor.set(0.5, 0.5);
upgrade1Text.x = 0;
upgrade1Text.y = -200;
self.addChild(upgrade1Text);
// Upgrade 2: Auto Clicker
var upgrade2Btn = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5,
tint: 0x2196F3
});
upgrade2Btn.x = 0;
upgrade2Btn.y = 0;
var upgrade2Text = new Text2('Auto Clicker\nLevel: 0/100\nCost: 1000', {
size: 40,
fill: 0xFFFFFF
});
upgrade2Text.anchor.set(0.5, 0.5);
upgrade2Text.x = 0;
upgrade2Text.y = 0;
self.addChild(upgrade2Text);
// Close button
var closeBtn = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1,
tint: 0xFF5722
});
closeBtn.x = 0;
closeBtn.y = 300;
var closeText = new Text2('CLOSE', {
size: 50,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 0;
closeText.y = 300;
self.addChild(closeText);
// Event handlers
upgrade1Btn.down = function () {
if (LK.getScore() >= 500 && clickPowerLevel < 100) {
LK.setScore(LK.getScore() - 500);
clickPower += 1;
clickPowerLevel += 1;
scoreTxt.setText(LK.getScore());
// Update button text
upgrade1Text.setText('Click Power +1\nLevel: ' + clickPowerLevel + '/100\nCost: 500');
// Change color to gray if maxed out
if (clickPowerLevel >= 100) {
upgrade1Btn.tint = 0x666666;
}
}
};
upgrade2Btn.down = function () {
if (LK.getScore() >= 1000 && autoClickerLevel < 100) {
LK.setScore(LK.getScore() - 1000);
autoClickerActive = true;
autoClickerLevel += 1;
scoreTxt.setText(LK.getScore());
// Update button text
upgrade2Text.setText('Auto Clicker\nLevel: ' + autoClickerLevel + '/100\nCost: 1000');
// Change color to gray if maxed out
if (autoClickerLevel >= 100) {
upgrade2Btn.tint = 0x666666;
}
}
};
closeBtn.down = function () {
shopVisible = false;
self.visible = false;
};
// Method to update shop display
self.updateDisplay = function () {
// Update click power display
upgrade1Text.setText('Click Power +1\nLevel: ' + clickPowerLevel + '/100\nCost: 500');
if (clickPowerLevel >= 100) {
upgrade1Btn.tint = 0x666666;
} else {
upgrade1Btn.tint = 0x4CAF50;
}
// Update auto clicker display
upgrade2Text.setText('Auto Clicker\nLevel: ' + autoClickerLevel + '/100\nCost: 1000');
if (autoClickerLevel >= 100) {
upgrade2Btn.tint = 0x666666;
} else {
upgrade2Btn.tint = 0x2196F3;
}
};
return self;
});
// ShopButton class for the shop access button
var ShopButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('peanut', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1,
tint: 0xFFD700
});
var buttonText = new Text2('SHOP', {
size: 40,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function () {
if (currentPlayerLevel >= 3) {
shopVisible = true;
shopInterface.visible = true;
shopInterface.updateDisplay(); // Update display when opening shop
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize score display
var scoreTxt = new Text2('000000', {
size: 150,
fill: 0xFFFFFF
});
// Initialize level display
var levelTxt = new Text2('Level: 1', {
size: 50,
fill: 0xFFFFFF
});
levelTxt.anchor.set(1, 1);
LK.gui.bottomRight.addChild(levelTxt);
// Initialize shop system
shopInterface = new Shop();
shopInterface.x = 400;
shopInterface.y = 2332;
shopInterface.visible = false;
game.addChild(shopInterface);
// Initialize shop button
shopButton = new ShopButton();
shopButton.x = 200;
shopButton.y = 2632;
shopButton.visible = false;
game.addChild(shopButton);
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Array to keep track of peanuts
var peanuts = [];
// Shop system variables
var shopVisible = false;
var clickPower = 1;
var autoClickerActive = false;
var currentPlayerLevel = 1;
var shopInterface;
var shopButton;
var clickPowerLevel = 0; // Track click power upgrade level (max 100)
var autoClickerLevel = 0; // Track auto clicker upgrade level (max 100)
// Function to spawn a new falling peanut
function spawnFallingPeanut() {
var newPeanut = new FallingPeanut();
newPeanut.horizontalSpeed = (Math.random() - 0.5) * 2; // Random horizontal speed between -1 and 1
do {
newPeanut.x = Math.random() * 2048; // Random x position
} while (Math.abs(newPeanut.x - 2048 / 2) < 150); // Ensure no overlap with peanut1
newPeanut.y = -newPeanut.height; // Start above the screen
peanuts.push(newPeanut);
game.addChild(newPeanut);
}
// Set interval to spawn falling peanuts every 3 seconds
var peanutSpawnInterval = LK.setInterval(spawnFallingPeanut, 3000);
// Update function called every tick
game.update = function () {
// Update all falling peanuts
for (var i = 0; i < peanuts.length; i++) {
peanuts[i].update();
}
// Update current player level
currentPlayerLevel = Math.min(100, Math.floor(LK.getScore() / 100) + 1);
// Show shop button when player reaches level 3
if (currentPlayerLevel >= 3 && !shopButton.visible) {
shopButton.visible = true;
}
// Auto clicker functionality
if (autoClickerActive && LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + clickPower * currentPlayerLevel);
scoreTxt.setText(LK.getScore());
}
};
// Function to spawn a new peanut
function spawnPeanut() {
var newPeanut = new Peanut();
newPeanut.x = 2048 / 2; // Center x position
newPeanut.y = 2732 / 2; // Center y position
game.addChild(newPeanut);
}
// Add Cloud123 as background
var backgroundCloud = game.attachAsset('cloud123', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 18.48,
// Scale to cover full width (2048/100)
scaleY: 27.32 // Scale to cover full height (2732/100)
});
backgroundCloud.x = 2048 / 2; // Center horizontally
backgroundCloud.y = 2732 / 2; // Center vertically
// Start the game by spawning the first peanut
spawnPeanut();
;