Code edit (11 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Ok, make the progress back 10px height and 2048 width and, make the progress bar 8px height and from 0 ro 2048 width depending on progress
Code edit (2 edits merged)
Please save this source code
User prompt
add a new progressbar class that uses assets progressBack and progressBar. don't do anything else
Code edit (7 edits merged)
Please save this source code
User prompt
if stored score was > 0, change the intro message to "Welcome back my love!"
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -690,20 +690,22 @@
var ProgressBar = Container.expand(function () {
var self = Container.call(this);
// Attach the progressBack asset
var progressBack = self.attachAsset('progressBack', {
- anchorX: 0.5,
+ anchorX: 0,
anchorY: 0.5,
width: 2048,
- height: 10
+ height: 40,
+ alpha: 0.8
});
// Attach the progressBar asset
var progressBar = self.attachAsset('progressBar', {
- anchorX: 0.5,
+ anchorX: 0,
anchorY: 0.5,
width: 2048,
- height: 8,
- y: 1
+ height: 32,
+ alpha: 0.8,
+ y: 4
});
// Set initial progress to 0
self.progress = 0;
// Method to update the progress
@@ -1291,8 +1293,11 @@
///////////////////////////////////////////////////////// GLOBAL VARIABLES ////////////////////////////////////////////////////////////
var maxGenerators = 9;
var nbHearts = 10;
var tapCount;
+var displayedTapCount; // For smooth animation
+var targetTapCount; // Target value for animation
+var isAnimatingCount = false; // Flag to track if count animation is in progress
var background;
var backgroundContainer;
var giftsContainer;
var middlegroundContainer;
@@ -1318,11 +1323,65 @@
console.log.apply(console, arguments);
}
}
function updateTapCountText() {
- tapCountText.setText('LOVE\r\n' + tapCount);
+ tapCountText.setText('LOVE\r\n' + displayedTapCount);
}
-// Helper function to add large numbers as strings
+// Function to animate the tap count smoothly
+function animateTapCount() {
+ if (!isAnimatingCount || displayedTapCount === targetTapCount) {
+ isAnimatingCount = false;
+ return;
+ }
+ // Determine if we need to increase or decrease the displayed count
+ var isIncreasing = compareNumbers(targetTapCount, displayedTapCount) > 0;
+ // Calculate the difference between current and target
+ var diff = isIncreasing ? subtractLargeNumbers(targetTapCount, displayedTapCount) : subtractLargeNumbers(displayedTapCount, targetTapCount);
+ if (diff === "0") {
+ displayedTapCount = targetTapCount; // Ensure exact match at the end
+ updateTapCountText();
+ isAnimatingCount = false;
+ return;
+ }
+ // Determine step size based on difference magnitude
+ var stepSize = "1";
+ var diffLength = diff.length;
+ // Use a more gradual step size calculation for smoother animation
+ if (diffLength > 5) {
+ // For very large differences
+ stepSize = "1" + "0".repeat(diffLength - 3);
+ } else if (diffLength > 3) {
+ // For medium differences
+ stepSize = "1" + "0".repeat(diffLength - 3);
+ } else if (diffLength > 2) {
+ // For hundreds
+ stepSize = "5";
+ } else {
+ // For small differences (1-99)
+ stepSize = "1";
+ }
+ // Update the displayed count
+ if (isIncreasing) {
+ displayedTapCount = addLargeNumbers(displayedTapCount, stepSize);
+ } else {
+ displayedTapCount = subtractLargeNumbers(displayedTapCount, stepSize);
+ }
+ // Update the text
+ updateTapCountText();
+ // Continue animation in the next frame - use a faster frame rate for smoother animation
+ LK.setTimeout(animateTapCount, 10); // ~100fps for smoother animation
+}
+function compareNumbers(a, b) {
+ a = a.toString();
+ b = b.toString();
+ if (a.length < b.length) {
+ return -1;
+ }
+ if (a.length > b.length) {
+ return 1;
+ }
+ return a < b ? -1 : a > b ? 1 : 0;
+}
function addLargeNumbers(a, b) {
// Convert numbers to strings if they aren't already
a = a.toString();
b = b.toString();
@@ -1454,11 +1513,15 @@
beatsToGenerate = Math.min(beatsToGenerate, self.maxHeartBeatsPerSecond); // Cap at 5 beats per update to avoid overwhelming
if (tempGenerated > 0) {
self.money = addLargeNumbers(self.money, tempGenerated.toString());
tapCount = self.money;
+ targetTapCount = tapCount; // Update target for animation
+ if (!isAnimatingCount) {
+ isAnimatingCount = true;
+ animateTapCount();
+ }
}
bigHeart.highestScore = Math.max(bigHeart.highestScore, parseInt(tapCount)); // Update highestScore
- updateTapCountText(); // Update the text display
self.lastUpdateTime = now;
// Save game status
storage.tapCount = tapCount;
storage.isInfiniteMode = isInfiniteMode;
@@ -1468,8 +1531,15 @@
length: 10
}, function (_, i) {
return self.generatorCounts[i] || 0;
});
+ // Update progress bar based on current level progress
+ if (!isInfiniteMode) {
+ var startTap = self.currentLevel === 0 ? 0 : TAPS_PER_LEVEL[self.currentLevel - 1];
+ var endTap = TAPS_PER_LEVEL[self.currentLevel];
+ var progress = Math.min(1, (parseInt(tapCount) - startTap) / (endTap - startTap));
+ progressBar.updateProgress(progress);
+ }
if (isInfiniteMode) {
return;
}
self.updateGeneratorsUi();
@@ -1488,12 +1558,21 @@
tapCount = addLargeNumbers(tapCount, self.tapMultiplier.toString());
self.money = addLargeNumbers(self.money, self.tapMultiplier.toString());
LK.getSound('pop').play(); // Play pop sound for manualGeneration
log("manualGeneration Tap count: ", tapCount); // Log the tap count
- updateTapCountText(); // Update the text display
+ targetTapCount = tapCount; // Update target for animation
+ if (!isAnimatingCount) {
+ isAnimatingCount = true;
+ animateTapCount();
+ }
bigHeart.highestScore = Math.max(bigHeart.highestScore, parseInt(tapCount)); // Update highestScore
self.updateGeneratorsUi();
self.checkProgress(); // Check for level up immediately
+ // Update progress bar based on current level progress
+ var startTap = self.currentLevel === 0 ? 0 : TAPS_PER_LEVEL[self.currentLevel - 1];
+ var endTap = TAPS_PER_LEVEL[self.currentLevel];
+ var progress = Math.min(1, (parseInt(tapCount) - startTap) / (endTap - startTap));
+ progressBar.updateProgress(progress);
};
self.checkProgress = function () {
if (bigHeart.highestScore >= self.tapsPerLevel[self.currentLevel]) {
if (self.currentLevel < 9) {
@@ -1590,8 +1669,12 @@
}
// Subtract cost using subtractLargeNumbers
self.money = subtractLargeNumbers(self.money, generatorConfig.cost.toString());
tapCount = self.money;
+ // Update displayed count immediately without animation for price reductions
+ displayedTapCount = tapCount;
+ targetTapCount = tapCount;
+ updateTapCountText();
// Calculate new cost
var currentCount = self.generatorCounts[generatorId] || 0;
var baseCost = GENERATORS[Object.keys(GENERATORS)[generatorId]].cost;
var newCost = Math.floor(baseCost * Math.pow(self.priceIncreaseRate, currentCount + 1));
@@ -1642,8 +1725,12 @@
}
// Subtract cost using subtractLargeNumbers
self.money = subtractLargeNumbers(self.money, upgradeConfig.cost.toString());
tapCount = self.money;
+ // Update displayed count immediately without animation for price reductions
+ displayedTapCount = tapCount;
+ targetTapCount = tapCount;
+ updateTapCountText();
var upgrade = new Upgrade(upgradeConfig);
upgrade.apply(targetGenerator);
self.upgrades[upgradeId] = upgrade;
return true;
@@ -1758,9 +1845,11 @@
}
};
}
function initializeGame() {
- tapCount = storage.tapCount || 0;
+ tapCount = storage.tapCount || "0";
+ displayedTapCount = tapCount; // Initialize displayed count
+ targetTapCount = tapCount; // Initialize target count
isInfiniteMode = storage.isInfiniteMode || false;
//storage.isInfiniteMode = isInfiniteMode = false;
//storage.isInfiniteMode = isInfiniteMode = true;
var storedGenerators = storage.generators || [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
@@ -1863,9 +1952,9 @@
messageText.anchor.set(0.5, 0);
messageText.x = 1024;
messageText.y = 2500;
foregroundContainer.addChild(messageText);
- // Start updtes
+ // Start updtes
bigHeart.down();
if (tapCount >= 10) {
popMessage("Welcome back my love!");
} else {
a big lovely heart
a big stone heart
a big used copper heart
face view of a big bronze heart
face view of a big silver heart
Big shining gold heart verly slightly ornate. face view.
Big precious shiny porcelain heart slightly ornate. face view.
Large precious heart in mother-of-pearl, lightly ornate. Front view.
Large heart in precious ruby, very lightly decorated. Front view.
The most precious large heart in diamond, Front view.
clean pink enamel board witha very thin border