/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // No plugins needed - using simple animations instead var UltraRealisticButton = Container.expand(function () { var self = Container.call(this); // Create all button layers from bottom to top with enhanced 3D depth var outerGlow = self.attachAsset('buttonOuterGlow', { anchorX: 0.5, anchorY: 0.5, alpha: 0.15, y: 15, scaleX: 1.1, scaleY: 1.1 }); var baseShadow = self.attachAsset('buttonBaseShadow', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8, y: 12, scaleX: 1.05, scaleY: 1.05 }); var deepShadow = self.attachAsset('buttonDeepShadow', { anchorX: 0.5, anchorY: 0.5, alpha: 0.6, y: 8, scaleX: 1.02, scaleY: 1.02 }); var rim = self.attachAsset('buttonRim', { anchorX: 0.5, anchorY: 0.5, alpha: 0.9, y: -2 }); var base = self.attachAsset('buttonBase', { anchorX: 0.5, anchorY: 0.5, y: -5 }); var mainBody = self.attachAsset('buttonMainBody', { anchorX: 0.5, anchorY: 0.5, y: -8 }); var gradientTop = self.attachAsset('buttonGradientTop', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8, y: -10 }); var gradientMid = self.attachAsset('buttonGradientMid', { anchorX: 0.5, anchorY: 0.5, alpha: 0.6, y: -6 }); var innerGlow = self.attachAsset('buttonInnerGlow', { anchorX: 0.5, anchorY: 0.5, alpha: 0.4, y: -12 }); var centerHighlight = self.attachAsset('buttonCenterHighlight', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3, y: -15 }); var topReflection = self.attachAsset('buttonTopReflection', { anchorX: 0.5, anchorY: 0.5, alpha: 0.5, y: -65 }); var gloss = self.attachAsset('buttonGloss', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7, y: -95 }); // Store references for animations self.layers = { outerGlow: outerGlow, baseShadow: baseShadow, deepShadow: deepShadow, rim: rim, base: base, mainBody: mainBody, gradientTop: gradientTop, gradientMid: gradientMid, innerGlow: innerGlow, centerHighlight: centerHighlight, topReflection: topReflection, gloss: gloss }; // Simple idle animation - gentle pulse self.startIdleAnimation = function () { self.pulseDirection = 1; self.pulseTimer = 0; }; // Simple press animation self.pressAnimation = function () { // Quick scale down self.scaleX = 0.95; self.scaleY = 0.95; self.rotation = 0.05; // Return to normal after short delay LK.setTimeout(function () { self.scaleX = 1.0; self.scaleY = 1.0; self.rotation = 0; }, 100); }; // Simple pulse animation update self.update = function () { if (self.pulseTimer !== undefined) { self.pulseTimer++; var pulseAmount = Math.sin(self.pulseTimer * 0.02) * 0.02; self.scaleX = 1.0 + pulseAmount; self.scaleY = 1.0 + pulseAmount; } }; return self; }); var Upgrade = Container.expand(function (name, baseCost, multiplier) { var self = Container.call(this); var background = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); var nameText = new Text2(name, { size: 40, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.y = -20; self.addChild(nameText); var costText = new Text2('', { size: 32, fill: 0xFFFF00 }); costText.anchor.set(0.5, 0.5); costText.y = 20; self.addChild(costText); self.name = name; self.level = 1; self.baseCost = baseCost; self.cost = baseCost; self.multiplier = multiplier; self.updateDisplay = function () { nameText.setText(self.name + ' (Lv.' + self.level + ')'); costText.setText('Cost: ' + formatNumber(self.cost)); background.tint = points >= self.cost ? 0x4CAF50 : 0x888888; }; self.down = function (x, y, obj) { if (points >= self.cost) { points -= self.cost; self.level++; // Simple 1.25x (25%) cost increase each level self.cost = Math.floor(self.cost * 1.25); self.updateDisplay(); updatePointsDisplay(); // Save upgrade data and points storage.points = points; storage.upgradeLevel = self.level; storage.upgradeCost = self.cost; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2E1065 }); /**** * Game Code ****/ //Storage library which should be used for persistent game data // Game variables - Initialize from storage with defaults var points = storage.points || 0; var totalClicks = storage.totalClicks || 0; var clickPower = storage.clickPower || 1; // Helper functions function formatNumber(num) { if (num >= 1000000000) { return (num / 1000000000).toFixed(1) + 'B'; } else if (num >= 1000000) { return (num / 1000000).toFixed(1) + 'M'; } else if (num >= 1000) { return (num / 1000).toFixed(1) + 'K'; } return Math.floor(num).toString(); } function updatePointsDisplay() { pointsText.setText(formatNumber(points) + ' Points'); } function updateAllDisplays() { updatePointsDisplay(); if (upgradeButton) { upgradeButton.updateDisplay(); } } // Simple game state - no persistence needed // Variables are now initialized from storage, so we just need to load upgrade and auto-clicker data // Create ultra-realistic button var mainButton = game.addChild(new UltraRealisticButton()); mainButton.x = 1024; mainButton.y = 1366; // Start the subtle idle animation mainButton.startIdleAnimation(); // Create points display var pointsText = new Text2('0 Points', { size: 80, fill: 0xFFFFFF }); pointsText.anchor.set(0.5, 0.5); pointsText.x = 1024; pointsText.y = 600; game.addChild(pointsText); // Create upgrade button var upgradeButton = new Upgrade('Click Power', 100, 1.25); upgradeButton.x = 1024; upgradeButton.y = 1800; game.addChild(upgradeButton); // Load upgrade data from storage upgradeButton.level = storage.upgradeLevel || 1; upgradeButton.cost = storage.upgradeCost || 100; // Click power calculation function getClickValue() { return clickPower * upgradeButton.level; } // Event handlers mainButton.down = function (x, y, obj) { var clickValue = getClickValue(); points += clickValue; totalClicks++; // Simple button press animation mainButton.pressAnimation(); // Simple rotation wiggle mainButton.rotation = 0.1; LK.setTimeout(function () { mainButton.rotation = -0.1; LK.setTimeout(function () { mainButton.rotation = 0; }, 50); }, 50); updatePointsDisplay(); // Save game state storage.points = points; storage.totalClicks = totalClicks; }; // Initialize display updatePointsDisplay(); upgradeButton.updateDisplay(); updateAllDisplays(); // Simple game update with small animations game.update = function () { // Update upgrade button display less frequently if (LK.ticks % 60 === 0) { upgradeButton.updateDisplay(); } // Add gentle floating animation to points text pointsText.y = 600 + Math.sin(LK.ticks * 0.01) * 3; };
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// No plugins needed - using simple animations instead
var UltraRealisticButton = Container.expand(function () {
var self = Container.call(this);
// Create all button layers from bottom to top with enhanced 3D depth
var outerGlow = self.attachAsset('buttonOuterGlow', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.15,
y: 15,
scaleX: 1.1,
scaleY: 1.1
});
var baseShadow = self.attachAsset('buttonBaseShadow', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8,
y: 12,
scaleX: 1.05,
scaleY: 1.05
});
var deepShadow = self.attachAsset('buttonDeepShadow', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.6,
y: 8,
scaleX: 1.02,
scaleY: 1.02
});
var rim = self.attachAsset('buttonRim', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.9,
y: -2
});
var base = self.attachAsset('buttonBase', {
anchorX: 0.5,
anchorY: 0.5,
y: -5
});
var mainBody = self.attachAsset('buttonMainBody', {
anchorX: 0.5,
anchorY: 0.5,
y: -8
});
var gradientTop = self.attachAsset('buttonGradientTop', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8,
y: -10
});
var gradientMid = self.attachAsset('buttonGradientMid', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.6,
y: -6
});
var innerGlow = self.attachAsset('buttonInnerGlow', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.4,
y: -12
});
var centerHighlight = self.attachAsset('buttonCenterHighlight', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3,
y: -15
});
var topReflection = self.attachAsset('buttonTopReflection', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.5,
y: -65
});
var gloss = self.attachAsset('buttonGloss', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.7,
y: -95
});
// Store references for animations
self.layers = {
outerGlow: outerGlow,
baseShadow: baseShadow,
deepShadow: deepShadow,
rim: rim,
base: base,
mainBody: mainBody,
gradientTop: gradientTop,
gradientMid: gradientMid,
innerGlow: innerGlow,
centerHighlight: centerHighlight,
topReflection: topReflection,
gloss: gloss
};
// Simple idle animation - gentle pulse
self.startIdleAnimation = function () {
self.pulseDirection = 1;
self.pulseTimer = 0;
};
// Simple press animation
self.pressAnimation = function () {
// Quick scale down
self.scaleX = 0.95;
self.scaleY = 0.95;
self.rotation = 0.05;
// Return to normal after short delay
LK.setTimeout(function () {
self.scaleX = 1.0;
self.scaleY = 1.0;
self.rotation = 0;
}, 100);
};
// Simple pulse animation update
self.update = function () {
if (self.pulseTimer !== undefined) {
self.pulseTimer++;
var pulseAmount = Math.sin(self.pulseTimer * 0.02) * 0.02;
self.scaleX = 1.0 + pulseAmount;
self.scaleY = 1.0 + pulseAmount;
}
};
return self;
});
var Upgrade = Container.expand(function (name, baseCost, multiplier) {
var self = Container.call(this);
var background = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5
});
var nameText = new Text2(name, {
size: 40,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.y = -20;
self.addChild(nameText);
var costText = new Text2('', {
size: 32,
fill: 0xFFFF00
});
costText.anchor.set(0.5, 0.5);
costText.y = 20;
self.addChild(costText);
self.name = name;
self.level = 1;
self.baseCost = baseCost;
self.cost = baseCost;
self.multiplier = multiplier;
self.updateDisplay = function () {
nameText.setText(self.name + ' (Lv.' + self.level + ')');
costText.setText('Cost: ' + formatNumber(self.cost));
background.tint = points >= self.cost ? 0x4CAF50 : 0x888888;
};
self.down = function (x, y, obj) {
if (points >= self.cost) {
points -= self.cost;
self.level++;
// Simple 1.25x (25%) cost increase each level
self.cost = Math.floor(self.cost * 1.25);
self.updateDisplay();
updatePointsDisplay();
// Save upgrade data and points
storage.points = points;
storage.upgradeLevel = self.level;
storage.upgradeCost = self.cost;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2E1065
});
/****
* Game Code
****/
//Storage library which should be used for persistent game data
// Game variables - Initialize from storage with defaults
var points = storage.points || 0;
var totalClicks = storage.totalClicks || 0;
var clickPower = storage.clickPower || 1;
// Helper functions
function formatNumber(num) {
if (num >= 1000000000) {
return (num / 1000000000).toFixed(1) + 'B';
} else if (num >= 1000000) {
return (num / 1000000).toFixed(1) + 'M';
} else if (num >= 1000) {
return (num / 1000).toFixed(1) + 'K';
}
return Math.floor(num).toString();
}
function updatePointsDisplay() {
pointsText.setText(formatNumber(points) + ' Points');
}
function updateAllDisplays() {
updatePointsDisplay();
if (upgradeButton) {
upgradeButton.updateDisplay();
}
}
// Simple game state - no persistence needed
// Variables are now initialized from storage, so we just need to load upgrade and auto-clicker data
// Create ultra-realistic button
var mainButton = game.addChild(new UltraRealisticButton());
mainButton.x = 1024;
mainButton.y = 1366;
// Start the subtle idle animation
mainButton.startIdleAnimation();
// Create points display
var pointsText = new Text2('0 Points', {
size: 80,
fill: 0xFFFFFF
});
pointsText.anchor.set(0.5, 0.5);
pointsText.x = 1024;
pointsText.y = 600;
game.addChild(pointsText);
// Create upgrade button
var upgradeButton = new Upgrade('Click Power', 100, 1.25);
upgradeButton.x = 1024;
upgradeButton.y = 1800;
game.addChild(upgradeButton);
// Load upgrade data from storage
upgradeButton.level = storage.upgradeLevel || 1;
upgradeButton.cost = storage.upgradeCost || 100;
// Click power calculation
function getClickValue() {
return clickPower * upgradeButton.level;
}
// Event handlers
mainButton.down = function (x, y, obj) {
var clickValue = getClickValue();
points += clickValue;
totalClicks++;
// Simple button press animation
mainButton.pressAnimation();
// Simple rotation wiggle
mainButton.rotation = 0.1;
LK.setTimeout(function () {
mainButton.rotation = -0.1;
LK.setTimeout(function () {
mainButton.rotation = 0;
}, 50);
}, 50);
updatePointsDisplay();
// Save game state
storage.points = points;
storage.totalClicks = totalClicks;
};
// Initialize display
updatePointsDisplay();
upgradeButton.updateDisplay();
updateAllDisplays();
// Simple game update with small animations
game.update = function () {
// Update upgrade button display less frequently
if (LK.ticks % 60 === 0) {
upgradeButton.updateDisplay();
}
// Add gentle floating animation to points text
pointsText.y = 600 + Math.sin(LK.ticks * 0.01) * 3;
};