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; }); // 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 floats gently up and down (idle animation) self._swimTick = 0; self.update = function () { self.lastX = self.x; self.lastY = self.y; self._swimTick++; // Gentle up and down motion self.y = 1366 + Math.sin(self._swimTick / 60) * 40; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Add ocean background var ocean = new Ocean(); game.addChild(ocean); // 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); // Update fish and shark positions every frame game.update = function () { for (var i = 0; i < fishArray.length; i++) { fishArray[i].update(); } shark.update(); };
===================================================================
--- original.js
+++ change.js
@@ -45,8 +45,37 @@
y: 0
});
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 floats gently up and down (idle animation)
+ self._swimTick = 0;
+ self.update = function () {
+ self.lastX = self.x;
+ self.lastY = self.y;
+ self._swimTick++;
+ // Gentle up and down motion
+ self.y = 1366 + Math.sin(self._swimTick / 60) * 40;
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -66,10 +95,14 @@
var fish = new Fish();
fishArray.push(fish);
game.addChild(fish);
}
-// Update fish positions every frame
+// Add the shark character to the game
+var shark = new Shark();
+game.addChild(shark);
+// Update fish and shark positions every frame
game.update = function () {
for (var i = 0; i < fishArray.length; i++) {
fishArray[i].update();
}
+ shark.update();
};
\ No newline at end of file