User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var buttonBounds = LK.gui.topRight.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 610
User prompt
Oltanı atmak için tuş olsun
User prompt
Please fix the bug: 'setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 492
User prompt
Rüzgar bulut ve güneş olsun havada ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Daşlar denizin derinliklerinde oldun ve büyük olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Denizin altında daşlar ve yosunlar olsun
User prompt
Balıkların gözlerini düzelt
User prompt
Varlıkların gözleri olsun
User prompt
Oltanı günzəllə, aşağı qədər atmaq olsun, çox dərinliklər atmaq olsun. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
gemiye hareket ettirmek olsun ve balıklar çoğalsın yani çok balık olsun büyük küçük daha büyük ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İnsan sadece gemiden balık tutabilsin.
User prompt
Gemi olsun, gemi için insan olsun işte. Balıklar her renkte olsun. İnsan tutuyor işte onu.
User prompt
Please fix the bug: 'TypeError: self.hop is not a function' in or related to this line: 'var originalY = self.y;' Line Number: 134
User prompt
Please fix the bug: 'TypeError: self.hop is not a function' in or related to this line: 'self.hop();' Line Number: 134
Code edit (1 edits merged)
Please save this source code
User prompt
Frog Lake Fishing
Initial prompt
Balık tutmak için göl olsun, oltu olsun, birkaç kurbağa falan olsun ve balıklar olsun.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Fish = Container.expand(function (fishType) {
var self = Container.call(this);
var fishGraphics;
if (fishType === 'small') {
fishGraphics = self.attachAsset('fishSmall', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 10;
self.speed = 2;
} else if (fishType === 'medium') {
fishGraphics = self.attachAsset('fishMedium', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 25;
self.speed = 1.5;
} else if (fishType === 'red') {
fishGraphics = self.attachAsset('fishRed', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 15;
self.speed = 1.8;
} else if (fishType === 'green') {
fishGraphics = self.attachAsset('fishGreen', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 20;
self.speed = 1.6;
} else if (fishType === 'yellow') {
fishGraphics = self.attachAsset('fishYellow', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 12;
self.speed = 2.2;
} else if (fishType === 'purple') {
fishGraphics = self.attachAsset('fishPurple', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 30;
self.speed = 1.4;
} else {
fishGraphics = self.attachAsset('fishLarge', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 50;
self.speed = 1;
}
self.direction = Math.random() > 0.5 ? 1 : -1;
self.fishType = fishType;
self.caught = false;
if (self.direction === -1) {
fishGraphics.scaleX = -1;
}
self.update = function () {
if (!self.caught) {
self.x += self.speed * self.direction;
self.y += Math.sin(LK.ticks * 0.02 + self.x * 0.01) * 0.5;
}
};
return self;
});
var FishingLine = Container.expand(function () {
var self = Container.call(this);
var lineGraphics = self.attachAsset('fishingLine', {
anchorX: 0.5,
anchorY: 0
});
var hookGraphics = self.attachAsset('hook', {
anchorX: 0.5,
anchorY: 0.5
});
self.isActive = false;
self.targetDepth = 0;
self.currentDepth = 0;
self.castPosition = 0;
lineGraphics.height = 10;
hookGraphics.y = 10;
hookGraphics.visible = false;
function castLine(x, targetY) {
self.isActive = true;
self.x = x;
self.castPosition = x;
self.targetDepth = targetY - 400;
self.currentDepth = 0;
hookGraphics.visible = true;
hookGraphics.y = 0;
tween(self, {
currentDepth: self.targetDepth
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
LK.getSound('splash').play();
}
});
}
function reelIn() {
if (self.isActive) {
tween(self, {
currentDepth: 0
}, {
duration: 800,
easing: tween.easeIn,
onFinish: function onFinish() {
self.isActive = false;
hookGraphics.visible = false;
lineGraphics.height = 10;
}
});
}
}
self.cast = castLine;
self.reel = reelIn;
self.update = function () {
if (self.isActive) {
lineGraphics.height = self.currentDepth + 10;
hookGraphics.y = self.currentDepth;
}
};
return self;
});
var Frog = Container.expand(function () {
var self = Container.call(this);
var frogGraphics = self.attachAsset('frog', {
anchorX: 0.5,
anchorY: 0.5
});
self.hopTimer = 0;
self.hopDelay = Math.random() * 180 + 120;
self.isHopping = false;
self.hop = function () {
self.isHopping = true;
var targetX = Math.random() * 1800 + 124;
var originalY = self.y;
tween(self, {
x: targetX,
y: originalY - 30
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
y: originalY
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
self.isHopping = false;
self.hopTimer = 0;
self.hopDelay = Math.random() * 180 + 120;
}
});
}
});
};
self.update = function () {
self.hopTimer++;
if (self.hopTimer >= self.hopDelay && !self.isHopping) {
self.hop();
}
};
return self;
});
var Ship = Container.expand(function () {
var self = Container.call(this);
var shipGraphics = self.attachAsset('ship', {
anchorX: 0.5,
anchorY: 1
});
var mastGraphics = self.attachAsset('mast', {
anchorX: 0.5,
anchorY: 1
});
mastGraphics.x = -50;
mastGraphics.y = -120;
var personGraphics = self.attachAsset('person', {
anchorX: 0.5,
anchorY: 1
});
personGraphics.x = 30;
personGraphics.y = -120;
self.bobTimer = 0;
self.originalY = 0;
self.update = function () {
self.bobTimer += 0.02;
self.y = self.originalY + Math.sin(self.bobTimer) * 3;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var waterBackground = game.addChild(LK.getAsset('water', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 400
}));
var ship = game.addChild(new Ship());
ship.x = 1024;
ship.y = 400;
ship.originalY = 400;
var fishingLine = game.addChild(new FishingLine());
fishingLine.y = 350;
var fish = [];
var frogs = [];
var lilyPads = [];
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var instructionText = new Text2('Tap to cast line, tap again to reel in!', {
size: 40,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 1);
instructionText.y = -20;
LK.gui.bottom.addChild(instructionText);
// Create lily pads
for (var i = 0; i < 8; i++) {
var lilyPad = game.addChild(LK.getAsset('lilyPad', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 1800 + 124,
y: Math.random() * 200 + 450
}));
lilyPads.push(lilyPad);
}
// Create frogs
for (var i = 0; i < 4; i++) {
var frog = game.addChild(new Frog());
frog.x = Math.random() * 1800 + 124;
frog.y = 380;
frogs.push(frog);
}
var fishSpawnTimer = 0;
var gameStarted = false;
function spawnFish() {
var fishTypes = ['small', 'small', 'medium', 'large', 'red', 'green', 'yellow', 'purple'];
var randomType = fishTypes[Math.floor(Math.random() * fishTypes.length)];
var newFish = new Fish(randomType);
var spawnSide = Math.random() > 0.5;
if (spawnSide) {
newFish.x = -100;
newFish.direction = 1;
} else {
newFish.x = 2148;
newFish.direction = -1;
}
newFish.y = Math.random() * 1000 + 600;
fish.push(newFish);
game.addChild(newFish);
}
function checkFishCatch() {
if (!fishingLine.isActive) return;
var hookX = fishingLine.x;
var hookY = fishingLine.y + fishingLine.currentDepth;
for (var i = fish.length - 1; i >= 0; i--) {
var currentFish = fish[i];
if (currentFish.caught) continue;
var distance = Math.sqrt(Math.pow(hookX - currentFish.x, 2) + Math.pow(hookY - currentFish.y, 2));
if (distance < 40) {
currentFish.caught = true;
LK.setScore(LK.getScore() + currentFish.points);
scoreText.setText('Score: ' + LK.getScore());
LK.getSound('catch').play();
tween(currentFish, {
alpha: 0,
scaleX: 1.5 * (currentFish.direction === -1 ? -1 : 1),
scaleY: 1.5
}, {
duration: 500,
onFinish: function onFinish() {
currentFish.destroy();
}
});
fish.splice(i, 1);
fishingLine.reel();
break;
}
}
}
game.down = function (x, y, obj) {
if (!fishingLine.isActive) {
fishingLine.cast(x, y);
gameStarted = true;
} else {
fishingLine.reel();
}
};
game.update = function () {
if (!gameStarted) return;
fishSpawnTimer++;
if (fishSpawnTimer >= 120) {
spawnFish();
fishSpawnTimer = 0;
}
// Clean up fish that have moved off screen
for (var i = fish.length - 1; i >= 0; i--) {
var currentFish = fish[i];
if (currentFish.x < -150 || currentFish.x > 2200) {
if (!currentFish.caught) {
currentFish.destroy();
fish.splice(i, 1);
}
}
}
checkFishCatch();
}; ===================================================================
--- original.js
+++ change.js
@@ -22,8 +22,36 @@
anchorY: 0.5
});
self.points = 25;
self.speed = 1.5;
+ } else if (fishType === 'red') {
+ fishGraphics = self.attachAsset('fishRed', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.points = 15;
+ self.speed = 1.8;
+ } else if (fishType === 'green') {
+ fishGraphics = self.attachAsset('fishGreen', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.points = 20;
+ self.speed = 1.6;
+ } else if (fishType === 'yellow') {
+ fishGraphics = self.attachAsset('fishYellow', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.points = 12;
+ self.speed = 2.2;
+ } else if (fishType === 'purple') {
+ fishGraphics = self.attachAsset('fishPurple', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.points = 30;
+ self.speed = 1.4;
} else {
fishGraphics = self.attachAsset('fishLarge', {
anchorX: 0.5,
anchorY: 0.5
@@ -146,8 +174,34 @@
}
};
return self;
});
+var Ship = Container.expand(function () {
+ var self = Container.call(this);
+ var shipGraphics = self.attachAsset('ship', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ var mastGraphics = self.attachAsset('mast', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ mastGraphics.x = -50;
+ mastGraphics.y = -120;
+ var personGraphics = self.attachAsset('person', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ personGraphics.x = 30;
+ personGraphics.y = -120;
+ self.bobTimer = 0;
+ self.originalY = 0;
+ self.update = function () {
+ self.bobTimer += 0.02;
+ self.y = self.originalY + Math.sin(self.bobTimer) * 3;
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -163,8 +217,12 @@
anchorY: 0,
x: 0,
y: 400
}));
+var ship = game.addChild(new Ship());
+ship.x = 1024;
+ship.y = 400;
+ship.originalY = 400;
var fishingLine = game.addChild(new FishingLine());
fishingLine.y = 350;
var fish = [];
var frogs = [];
@@ -201,9 +259,9 @@
}
var fishSpawnTimer = 0;
var gameStarted = false;
function spawnFish() {
- var fishTypes = ['small', 'small', 'medium', 'large'];
+ var fishTypes = ['small', 'small', 'medium', 'large', 'red', 'green', 'yellow', 'purple'];
var randomType = fishTypes[Math.floor(Math.random() * fishTypes.length)];
var newFish = new Fish(randomType);
var spawnSide = Math.random() > 0.5;
if (spawnSide) {