User prompt
Change score fill to black
Code edit (1 edits merged)
Please save this source code
User prompt
Continue moving initialisation code to gameInitialize
User prompt
Move gameInitialize call to the bottom of the code
User prompt
Move gameInitialize call to be the last instruction
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: background2' in or related to this line: 'background2.x -= 2;' Line Number: 118
User prompt
Move initialisations in a gameInitialize function
User prompt
In global scope, separate declarations and initialisations
Code edit (1 edits merged)
Please save this source code
User prompt
Rework game update with topic dedicated functions
User prompt
Add 50 to player x
User prompt
Player should start at the middle of the screen Vertically
User prompt
Player should start at the middle of the screen
User prompt
When baby shark touches a bigger fish, if fish’s first third has passed baby shark x then baby shark bounces on it , if not, a life is lost
Code edit (1 edits merged)
Please save this source code
User prompt
Use 2732 instead of 2048 for backgrounds width
Code edit (1 edits merged)
Please save this source code
User prompt
no way :( so create a new background2 asset
Code edit (1 edits merged)
Please save this source code
User prompt
Fix background2 because it’s still not reversed horizontally!!!
User prompt
Fix background2 because it’s still not reversed horizontally
User prompt
Fix background2 scale because scale.set(-1, 1) doesn’t work
User prompt
Try something different
User prompt
Fix background2.scale.x = -1; it doesn’t work
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Baby Shark class var BabyShark = Container.expand(function () { var self = Container.call(this); var sharkGraphics = self.attachAsset('babyShark', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.velocityY = 0; self.update = function () { self.velocityY += 0.2; // Further reduced gravity effect self.y += self.velocityY; if (self.y > 2732 - self.height / 2) { self.y = 2732 - self.height / 2; self.velocityY = 0; } if (self.y < self.height / 2) { self.y = self.height / 2; self.velocityY = 0; } // Update logic for Baby Shark }; self.grow = function () { self.scaleX += 0.1; self.scaleY += 0.1; }; }); // Fish1 class var Fish1 = Container.expand(function () { var self = Container.call(this); var fishGraphics = self.attachAsset('fish1', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.x -= self.speed; if (self.x < -self.width) { self.destroy(); } }; }); // Fish2 class var Fish2 = Container.expand(function () { var self = Container.call(this); var fishGraphics = self.attachAsset('fish2', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.x -= self.speed; if (self.x < -self.width) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0000ff // Init game with blue background }); /**** * Game Code ****/ var background1 = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2732 / 2, y: 2732 / 2 }); var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5, x: 2732 + 2732 / 2, y: 2732 / 2 }); game.addChild(background1); game.addChild(background2); //background2.scale.x = -1; var babyShark = game.addChild(new BabyShark()); babyShark.x = 2048 / 2; babyShark.y = 2732 / 2; babyShark.velocityY = 0; var fish1s = []; var fish2s = []; var score = 0; var scoreTxt = new Text2('Score: 0', { size: 100, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); function spawnSmallFish() { var smallFish = new Fish1(); smallFish.x = 2048 + 50; smallFish.y = Math.random() * (2732 - smallFish.height) + smallFish.height / 2; fish1s.push(smallFish); game.addChild(smallFish); } function spawnFish2() { var fish2 = new Fish2(); fish2.x = 2048 + 50; fish2.y = Math.random() * (2732 - fish2.height) + fish2.height / 2; fish2s.push(fish2); game.addChild(fish2); } game.down = function (x, y, obj) { // babyShark.x = x; babyShark.velocityY = -10; }; game.move = function (x, y, obj) { // babyShark.x = x; // babyShark.y = y; }; game.update = function () { babyShark.update(); background1.x -= 2; background2.x -= 2; if (background1.x <= -2732 / 2) { background1.x = 2732 + 2732 / 2; } if (background2.x <= -2732 / 2) { background2.x = 2732 + 2732 / 2; } for (var i = fish1s.length - 1; i >= 0; i--) { if (babyShark.intersects(fish1s[i])) { babyShark.grow(); score += 10; scoreTxt.setText('Score: ' + score); fish1s[i].destroy(); fish1s.splice(i, 1); } } for (var j = fish2s.length - 1; j >= 0; j--) { if (babyShark.intersects(fish2s[j])) { if (fish2s[j].x - fish2s[j].width / 3 > babyShark.x) { // Bounce baby shark off the bigger fish babyShark.velocityY = -10; babyShark.x -= 50; // Move baby shark back a bit } else { // Lose a life LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } } if (LK.ticks % 60 == 0) { spawnSmallFish(); } if (LK.ticks % 180 == 0) { spawnFish2(); } };
===================================================================
--- original.js
+++ change.js
@@ -85,10 +85,10 @@
game.addChild(background1);
game.addChild(background2);
//background2.scale.x = -1;
var babyShark = game.addChild(new BabyShark());
-babyShark.x = 100;
-babyShark.y = 2732 - 200;
+babyShark.x = 2048 / 2;
+babyShark.y = 2732 / 2;
babyShark.velocityY = 0;
var fish1s = [];
var fish2s = [];
var score = 0;
Orange Baby fish lateral view. 2024 game style
Pink Baby fish lateral view. 2024 game style
Empty Under water. water only. 2024 game style
Cute Baby shark.. . 2024 game style. Side view. Photorealistic
Classic fish lateral view.. 2024 game style
Classic fish with fangs lateral view.. 2024 game style. Photorealistic
Classic fish with fangs mouth closed lateral view.. 2024 game style. Photorealistic. Full side view.
Cachalot. Horizontal closed lateral view.... 2024 game style. Photorealistic. Full side view.
Straight horizontal Orca. Mouth open. 2024 game style. Photorealistic. Full side view
Start button in the shape of a shark mouth.
beluga swimming mouth open. 2024 game style. Photorealistic. Entire lateral profile view, perfectly horizontal.
North Pacific right whale. Horizontal complete lateral view..... 2024 game style. Photorealistic. Full side view.
Decomposition of Horizontal Swimming movement of a woman with a snorkel.. 2024 game style. 2 frames sprite sheet. Photorealistic
Very minimalist skeleton of a fish with a fin and cute shark head... 2d. Black background. High contrast. No shadows.