User prompt
add a start screen and make it have a nice design ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add record score counter ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add ocean background with water gradient and lighting effects Add OceanBackground class for water animations and effects Initialize ocean background in game setup Update game variables to include ocean background Update game update loop to include ocean background animations
User prompt
make background: blue realistic pixel ocen , Add ocean background with water gradient and lighting effects
User prompt
realistic pixel ocean background
User prompt
Reduce your width by 10 hight by 5 when you get a goldenfish
User prompt
Reduce your width by 20 hight by 10 when you get a goldenfish ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Reduce your size by 20 when you get a goldenfish
User prompt
Reduce your width and height by 30 when you get a goldenfish
User prompt
Reduce your width and height by 15 when you get a goldenfish
User prompt
Increase your widht and hight by 15 when you get a goldenfish
User prompt
Increase your health by 15 when you get a power-up
User prompt
Increase your health by 10 when you get a power-up
User prompt
fix,
User prompt
Hungry Shark Attack
Initial prompt
bir köpek balığı oyunu
/**** * Classes ****/ var Fish = Container.expand(function (type, speed) { var self = Container.call(this); self.type = type || 'smallFish'; self.speed = speed || 2; self.value = 1; self.lastY = 0; if (self.type === 'smallFish') { self.value = 1; self.danger = 0; } else if (self.type === 'mediumFish') { self.value = 2; self.danger = 0.5; } else if (self.type === 'largeFish') { self.value = 4; self.danger = 1; } else if (self.type === 'goldenFish') { self.value = 10; self.danger = 0; } var fishGraphics = self.attachAsset(self.type, { anchorX: 0.5, anchorY: 0.5 }); self.direction = Math.random() > 0.5 ? 1 : -1; fishGraphics.scale.x = self.direction; self.update = function () { self.lastY = self.y; self.x += self.speed * self.direction; // Wrap around screen if (self.x < -100 && self.direction < 0) { self.x = 2148; } else if (self.x > 2148 && self.direction > 0) { self.x = -100; } }; return self; }); var Obstacle = Container.expand(function (speed) { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = speed || 1; self.damage = 10; self.lastY = 0; self.update = function () { self.lastY = self.y; self.y += self.speed; // Remove if off screen if (self.y > 2832) { self.shouldRemove = true; } }; return self; }); var OceanBackground = Container.expand(function () { var self = Container.call(this); // Main ocean background var bgGraphics = self.attachAsset('oceanBg', { anchorX: 0, anchorY: 0 }); // Ocean floor var floorGraphics = self.attachAsset('oceanFloor', { anchorX: 0, anchorY: 1 }); floorGraphics.y = 2732; // Water surface with transparency var surfaceGraphics = self.attachAsset('waterSurface', { anchorX: 0, anchorY: 0 }); surfaceGraphics.y = 0; surfaceGraphics.alpha = 0.7; // Light rays var lights = []; for (var i = 0; i < 3; i++) { var light = self.attachAsset('lightRay', { anchorX: 0.5, anchorY: 0 }); light.x = 400 + Math.random() * 1200; light.y = 0; light.alpha = 0.2 + Math.random() * 0.2; light.scale.set(0.7 + Math.random() * 0.6); lights.push(light); } // Bubbles var bubbles = []; for (var i = 0; i < 15; i++) { spawnBubble(); } function spawnBubble() { var bubble = self.attachAsset('bubbles', { anchorX: 0.5, anchorY: 0.5 }); bubble.x = Math.random() * 2048; bubble.y = 500 + Math.random() * 2200; bubble.alpha = 0.3 + Math.random() * 0.5; bubble.scale.set(0.3 + Math.random() * 0.7); bubble.speed = 0.5 + Math.random() * 1.5; bubble.wobbleSpeed = 0.01 + Math.random() * 0.03; bubble.wobbleAmount = 0 + Math.random() * 30; bubble.wobbleOffset = Math.random() * Math.PI * 2; bubbles.push(bubble); } self.update = function () { // Update bubbles for (var i = bubbles.length - 1; i >= 0; i--) { var bubble = bubbles[i]; bubble.y -= bubble.speed; bubble.x += Math.sin(LK.ticks * bubble.wobbleSpeed + bubble.wobbleOffset) * 0.3; // If bubble reaches surface, respawn it if (bubble.y < 100) { bubble.destroy(); bubbles.splice(i, 1); spawnBubble(); } } // Gentle animation for water surface surfaceGraphics.y = Math.sin(LK.ticks * 0.02) * 5; // Animate light rays for (var i = 0; i < lights.length; i++) { var light = lights[i]; light.alpha = 0.2 + Math.sin(LK.ticks * 0.01 + i) * 0.1; } }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); var powerupGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.type = Math.random() > 0.5 ? 'speed' : 'invincibility'; self.speed = 1; self.lastY = 0; self.update = function () { self.lastY = self.y; self.y += self.speed; // Simple animation self.rotation += 0.02; // Remove if off screen if (self.y > 2832) { self.shouldRemove = true; } }; return self; }); // Set ocean blue background var Shark = Container.expand(function () { var self = Container.call(this); var sharkGraphics = self.attachAsset('shark', { anchorX: 0.5, anchorY: 0.5 }); self.size = 1; self.speed = 5; self.health = 100; self.oxygen = 100; self.score = 0; self.lastX = 0; self.lastY = 0; self.facing = 1; // 1 = right, -1 = left self.update = function () { self.lastX = self.x; self.lastY = self.y; // Reduce oxygen when deep in the ocean (upper part of the screen is surface) if (self.y > 1000) { self.oxygen -= 0.2; if (self.oxygen <= 0) { self.health -= 0.5; } } else { // Replenish oxygen near the surface self.oxygen = Math.min(100, self.oxygen + 0.5); } // Update scale based on size self.scale.set(self.size); // Flip shark graphic based on direction if (self.facing === 1) { sharkGraphics.scale.x = Math.abs(sharkGraphics.scale.x); } else { sharkGraphics.scale.x = -Math.abs(sharkGraphics.scale.x); } }; self.grow = function (amount) { self.size += amount; self.score += Math.round(amount * 10); }; self.takeDamage = function (amount) { self.health -= amount; LK.getSound('damage').play(); LK.effects.flashObject(self, 0xff0000, 500); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Background is now handled by the OceanBackground class // Game variables var shark; var fishes = []; var obstacles = []; var powerUps = []; var lastIntersectingFish = {}; var lastIntersectingObstacle = {}; var lastIntersectingPowerUp = {}; var gameActive = true; var powerUpActive = false; var powerUpTimer = 0; var spawnTimer = 0; var difficultyTimer = 0; var difficulty = 1; var maxFishes = 10; var dragNode = null; var oceanBackground; // UI elements var scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); LK.gui.topLeft.addChild(scoreText); scoreText.x = 120; scoreText.y = 20; var healthBarBg = LK.getAsset('healthBg', { anchorX: 0, anchorY: 0.5, x: 120, y: 100 }); LK.gui.topLeft.addChild(healthBarBg); var healthBarFill = LK.getAsset('healthBar', { anchorX: 0, anchorY: 0.5, x: 120, y: 100 }); LK.gui.topLeft.addChild(healthBarFill); var oxygenBarBg = LK.getAsset('oxygenBg', { anchorX: 0, anchorY: 0.5, x: 120, y: 150 }); LK.gui.topLeft.addChild(oxygenBarBg); var oxygenBarFill = LK.getAsset('oxygen', { anchorX: 0, anchorY: 0.5, x: 120, y: 150 }); LK.gui.topLeft.addChild(oxygenBarFill); // Initialize shark function initGame() { // Create ocean background var oceanBg = new OceanBackground(); game.addChild(oceanBg); // Create shark shark = new Shark(); shark.x = 2048 / 2; shark.y = 2732 / 2; game.addChild(shark); // Reset variables fishes = []; obstacles = []; powerUps = []; lastIntersectingFish = {}; lastIntersectingObstacle = {}; lastIntersectingPowerUp = {}; gameActive = true; powerUpActive = false; powerUpTimer = 0; spawnTimer = 0; difficultyTimer = 0; difficulty = 1; LK.setScore(0); // Spawn initial fish for (var i = 0; i < 5; i++) { spawnFish(); } } // Spawn a new fish function spawnFish() { var fishType; var rand = Math.random(); if (rand < 0.05) { fishType = 'goldenFish'; } else if (rand < 0.2) { fishType = 'largeFish'; } else if (rand < 0.5) { fishType = 'mediumFish'; } else { fishType = 'smallFish'; } var speed = 1 + Math.random() * 2 * difficulty; var fish = new Fish(fishType, speed); // Position fish at random height, but from the side fish.y = 200 + Math.random() * 2300; if (Math.random() > 0.5) { fish.x = -50; fish.direction = 1; } else { fish.x = 2098; fish.direction = -1; } fishes.push(fish); game.addChild(fish); } // Spawn an obstacle function spawnObstacle() { var obstacle = new Obstacle(1 + Math.random() * difficulty); obstacle.x = 100 + Math.random() * 1848; obstacle.y = -100; obstacles.push(obstacle); game.addChild(obstacle); } // Spawn a power-up function spawnPowerUp() { var powerUp = new PowerUp(); powerUp.x = 100 + Math.random() * 1848; powerUp.y = -100; powerUps.push(powerUp); game.addChild(powerUp); } // Handle shark collision with fish function handleFishCollision(fish, index) { // Check if shark can eat this fish if (shark.size >= fish.danger) { // Shark eats fish shark.grow(fish.value * 0.05); // Reduce width by 10 and height by 5 when eating golden fish if (fish.type === 'goldenFish') { var sharkGraphics = shark.getChildAt(0); sharkGraphics.width -= 10; sharkGraphics.height -= 5; } LK.setScore(shark.score); scoreText.setText("Score: " + shark.score); LK.getSound('eat').play(); // Remove fish fish.destroy(); fishes.splice(index, 1); } else { // Fish damages shark shark.takeDamage(5 * fish.danger); } } // Game events game.move = function (x, y, obj) { if (!gameActive || !dragNode) return; // Move shark to touch position dragNode.x = x; dragNode.y = y; // Update shark direction based on movement if (dragNode.x > dragNode.lastX) { dragNode.facing = 1; } else if (dragNode.x < dragNode.lastX) { dragNode.facing = -1; } }; game.down = function (x, y, obj) { if (!gameActive) return; dragNode = shark; game.move(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; // Main game update game.update = function () { if (!gameActive) return; // Increase difficulty over time difficultyTimer++; if (difficultyTimer >= 600) { // Every 10 seconds difficulty += 0.1; maxFishes = Math.min(20, maxFishes + 1); difficultyTimer = 0; } // Update ocean background for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof OceanBackground) { game.children[i].update(); break; } } // Update shark shark.update(); // Update UI healthBarFill.width = shark.health / 100 * 200; oxygenBarFill.width = shark.oxygen / 100 * 200; // Check if game over if (shark.health <= 0) { gameActive = false; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Spawn new entities spawnTimer++; if (spawnTimer >= 60) { // Every second if (fishes.length < maxFishes) { spawnFish(); } if (Math.random() < 0.2 * difficulty) { spawnObstacle(); } if (Math.random() < 0.05) { spawnPowerUp(); } spawnTimer = 0; } // Handle power-up timer if (powerUpActive) { powerUpTimer--; if (powerUpTimer <= 0) { powerUpActive = false; shark.speed = 5; } } // Update fishes and check collisions for (var i = fishes.length - 1; i >= 0; i--) { var fish = fishes[i]; fish.update(); var id = "fish" + i; var isIntersecting = shark.intersects(fish); // Check collision (transition from not intersecting to intersecting) if (!lastIntersectingFish[id] && isIntersecting) { handleFishCollision(fish, i); continue; // Skip further processing if fish was eaten } lastIntersectingFish[id] = isIntersecting; } // Update obstacles and check collisions for (var i = obstacles.length - 1; i >= 0; i--) { var obstacle = obstacles[i]; obstacle.update(); if (obstacle.shouldRemove) { obstacle.destroy(); obstacles.splice(i, 1); continue; } var id = "obstacle" + i; var isIntersecting = shark.intersects(obstacle); // Check collision (transition from not intersecting to intersecting) if (!lastIntersectingObstacle[id] && isIntersecting) { if (!powerUpActive || powerUpActive && shark.type !== 'invincibility') { shark.takeDamage(obstacle.damage); } } lastIntersectingObstacle[id] = isIntersecting; } // Update power-ups and check collisions for (var i = powerUps.length - 1; i >= 0; i--) { var powerUp = powerUps[i]; powerUp.update(); if (powerUp.shouldRemove) { powerUp.destroy(); powerUps.splice(i, 1); continue; } var id = "powerUp" + i; var isIntersecting = shark.intersects(powerUp); // Check collision (transition from not intersecting to intersecting) if (!lastIntersectingPowerUp[id] && isIntersecting) { // Apply power-up effect powerUpActive = true; powerUpTimer = 300; // 5 seconds if (powerUp.type === 'speed') { shark.speed = 10; } // Increase health by 15 when collecting any power-up shark.health = Math.min(100, shark.health + 15); LK.getSound('powerup').play(); LK.effects.flashObject(shark, 0x00ffff, 500); // Remove power-up powerUp.destroy(); powerUps.splice(i, 1); } lastIntersectingPowerUp[id] = isIntersecting; } }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -56,8 +56,84 @@
}
};
return self;
});
+var OceanBackground = Container.expand(function () {
+ var self = Container.call(this);
+ // Main ocean background
+ var bgGraphics = self.attachAsset('oceanBg', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ // Ocean floor
+ var floorGraphics = self.attachAsset('oceanFloor', {
+ anchorX: 0,
+ anchorY: 1
+ });
+ floorGraphics.y = 2732;
+ // Water surface with transparency
+ var surfaceGraphics = self.attachAsset('waterSurface', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ surfaceGraphics.y = 0;
+ surfaceGraphics.alpha = 0.7;
+ // Light rays
+ var lights = [];
+ for (var i = 0; i < 3; i++) {
+ var light = self.attachAsset('lightRay', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ light.x = 400 + Math.random() * 1200;
+ light.y = 0;
+ light.alpha = 0.2 + Math.random() * 0.2;
+ light.scale.set(0.7 + Math.random() * 0.6);
+ lights.push(light);
+ }
+ // Bubbles
+ var bubbles = [];
+ for (var i = 0; i < 15; i++) {
+ spawnBubble();
+ }
+ function spawnBubble() {
+ var bubble = self.attachAsset('bubbles', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ bubble.x = Math.random() * 2048;
+ bubble.y = 500 + Math.random() * 2200;
+ bubble.alpha = 0.3 + Math.random() * 0.5;
+ bubble.scale.set(0.3 + Math.random() * 0.7);
+ bubble.speed = 0.5 + Math.random() * 1.5;
+ bubble.wobbleSpeed = 0.01 + Math.random() * 0.03;
+ bubble.wobbleAmount = 0 + Math.random() * 30;
+ bubble.wobbleOffset = Math.random() * Math.PI * 2;
+ bubbles.push(bubble);
+ }
+ self.update = function () {
+ // Update bubbles
+ for (var i = bubbles.length - 1; i >= 0; i--) {
+ var bubble = bubbles[i];
+ bubble.y -= bubble.speed;
+ bubble.x += Math.sin(LK.ticks * bubble.wobbleSpeed + bubble.wobbleOffset) * 0.3;
+ // If bubble reaches surface, respawn it
+ if (bubble.y < 100) {
+ bubble.destroy();
+ bubbles.splice(i, 1);
+ spawnBubble();
+ }
+ }
+ // Gentle animation for water surface
+ surfaceGraphics.y = Math.sin(LK.ticks * 0.02) * 5;
+ // Animate light rays
+ for (var i = 0; i < lights.length; i++) {
+ var light = lights[i];
+ light.alpha = 0.2 + Math.sin(LK.ticks * 0.01 + i) * 0.1;
+ }
+ };
+ return self;
+});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
@@ -136,10 +212,9 @@
/****
* Game Code
****/
-// Set ocean blue background
-game.setBackgroundColor(0x006994);
+// Background is now handled by the OceanBackground class
// Game variables
var shark;
var fishes = [];
var obstacles = [];
@@ -154,8 +229,9 @@
var difficultyTimer = 0;
var difficulty = 1;
var maxFishes = 10;
var dragNode = null;
+var oceanBackground;
// UI elements
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
@@ -193,8 +269,11 @@
});
LK.gui.topLeft.addChild(oxygenBarFill);
// Initialize shark
function initGame() {
+ // Create ocean background
+ var oceanBg = new OceanBackground();
+ game.addChild(oceanBg);
// Create shark
shark = new Shark();
shark.x = 2048 / 2;
shark.y = 2732 / 2;
@@ -315,8 +394,15 @@
difficulty += 0.1;
maxFishes = Math.min(20, maxFishes + 1);
difficultyTimer = 0;
}
+ // Update ocean background
+ for (var i = 0; i < game.children.length; i++) {
+ if (game.children[i] instanceof OceanBackground) {
+ game.children[i].update();
+ break;
+ }
+ }
// Update shark
shark.update();
// Update UI
healthBarFill.width = shark.health / 100 * 200;
realistic pixel shark. In-Game asset. 2d. High contrast. No shadows
realistic pixel gold fish. In-Game asset. 2d. High contrast. No shadows
realistic pixel sea turtle. In-Game asset. 2d. High contrast. No shadows
realistic pixel horizontal jellyfish. In-Game asset. 2d. High contrast. No shadows
Realistic pixel horizontal dolphin. In-Game asset. 2d. High contrast. No shadows
realistic vertical meteor. In-Game asset. 2d. High contrast. No shadows
realistic pixel diver. In-Game asset. 2d. High contrast. No shadows