User prompt
skor 100 olduktan sonra kırmızı balıklar çoğalsın
User prompt
bir skor sistemi ekle, her bir balık yediğimizde 1 er artsın. Her 10 skorda mavi balıkların hızı artsın
User prompt
oyunda iken mouse imlecini yok et
User prompt
kırmızı renkte balıklar da ekle ve bunları yediğimizde karakterimiz küçülsün
User prompt
karakter aşağı ve yukarıda hareket etsin
User prompt
balık yedikçe büyüsün
User prompt
my character eat fish
User prompt
ı want up and down control
User prompt
my character mouse control with movement
User prompt
my character is shark
User prompt
make ocean and make fish
User prompt
Deniz Ortasında Yüzücü
Initial prompt
sadece bir karakter yap, denizin ortasında yüzsün
/**** * Classes ****/ // Fish class: represents a single fish swimming in the ocean var Fish = Container.expand(function () { var self = Container.call(this); // Create a simple ellipse as the fish var fishAsset = self.attachAsset('fish', { width: 120, height: 60, color: 0xffcc66, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); // Randomize initial position and speed self.x = Math.random() * 2048; self.y = 400 + Math.random() * 1800; self.speed = 2 + Math.random() * 3; // Track lastX for edge detection self.lastX = self.x; // Fish swims to the right, loops back to left when off screen self.update = function () { self.lastX = self.x; self.x += self.speed; if (self.lastX <= 2048 && self.x > 2048) { self.x = -100; self.y = 400 + Math.random() * 1800; self.speed = 2 + Math.random() * 3; } }; return self; }); var Ocean = Container.expand(function () { var self = Container.call(this); // Create a large blue rectangle as the ocean background var oceanAsset = self.attachAsset('ocean', { width: 2048, height: 2732, color: 0x3399ff, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); return self; }); // RedFish class: represents a red fish that shrinks the shark var RedFish = Container.expand(function () { var self = Container.call(this); // Attach red fish asset var redFishAsset = self.attachAsset('redfish', { width: 120, height: 60, color: 0xd83318, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); // Randomize initial position and speed self.x = Math.random() * 2048; self.y = 400 + Math.random() * 1800; self.speed = 2 + Math.random() * 3; // Track lastX for edge detection self.lastX = self.x; // Red fish swims to the right, loops back to left when off screen self.update = function () { self.lastX = self.x; self.x += self.speed; if (self.lastX <= 2048 && self.x > 2048) { self.x = -100; self.y = 400 + Math.random() * 1800; self.speed = 2 + Math.random() * 3; } }; return self; }); // Shark class: represents the main character (shark) swimming in the ocean var Shark = Container.expand(function () { var self = Container.call(this); // Attach a shark asset (box for now, can be replaced with a shark image asset) var sharkAsset = self.attachAsset('shark', { width: 220, height: 100, color: 0x444444, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); // Start in the center of the ocean self.x = 1024; self.y = 1366; // Track lastX and lastY for possible future movement logic self.lastX = self.x; self.lastY = self.y; // Shark update: just track lastX/lastY for drag movement self.update = function () { self.lastX = self.x; self.lastY = self.y; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Hide the mouse cursor during gameplay if (typeof LK.setCursor === "function") { LK.setCursor("none"); } else if (typeof stage !== "undefined" && stage.view && stage.view.style) { stage.view.style.cursor = "none"; } // Add ocean background var ocean = new Ocean(); game.addChild(ocean); // Score system var score = 0; var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.x = LK.gui.top.width / 2; scoreTxt.y = 10; // Add several fish swimming in the ocean var fishArray = []; for (var i = 0; i < 7; i++) { var fish = new Fish(); fishArray.push(fish); game.addChild(fish); } // Add the shark character to the game var shark = new Shark(); game.addChild(shark); // Add several red fish swimming in the ocean var redFishArray = []; for (var i = 0; i < 3; i++) { var redFish = new RedFish(); redFishArray.push(redFish); game.addChild(redFish); } // Mouse/touch drag control for shark var draggingShark = false; // Handle drag start game.down = function (x, y, obj) { // Check if the press is on the shark (simple bounding box check) var dx = x - shark.x; var dy = y - shark.y; // Use shark asset size for hit area var halfW = 0.5 * shark.width; var halfH = 0.5 * shark.height; if (dx >= -halfW && dx <= halfW && dy >= -halfH && dy <= halfH) { draggingShark = true; // Move shark immediately to touch point shark.x = x; shark.y = y; } }; // Handle drag move game.move = function (x, y, obj) { if (draggingShark) { shark.x = x; shark.y = y; } }; // Handle drag end game.up = function (x, y, obj) { draggingShark = false; }; // Update fish and shark positions every frame game.update = function () { // Blue fish logic (grow) for (var i = 0; i < fishArray.length; i++) { var fish = fishArray[i]; fish.update(); // Track lastWasIntersecting for each fish if (typeof fish.lastWasIntersecting === "undefined") { fish.lastWasIntersecting = false; } var isIntersecting = shark.intersects(fish); // If shark just started intersecting with this fish, "eat" it if (!fish.lastWasIntersecting && isIntersecting) { // Move fish to a new random position and speed fish.x = -100; fish.y = 400 + Math.random() * 1800; fish.speed = 2 + Math.random() * 3; // Increment score and update display score++; scoreTxt.setText(score + ""); // Grow the shark a bit each time it eats a fish if (typeof shark._scaleX === "undefined") { shark._scaleX = 1; shark._scaleY = 1; } // Increase scale by 5% per fish eaten shark._scaleX *= 1.05; shark._scaleY *= 1.05; // Clamp max scale to avoid infinite growth if (shark._scaleX > 3) shark._scaleX = 3; if (shark._scaleY > 3) shark._scaleY = 3; shark.scaleX = shark._scaleX; shark.scaleY = shark._scaleY; } fish.lastWasIntersecting = isIntersecting; } // Increase blue fish speed every 10 score if (score > 0 && score % 10 === 0 && typeof game.lastSpeedUpScore !== "number") { for (var s = 0; s < fishArray.length; s++) { fishArray[s].speed += 1; } game.lastSpeedUpScore = score; } if (score % 10 !== 0) { game.lastSpeedUpScore = undefined; } // Red fish logic (shrink) for (var j = 0; j < redFishArray.length; j++) { var redFish = redFishArray[j]; redFish.update(); if (typeof redFish.lastWasIntersecting === "undefined") { redFish.lastWasIntersecting = false; } var isRedIntersecting = shark.intersects(redFish); // If shark just started intersecting with this red fish, "eat" it and shrink if (!redFish.lastWasIntersecting && isRedIntersecting) { // Move red fish to a new random position and speed redFish.x = -100; redFish.y = 400 + Math.random() * 1800; redFish.speed = 2 + Math.random() * 3; // Shrink the shark a bit each time it eats a red fish if (typeof shark._scaleX === "undefined") { shark._scaleX = 1; shark._scaleY = 1; } // Decrease scale by 10% per red fish eaten shark._scaleX *= 0.90; shark._scaleY *= 0.90; // Clamp min scale to avoid disappearing if (shark._scaleX < 0.4) shark._scaleX = 0.4; if (shark._scaleY < 0.4) shark._scaleY = 0.4; shark.scaleX = shark._scaleX; shark.scaleY = shark._scaleY; } redFish.lastWasIntersecting = isRedIntersecting; } // After score reaches 100, increase the number of red fish if not already done if (score >= 100 && !game.redFishIncreased) { // Add 5 more red fish for (var add = 0; add < 5; add++) { var extraRedFish = new RedFish(); redFishArray.push(extraRedFish); game.addChild(extraRedFish); } game.redFishIncreased = true; } // Always update shark to track lastX/lastY for movement shark.update(); };
===================================================================
--- original.js
+++ change.js
@@ -251,7 +251,17 @@
shark.scaleY = shark._scaleY;
}
redFish.lastWasIntersecting = isRedIntersecting;
}
+ // After score reaches 100, increase the number of red fish if not already done
+ if (score >= 100 && !game.redFishIncreased) {
+ // Add 5 more red fish
+ for (var add = 0; add < 5; add++) {
+ var extraRedFish = new RedFish();
+ redFishArray.push(extraRedFish);
+ game.addChild(extraRedFish);
+ }
+ game.redFishIncreased = true;
+ }
// Always update shark to track lastX/lastY for movement
shark.update();
};
\ No newline at end of file