User prompt
Delete existing fishing rod asset and create new fishing rod asset.
User prompt
hook and line should move left and right But they must be tied to the fishing rod and not come out of the fishing rod. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
hook and line should move left and right ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The fish that comes after 500 points and eats other fish should come with less intervals
User prompt
bigFish should come with less intervals
User prompt
Fish should come less frequently and randomly.
User prompt
There should be no time in the game
User prompt
After 500 points, a bigger fish should come and this fish should eat other fish.
User prompt
Fishing line should be under the fishing rod
User prompt
Add medium sized fish
User prompt
The fishing line must be tied to the fishing rod.
User prompt
The hook must be attached to the fishing line, below the fishing rod, that is, the fishing line. Also the hook should move in all directions.
User prompt
The tip of the fishing rod must be in line with the fishing rod and must be attached to the fishing rod.
User prompt
The fishing rod should remain stationary, but the tip of the fishing rod should move in all directions.
User prompt
The fishing rod should move in all directions.
Code edit (1 edits merged)
Please save this source code
User prompt
Deep Sea Fishing
Initial prompt
Make me a like Gold Mining but instead of golds player should collect fishes with a fishing rod
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Fish = Container.expand(function (fishType, depth) {
var self = Container.call(this);
var fishGraphics = self.attachAsset(fishType, {
anchorX: 0.5,
anchorY: 0.5
});
self.fishType = fishType;
self.depth = depth;
self.speed = 2;
self.direction = Math.random() > 0.5 ? 1 : -1;
self.value = fishType === 'smallFish' ? 10 : fishType === 'mediumFish' ? 25 : fishType === 'largeFish' ? 50 : 100;
self.caught = false;
self.isBigFish = fishType === 'bigFish';
self.lastEatingTime = 0;
// Set fish speed based on type
if (fishType === 'smallFish') {
self.speed = 3;
} else if (fishType === 'mediumFish') {
self.speed = 2;
} else if (fishType === 'largeFish') {
self.speed = 1.5;
} else {
self.speed = 1; // Big fish is slowest
}
self.update = function () {
if (!self.caught) {
self.x += self.speed * self.direction;
// Reverse direction if fish goes off screen
if (self.x < -100 || self.x > 2148) {
self.direction *= -1;
}
// Big fish eating behavior
if (self.isBigFish && LK.ticks - self.lastEatingTime > 60) {
for (var i = fish.length - 1; i >= 0; i--) {
var otherFish = fish[i];
if (otherFish !== self && !otherFish.caught && !otherFish.isBigFish) {
var distance = Math.sqrt(Math.pow(self.x - otherFish.x, 2) + Math.pow(self.y - otherFish.y, 2));
if (distance < 80) {
// Eat the fish
otherFish.destroy();
fish.splice(i, 1);
self.lastEatingTime = LK.ticks;
break;
}
}
}
}
}
};
return self;
});
var FishingLine = Container.expand(function () {
var self = Container.call(this);
self.segments = [];
self.hook = self.addChild(LK.getAsset('hook', {
anchorX: 0.5,
anchorY: 0.5
}));
self.maxLength = 1500;
self.currentLength = 0;
self.isDropping = false;
self.isReeling = false;
self.caughtFish = null;
self.startDrop = function () {
if (!self.isDropping && !self.isReeling) {
self.isDropping = true;
LK.getSound('splash').play();
}
};
self.startReel = function () {
if (self.isDropping && !self.isReeling) {
self.isDropping = false;
self.isReeling = true;
}
};
self.update = function () {
// Drop line
if (self.isDropping && self.currentLength < self.maxLength) {
self.currentLength += 8;
self.hook.x = 0; // Keep hook centered on line
self.hook.y = self.currentLength;
// Add line segments
if (self.currentLength % 20 === 0) {
var segment = self.addChild(LK.getAsset('fishingLine', {
anchorX: 0.5,
anchorY: 0.5
}));
segment.x = 0; // Keep segments aligned with fishing line center
segment.y = self.currentLength - 10;
self.segments.push(segment);
}
}
// Reel in line
if (self.isReeling && self.currentLength > 0) {
self.currentLength -= 6;
self.hook.x = 0; // Keep hook centered on line
self.hook.y = self.currentLength;
// Remove line segments
if (self.segments.length > 0 && self.currentLength % 20 === 0) {
var segment = self.segments.pop();
if (segment) {
segment.destroy();
}
}
// Move caught fish with hook
if (self.caughtFish) {
self.caughtFish.x = self.x + self.hook.x;
self.caughtFish.y = self.y + self.hook.y;
}
// Check if fully reeled in
if (self.currentLength <= 0) {
self.isReeling = false;
if (self.caughtFish) {
// Score points
LK.setScore(LK.getScore() + self.caughtFish.value);
scoreTxt.setText(LK.getScore());
// Remove caught fish
self.caughtFish.destroy();
for (var i = fish.length - 1; i >= 0; i--) {
if (fish[i] === self.caughtFish) {
fish.splice(i, 1);
break;
}
}
self.caughtFish = null;
LK.getSound('catch').play();
}
}
}
// Check for fish collision
if (!self.caughtFish && self.currentLength > 0) {
for (var i = 0; i < fish.length; i++) {
var currentFish = fish[i];
if (!currentFish.caught && self.hook.intersects(currentFish)) {
self.caughtFish = currentFish;
currentFish.caught = true;
self.startReel();
break;
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var fish = [];
var fishingLine;
var waterSurface = 500;
var fishSpawnTimer = 0;
// Create water
var water = game.addChild(LK.getAsset('water', {
anchorX: 0,
anchorY: 0,
x: 0,
y: waterSurface
}));
// Create fishing rod
var fishingRod = game.addChild(LK.getAsset('fishingRod', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: waterSurface
}));
// Create fishing line
fishingLine = game.addChild(new FishingLine());
fishingLine.x = 1024; // Start at rod base, will be updated by move events
fishingLine.y = waterSurface + 10; // Position line below rod tip
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 50;
// Initialize score
scoreTxt.setText(LK.getScore());
// Spawn fish function
function spawnFish() {
var fishTypes = ['smallFish', 'mediumFish', 'largeFish'];
var depths = [200, 400, 600]; // Shallow, medium, deep
var typeIndex = Math.floor(Math.random() * fishTypes.length);
var fishType = fishTypes[typeIndex];
var depth = depths[typeIndex] + Math.random() * 200;
var newFish = new Fish(fishType, depth);
newFish.x = Math.random() > 0.5 ? -50 : 2098;
newFish.y = waterSurface + depth;
fish.push(newFish);
game.addChild(newFish);
}
// Touch controls
game.down = function (x, y, obj) {
fishingLine.startDrop();
};
game.up = function (x, y, obj) {
if (fishingLine.isDropping) {
fishingLine.startReel();
}
};
game.move = function (x, y, obj) {
// Calculate angle from rod base to touch position
var rodBaseX = 1024; // Keep rod base at center
var rodBaseY = waterSurface;
var deltaX = x - rodBaseX;
var deltaY = y - rodBaseY;
var angle = Math.atan2(deltaY, deltaX) - Math.PI / 2; // Subtract PI/2 to correct for rod anchor point
// Limit rod rotation to reasonable angles (about 60 degrees each side)
var maxAngle = Math.PI / 3; // 60 degrees
angle = Math.max(-maxAngle, Math.min(maxAngle, angle));
// Rotate the fishing rod
fishingRod.rotation = angle;
// Calculate tip position based on rod rotation and anchor point
// Since rod anchor is at bottom center (0.5, 1), we calculate from the base
var rodLength = 200; // Rod height
var tipX = rodBaseX + Math.sin(angle) * rodLength;
var tipY = rodBaseY - Math.cos(angle) * rodLength; // Negative because we go up from base
// Move fishing line to below the rod tip position
fishingLine.x = tipX;
fishingLine.y = tipY + 10; // Position line slightly below rod tip
// Update all line segments to maintain relative position to fishing line
for (var i = 0; i < fishingLine.segments.length; i++) {
fishingLine.segments[i].x = 0; // Keep segments centered relative to fishing line
}
// Update hook position to move with fishing line
fishingLine.hook.x = 0; // Reset to relative position within fishing line
fishingLine.hook.y = fishingLine.currentLength;
// Move caught fish with the hook if there is one
if (fishingLine.caughtFish) {
fishingLine.caughtFish.x = fishingLine.x;
fishingLine.caughtFish.y = fishingLine.y + fishingLine.currentLength;
}
};
// Game variables for random spawning
var nextFishSpawnTime = 180 + Math.random() * 240; // Random interval between 3-7 seconds
// Main game loop
game.update = function () {
// Spawn fish randomly
fishSpawnTimer++;
if (fishSpawnTimer >= nextFishSpawnTime) {
spawnFish();
fishSpawnTimer = 0;
// Set next random spawn time (3-7 seconds)
nextFishSpawnTime = 180 + Math.random() * 240;
}
// Clean up fish that are off screen
for (var i = fish.length - 1; i >= 0; i--) {
var currentFish = fish[i];
if (currentFish.x < -200 || currentFish.x > 2248) {
currentFish.destroy();
fish.splice(i, 1);
}
}
// Spawn big fish after 500 points with random intervals
var currentScore = LK.getScore();
if (currentScore >= 500 && Math.random() < 0.001) {
// 0.1% chance per frame (10 times less frequent)
var bigFish = new Fish('bigFish', 300 + Math.random() * 400);
bigFish.x = Math.random() > 0.5 ? -100 : 2148;
bigFish.y = waterSurface + bigFish.depth;
fish.push(bigFish);
game.addChild(bigFish);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -109,14 +109,8 @@
if (segment) {
segment.destroy();
}
}
- // Update all line segments to follow fishing line position
- for (var i = 0; i < self.segments.length; i++) {
- self.segments[i].x = 0; // Keep segments centered relative to fishing line
- }
- // Update hook position to follow fishing line
- self.hook.x = 0; // Keep hook centered on line
// Move caught fish with hook
if (self.caughtFish) {
self.caughtFish.x = self.x + self.hook.x;
self.caughtFish.y = self.y + self.hook.y;
@@ -231,31 +225,18 @@
var angle = Math.atan2(deltaY, deltaX) - Math.PI / 2; // Subtract PI/2 to correct for rod anchor point
// Limit rod rotation to reasonable angles (about 60 degrees each side)
var maxAngle = Math.PI / 3; // 60 degrees
angle = Math.max(-maxAngle, Math.min(maxAngle, angle));
+ // Rotate the fishing rod
+ fishingRod.rotation = angle;
// Calculate tip position based on rod rotation and anchor point
// Since rod anchor is at bottom center (0.5, 1), we calculate from the base
var rodLength = 200; // Rod height
var tipX = rodBaseX + Math.sin(angle) * rodLength;
var tipY = rodBaseY - Math.cos(angle) * rodLength; // Negative because we go up from base
- // Stop any existing tweens on the rod and fishing line
- tween.stop(fishingRod);
- tween.stop(fishingLine);
- // Smoothly rotate the fishing rod
- tween(fishingRod, {
- rotation: angle
- }, {
- duration: 200,
- easing: tween.easeOut
- });
- // Smoothly move fishing line to below the rod tip position
- tween(fishingLine, {
- x: tipX,
- y: tipY + 10
- }, {
- duration: 200,
- easing: tween.easeOut
- });
+ // Move fishing line to below the rod tip position
+ fishingLine.x = tipX;
+ fishingLine.y = tipY + 10; // Position line slightly below rod tip
// Update all line segments to maintain relative position to fishing line
for (var i = 0; i < fishingLine.segments.length; i++) {
fishingLine.segments[i].x = 0; // Keep segments centered relative to fishing line
}
Rubber Hose Style Blue Fish. In-Game asset. 2d. High contrast. No shadows
Rubber Hose Style Green Medium-Sized fish. In-Game asset. 2d. High contrast. No shadows
Rubber Hose Style Orange Happy Fish. In-Game asset. 2d. High contrast. No shadows
Rubber Hose Style Swimming pose Shark. It's Angry. In-Game asset. 2d. High contrast. No shadows
Rubber Hose Style octopus. In-Game asset. 2d. High contrast. No shadows