Code edit (1 edits merged)
Please save this source code
User prompt
In grow() also update collisionBody y
Code edit (4 edits merged)
Please save this source code
User prompt
In grow() also update collisionBody x
User prompt
collisionBody Is a circle so update the width equally
User prompt
Also update collisionBody to half of the new height
User prompt
In grow(), update currentWidth and use heightRatio
Code edit (1 edits merged)
Please save this source code
User prompt
In Baby Shark class, define a property for height ratio = 124/200
User prompt
In Baby Shark class, define a property for currentSize
Code edit (1 edits merged)
Please save this source code
User prompt
Define collisionBody width and height to 95
User prompt
Move collision body to the right third
User prompt
Add a public collisionBody to baby shark, use collisionBody asset
User prompt
Set collisionBody as a public property
User prompt
Add collisionBody to baby shark, use collisionBody asset
Code edit (2 edits merged)
Please save this source code
User prompt
Just Add an isDebug global for debugging mode
User prompt
Add an isDebug global for debugging
Code edit (1 edits merged)
Please save this source code
User prompt
Group all global variables declarations In one place
User prompt
Group global variables declarations
User prompt
Remove useless assignations … = null; in global scope
Code edit (5 edits merged)
Please save this source code
User prompt
In baby shark grow, add 50 to width and height instead of using scale
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Baby Shark class var BabyShark = Container.expand(function () { var self = Container.call(this); self.currentWidth = 200; // Initialize currentSize property self.heightRatio = 124 / 200; // Define height ratio property self.speed = 10; self.velocityY = 0; var sharkGraphics = self.attachAsset('babyShark', { anchorX: 0.5, anchorY: 0.5 }); self.collisionBody = self.attachAsset('collisionBody', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7, x: sharkGraphics.width * 0.3, y: sharkGraphics.height * 0.1, width: 62, height: 62 }); self.update = function () { self.velocityY += 0.4; // 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.currentWidth += 50; self.width = self.currentWidth; self.height = self.currentWidth * self.heightRatio; self.collisionBody.width = self.height / 2; self.collisionBody.height = self.height / 2; self.collisionBody.x = self.width / 3; self.collisionBody.y = self.height / 3; }; }); // 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.collided = false; 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 isDebug = true; // Global variable for debugging mode var sharkLevel = 1; var currentProgress = 0; function spawnFish() { if (LK.ticks % 60 == 0) { spawnSmallFish(); } if (LK.ticks % 180 == 0) { spawnFish2(); } } function updateFish2Collisions() { 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(); } } } } function updateFish1Collisions() { var offset = 300; // Define the x offset range for (var i = fish1s.length - 1; i >= 0; i--) { if (Math.abs(babyShark.x - fish1s[i].x) > offset) { continue; // Skip fishes outside the x offset range } if (!fish1s[i].collided && babyShark.intersects(fish1s[i])) { fish1s[i].collided = true; score += 10; scoreTxt.setText(score); currentProgress += 1; currentProgressTxt.setText(currentProgress + "/10"); if (currentProgress > 9) { sharkLevel += 1; currentProgress = 0; babyShark.grow(); } fish1s[i].destroy(); fish1s.splice(i, 1); } } } function updateBackgrounds() { 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; } } var background1; function gameInitialize() { background1 = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2732 / 2, y: 2732 / 2 }); background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5, x: 2732 + 2732 / 2, y: 2732 / 2 }); game.addChild(background1); game.addChild(background2); babyShark = game.addChild(new BabyShark()); babyShark.x = 150; babyShark.y = 2732 / 2; babyShark.velocityY = 0; babyShark.collisionBody.visible = isDebug; // Show collision body if debugging fish1s = []; fish2s = []; score = 0; scoreTxt = new Text2('0', { size: 100, fill: "#ffffff", dropShadow: true, dropShadowColor: "#000000", dropShadowBlur: 4, dropShadowDistance: 6 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); currentProgress = 0; currentProgressTxt = new Text2('0/10', { size: 100, fill: "#ffffff", dropShadow: true, dropShadowColor: "#000000", dropShadowBlur: 4, dropShadowDistance: 6 }); currentProgressTxt.anchor.set(1, 0); LK.gui.topRight.addChild(currentProgressTxt); } //background2.scale.x = -1; var babyShark; var fish1s; var fish2s; var score; var scoreTxt; var currentProgressTxt; 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.velocityY = -20; }; game.update = function () { updateBackgrounds(); updateFish1Collisions(); updateFish2Collisions(); spawnFish(); }; gameInitialize();
===================================================================
--- original.js
+++ change.js
@@ -41,8 +41,9 @@
self.height = self.currentWidth * self.heightRatio;
self.collisionBody.width = self.height / 2;
self.collisionBody.height = self.height / 2;
self.collisionBody.x = self.width / 3;
+ self.collisionBody.y = self.height / 3;
};
});
// Fish1 class
var Fish1 = Container.expand(function () {
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.