User prompt
Show what level rod you have
User prompt
fx buttons
User prompt
make a invatory gui that showsthe fish
User prompt
and when you get to level 100 it resets
User prompt
make 100 levels
User prompt
when you upgrade make the fishing rod chang color and make it were you get more money ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
show how musch money you have
User prompt
Please fix the bug: 'Timeout.tick error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.inventory = inventory;' Line Number: 238 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Tap Fisher Tycoon
Initial prompt
Make a game where you tap and you fish for fish and then you sell to upgrade your fishing rod to get better fish.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Fish = Container.expand(function (fishType) { var self = Container.call(this); var fishTypes = { 'common': { asset: 'commonFish', value: 5, name: 'Sardine' }, 'uncommon': { asset: 'uncommonFish', value: 15, name: 'Bass' }, 'rare': { asset: 'rareFish', value: 50, name: 'Tuna' }, 'legendary': { asset: 'legendaryFish', value: 200, name: 'Golden Fish' } }; self.fishData = fishTypes[fishType] || fishTypes['common']; self.fishType = fishType || 'common'; var fishGraphics = self.attachAsset(self.fishData.asset, { anchorX: 0.5, anchorY: 0.5 }); self.getValue = function () { // Progressive multiplier that grows more reasonably for 100 levels // Levels 1-10: 10% bonus per level // Levels 11-50: 5% bonus per level // Levels 51-100: 2% bonus per level var multiplier = 1; if (rodLevel <= 10) { multiplier = 1 + (rodLevel - 1) * 0.1; } else if (rodLevel <= 50) { multiplier = 2 + (rodLevel - 10) * 0.05; // Start at 2x (level 10 bonus) + additional } else { multiplier = 4 + (rodLevel - 50) * 0.02; // Start at 4x (level 50 bonus) + additional } return Math.floor(self.fishData.value * multiplier); }; self.getName = function () { return self.fishData.name; }; return self; }); var FishingRod = Container.expand(function () { var self = Container.call(this); var rodGraphics = self.attachAsset('fishingRod', { anchorX: 0.5, anchorY: 0 }); var lineGraphics = self.attachAsset('fishingLine', { anchorX: 0.5, anchorY: 0 }); lineGraphics.y = 300; lineGraphics.visible = false; var hookGraphics = self.attachAsset('hook', { anchorX: 0.5, anchorY: 0 }); hookGraphics.y = 700; hookGraphics.visible = false; self.isCasting = false; self.castProgress = 0; self.cast = function () { if (self.isCasting) return; self.isCasting = true; self.castProgress = 0; lineGraphics.visible = true; hookGraphics.visible = true; tween(self, { castProgress: 1 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { self.pullUp(); } }); }; self.pullUp = function () { tween(self, { castProgress: 0 }, { duration: 800, easing: tween.easeIn, onFinish: function onFinish() { lineGraphics.visible = false; hookGraphics.visible = false; self.isCasting = false; } }); }; self.update = function () { if (self.isCasting) { lineGraphics.height = 400 + self.castProgress * 300; hookGraphics.y = 700 + self.castProgress * 300; } }; return self; }); var UpgradeButton = Container.expand(function (upgradeType, cost, description) { var self = Container.call(this); var buttonGraphics = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(description + '\n$' + cost, { size: 32, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.upgradeType = upgradeType; self.cost = cost; self.description = description; self.updateText = function (newCost) { self.cost = newCost; buttonText.setText(self.description + '\n$' + newCost); }; self.down = function (x, y, obj) { if (coins >= self.cost) { coins -= self.cost; LK.getSound('upgrade').play(); if (self.upgradeType === 'rod') { rodLevel++; self.updateText(Math.floor(self.cost * 1.5)); updateRodAppearance(); // Update rod color when upgraded } updateUI(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state variables var coins = storage.coins || 0; var rodLevel = storage.rodLevel || 1; // Reconstruct inventory from flattened storage var inventory = []; var storedTypes = storage.inventoryTypes || []; var storedValues = storage.inventoryValues || []; var storedNames = storage.inventoryNames || []; for (var i = 0; i < storedTypes.length; i++) { inventory.push({ type: storedTypes[i], value: storedValues[i], name: storedNames[i] }); } var totalFishCaught = storage.totalFishCaught || 0; // Create water background var water = game.attachAsset('water', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Create fishing rod var fishingRod = game.addChild(new FishingRod()); fishingRod.x = 1024; fishingRod.y = 200; // Function to update rod appearance based on level function updateRodAppearance() { var rodColors = [0x8b4513, 0x4a90e2, 0x9b59b6, 0xe74c3c, 0xf39c12, // Levels 1-5: Brown, Blue, Purple, Red, Orange 0x1abc9c, 0x34495e, 0xe67e22, 0x9c88ff, 0xff6b6b, // Levels 6-10: Turquoise, Dark Gray, Orange, Light Purple, Light Red 0x4ecdc4, 0x45b7d1, 0x96ceb4, 0xfeca57, 0xff9ff3, // Levels 11-15: Mint, Sky Blue, Sage, Yellow, Pink 0x54a0ff, 0x5f27cd, 0x00d2d3, 0xff9f43, 0xc44569, // Levels 16-20: Blue, Deep Purple, Cyan, Peach, Maroon 0x3d5a80, 0x98ddca, 0xd63031, 0x6c5ce7, 0xa29bfe // Levels 21-25: Navy, Mint Green, Crimson, Violet, Periwinkle ]; var rodGraphics = fishingRod.children[0]; // First child is the rod graphics if (rodGraphics) { var colorIndex; if (rodLevel <= 25) { colorIndex = rodLevel - 1; } else { // For levels 26-100, cycle through colors with slight variations var baseColorIndex = (rodLevel - 26) % 25; var variation = Math.floor((rodLevel - 26) / 25); var baseColor = rodColors[baseColorIndex]; // Add brightness variation for higher levels var brightnessFactor = 1 + variation * 0.15; var r = Math.min(255, Math.floor((baseColor >> 16 & 0xFF) * brightnessFactor)); var g = Math.min(255, Math.floor((baseColor >> 8 & 0xFF) * brightnessFactor)); var b = Math.min(255, Math.floor((baseColor & 0xFF) * brightnessFactor)); var finalColor = r << 16 | g << 8 | b; tween(rodGraphics, { tint: finalColor }, { duration: 500, easing: tween.easeOut }); return; } tween(rodGraphics, { tint: rodColors[colorIndex] }, { duration: 500, easing: tween.easeOut }); } } // Set initial rod color updateRodAppearance(); // Create UI elements var coinsText = new Text2('Coins: $' + coins, { size: 48, fill: 0xFFFFFF }); coinsText.anchor.set(0, 0); coinsText.x = 120; // Position away from top-left menu icon LK.gui.topLeft.addChild(coinsText); var rodLevelText = new Text2('Rod Level: ' + rodLevel, { size: 36, fill: 0xFFFFFF }); rodLevelText.anchor.set(0, 0); LK.gui.topRight.addChild(rodLevelText); rodLevelText.y = 60; var inventoryText = new Text2('Fish Caught: ' + inventory.length, { size: 36, fill: 0xFFFFFF }); inventoryText.anchor.set(0, 0); LK.gui.topRight.addChild(inventoryText); inventoryText.y = 110; // Create upgrade button var rodUpgrade = game.addChild(new UpgradeButton('rod', 100, 'Upgrade Rod')); rodUpgrade.x = 1024; rodUpgrade.y = 2500; // Create sell button var sellButtonGraphics = game.attachAsset('sellButton', { anchorX: 0.5, anchorY: 0.5, x: 300, y: 2500 }); var sellButtonText = new Text2('Sell All Fish', { size: 32, fill: 0xFFFFFF }); sellButtonText.anchor.set(0.5, 0.5); sellButtonGraphics.addChild(sellButtonText); // Fish spawn area var fishSpawnArea = { x: 400, y: 1400, width: 1200, height: 800 }; // Arrays to track game objects var caughtFish = []; var fishingTimer = 0; function updateUI() { coinsText.setText('Coins: $' + coins); rodLevelText.setText('Rod Level: ' + rodLevel); inventoryText.setText('Fish Caught: ' + inventory.length); // Save to storage - flatten inventory for storage compatibility storage.coins = coins; storage.rodLevel = rodLevel; // Store inventory as separate arrays var inventoryTypes = []; var inventoryValues = []; var inventoryNames = []; for (var i = 0; i < inventory.length; i++) { inventoryTypes.push(inventory[i].type); inventoryValues.push(inventory[i].value); inventoryNames.push(inventory[i].name); } storage.inventoryTypes = inventoryTypes; storage.inventoryValues = inventoryValues; storage.inventoryNames = inventoryNames; storage.totalFishCaught = totalFishCaught; } function getFishTypeByRodLevel() { var random = Math.random(); // Progressive legendary fish chance (starts at level 10, max 25% at level 100) var legendaryChance = Math.max(0, (rodLevel - 10) * 0.0025); legendaryChance = Math.min(0.25, legendaryChance); // Progressive rare fish chance (starts at level 5, max 40% at level 100) var rareChance = Math.max(0, (rodLevel - 5) * 0.004); rareChance = Math.min(0.4, rareChance); // Progressive uncommon fish chance (starts at level 2, max 50% at level 100) var uncommonChance = Math.max(0, (rodLevel - 2) * 0.005); uncommonChance = Math.min(0.5, uncommonChance); if (random < legendaryChance) return 'legendary'; if (random < legendaryChance + rareChance) return 'rare'; if (random < legendaryChance + rareChance + uncommonChance) return 'uncommon'; return 'common'; } function spawnFish() { var fishType = getFishTypeByRodLevel(); var fish = new Fish(fishType); fish.x = fishSpawnArea.x + Math.random() * fishSpawnArea.width; fish.y = fishSpawnArea.y + Math.random() * fishSpawnArea.height; game.addChild(fish); caughtFish.push(fish); inventory.push({ type: fishType, value: fish.getValue(), name: fish.getName() }); totalFishCaught++; // Animate fish jump var originalY = fish.y; tween(fish, { y: originalY - 100 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { tween(fish, { y: originalY }, { duration: 500, easing: tween.easeIn, onFinish: function onFinish() { tween(fish, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { fish.destroy(); var index = caughtFish.indexOf(fish); if (index > -1) { caughtFish.splice(index, 1); } } }); } }); } }); LK.getSound('catch').play(); updateUI(); } // Game tap handler game.down = function (x, y, obj) { if (!fishingRod.isCasting) { fishingRod.cast(); LK.getSound('splash').play(); // Chance to catch fish based on rod level (scales to 100 levels, max 95%) var catchChance = 0.3 + Math.min(0.65, rodLevel * 0.0065); if (Math.random() < catchChance) { LK.setTimeout(function () { spawnFish(); }, 1200); } } }; // Sell button handler sellButtonGraphics.down = function (x, y, obj) { if (inventory.length > 0) { var totalValue = 0; for (var i = 0; i < inventory.length; i++) { totalValue += inventory[i].value; } coins += totalValue; inventory = []; // Clear visible fish for (var j = 0; j < caughtFish.length; j++) { if (caughtFish[j] && caughtFish[j].destroy) { caughtFish[j].destroy(); } } caughtFish = []; updateUI(); LK.effects.flashScreen(0x00FF00, 500); } }; // Auto-save every 5 seconds var autoSaveTimer = LK.setInterval(function () { storage.coins = coins; storage.rodLevel = rodLevel; // Store inventory as separate arrays var inventoryTypes = []; var inventoryValues = []; var inventoryNames = []; for (var i = 0; i < inventory.length; i++) { inventoryTypes.push(inventory[i].type); inventoryValues.push(inventory[i].value); inventoryNames.push(inventory[i].name); } storage.inventoryTypes = inventoryTypes; storage.inventoryValues = inventoryValues; storage.inventoryNames = inventoryNames; storage.totalFishCaught = totalFishCaught; }, 5000); game.update = function () { // Update fishing rod animation if (fishingRod && fishingRod.update) { fishingRod.update(); } // Update upgrade button cost display with progressive scaling for 100 levels var targetCost; if (rodLevel <= 10) { targetCost = Math.floor(100 * Math.pow(1.5, rodLevel - 1)); } else if (rodLevel <= 50) { var baseCost = Math.floor(100 * Math.pow(1.5, 9)); // Cost at level 10 targetCost = Math.floor(baseCost * Math.pow(1.3, rodLevel - 10)); } else { var baseCost10 = Math.floor(100 * Math.pow(1.5, 9)); var baseCost50 = Math.floor(baseCost10 * Math.pow(1.3, 40)); targetCost = Math.floor(baseCost50 * Math.pow(1.2, rodLevel - 50)); } if (rodUpgrade && rodUpgrade.cost !== targetCost) { rodUpgrade.updateText(targetCost); } };
===================================================================
--- original.js
+++ change.js
@@ -37,9 +37,20 @@
anchorX: 0.5,
anchorY: 0.5
});
self.getValue = function () {
- var multiplier = 1 + (rodLevel - 1) * 0.5; // 50% bonus per rod level
+ // Progressive multiplier that grows more reasonably for 100 levels
+ // Levels 1-10: 10% bonus per level
+ // Levels 11-50: 5% bonus per level
+ // Levels 51-100: 2% bonus per level
+ var multiplier = 1;
+ if (rodLevel <= 10) {
+ multiplier = 1 + (rodLevel - 1) * 0.1;
+ } else if (rodLevel <= 50) {
+ multiplier = 2 + (rodLevel - 10) * 0.05; // Start at 2x (level 10 bonus) + additional
+ } else {
+ multiplier = 4 + (rodLevel - 50) * 0.02; // Start at 4x (level 50 bonus) + additional
+ }
return Math.floor(self.fishData.value * multiplier);
};
self.getName = function () {
return self.fishData.name;
@@ -175,13 +186,44 @@
fishingRod.x = 1024;
fishingRod.y = 200;
// Function to update rod appearance based on level
function updateRodAppearance() {
- var rodColors = [0x8b4513, 0x4a90e2, 0x9b59b6, 0xe74c3c, 0xf39c12]; // Brown, Blue, Purple, Red, Orange
+ var rodColors = [0x8b4513, 0x4a90e2, 0x9b59b6, 0xe74c3c, 0xf39c12,
+ // Levels 1-5: Brown, Blue, Purple, Red, Orange
+ 0x1abc9c, 0x34495e, 0xe67e22, 0x9c88ff, 0xff6b6b,
+ // Levels 6-10: Turquoise, Dark Gray, Orange, Light Purple, Light Red
+ 0x4ecdc4, 0x45b7d1, 0x96ceb4, 0xfeca57, 0xff9ff3,
+ // Levels 11-15: Mint, Sky Blue, Sage, Yellow, Pink
+ 0x54a0ff, 0x5f27cd, 0x00d2d3, 0xff9f43, 0xc44569,
+ // Levels 16-20: Blue, Deep Purple, Cyan, Peach, Maroon
+ 0x3d5a80, 0x98ddca, 0xd63031, 0x6c5ce7, 0xa29bfe // Levels 21-25: Navy, Mint Green, Crimson, Violet, Periwinkle
+ ];
var rodGraphics = fishingRod.children[0]; // First child is the rod graphics
- if (rodGraphics && rodLevel <= rodColors.length) {
+ if (rodGraphics) {
+ var colorIndex;
+ if (rodLevel <= 25) {
+ colorIndex = rodLevel - 1;
+ } else {
+ // For levels 26-100, cycle through colors with slight variations
+ var baseColorIndex = (rodLevel - 26) % 25;
+ var variation = Math.floor((rodLevel - 26) / 25);
+ var baseColor = rodColors[baseColorIndex];
+ // Add brightness variation for higher levels
+ var brightnessFactor = 1 + variation * 0.15;
+ var r = Math.min(255, Math.floor((baseColor >> 16 & 0xFF) * brightnessFactor));
+ var g = Math.min(255, Math.floor((baseColor >> 8 & 0xFF) * brightnessFactor));
+ var b = Math.min(255, Math.floor((baseColor & 0xFF) * brightnessFactor));
+ var finalColor = r << 16 | g << 8 | b;
+ tween(rodGraphics, {
+ tint: finalColor
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+ return;
+ }
tween(rodGraphics, {
- tint: rodColors[rodLevel - 1]
+ tint: rodColors[colorIndex]
}, {
duration: 500,
easing: tween.easeOut
});
@@ -260,11 +302,20 @@
storage.totalFishCaught = totalFishCaught;
}
function getFishTypeByRodLevel() {
var random = Math.random();
- if (rodLevel >= 4 && random < 0.05) return 'legendary';
- if (rodLevel >= 3 && random < 0.15) return 'rare';
- if (rodLevel >= 2 && random < 0.3) return 'uncommon';
+ // Progressive legendary fish chance (starts at level 10, max 25% at level 100)
+ var legendaryChance = Math.max(0, (rodLevel - 10) * 0.0025);
+ legendaryChance = Math.min(0.25, legendaryChance);
+ // Progressive rare fish chance (starts at level 5, max 40% at level 100)
+ var rareChance = Math.max(0, (rodLevel - 5) * 0.004);
+ rareChance = Math.min(0.4, rareChance);
+ // Progressive uncommon fish chance (starts at level 2, max 50% at level 100)
+ var uncommonChance = Math.max(0, (rodLevel - 2) * 0.005);
+ uncommonChance = Math.min(0.5, uncommonChance);
+ if (random < legendaryChance) return 'legendary';
+ if (random < legendaryChance + rareChance) return 'rare';
+ if (random < legendaryChance + rareChance + uncommonChance) return 'uncommon';
return 'common';
}
function spawnFish() {
var fishType = getFishTypeByRodLevel();
@@ -316,10 +367,10 @@
game.down = function (x, y, obj) {
if (!fishingRod.isCasting) {
fishingRod.cast();
LK.getSound('splash').play();
- // Chance to catch fish based on rod level
- var catchChance = 0.3 + rodLevel * 0.1;
+ // Chance to catch fish based on rod level (scales to 100 levels, max 95%)
+ var catchChance = 0.3 + Math.min(0.65, rodLevel * 0.0065);
if (Math.random() < catchChance) {
LK.setTimeout(function () {
spawnFish();
}, 1200);
@@ -368,10 +419,20 @@
// Update fishing rod animation
if (fishingRod && fishingRod.update) {
fishingRod.update();
}
- // Update upgrade button cost display
- if (rodUpgrade && rodUpgrade.cost !== 100 * Math.pow(1.5, rodLevel - 1)) {
- var newCost = Math.floor(100 * Math.pow(1.5, rodLevel - 1));
- rodUpgrade.updateText(newCost);
+ // Update upgrade button cost display with progressive scaling for 100 levels
+ var targetCost;
+ if (rodLevel <= 10) {
+ targetCost = Math.floor(100 * Math.pow(1.5, rodLevel - 1));
+ } else if (rodLevel <= 50) {
+ var baseCost = Math.floor(100 * Math.pow(1.5, 9)); // Cost at level 10
+ targetCost = Math.floor(baseCost * Math.pow(1.3, rodLevel - 10));
+ } else {
+ var baseCost10 = Math.floor(100 * Math.pow(1.5, 9));
+ var baseCost50 = Math.floor(baseCost10 * Math.pow(1.3, 40));
+ targetCost = Math.floor(baseCost50 * Math.pow(1.2, rodLevel - 50));
}
+ if (rodUpgrade && rodUpgrade.cost !== targetCost) {
+ rodUpgrade.updateText(targetCost);
+ }
};
\ No newline at end of file