User prompt
Сделай так чтоб водоросли были обязательно в самом низу
User prompt
Сделай так чтоб музыка останавливалась когда игрок проиграл
User prompt
Добавь водоросли
User prompt
Подставь музыку база как фоновую
User prompt
Сделай так чтоб акула ела только передом
User prompt
Please fix the bug: 'TypeError: fishGraphics.setTexture is not a function' in or related to this line: 'fishGraphics.setTexture(LK.getAsset('fish', {}).texture);' Line Number: 39
User prompt
Исправь текстурки рыбы
User prompt
Please fix the bug: 'TypeError: fishGraphics.setTexture is not a function' in or related to this line: 'fishGraphics.setTexture(LK.getAsset('fish', {}).texture);' Line Number: 39
User prompt
Сделай так чтоб текстура ры менялась на испуганную рыбу в момент приближения акулы
User prompt
Добавь испугунцю рыбу.
User prompt
Сделай так что при съедание рыбы фуги игрок проиграл
User prompt
Добавь рыбу фугу
User prompt
Сделай так чтоб через каждые 10 стеденой рыбы акула становилась в1,5 больше и быстрее
User prompt
Добавь счет съеденной рыбы
User prompt
Сделай так чтоб рыба поворачивалась как и акула
User prompt
Сделай так чтоб акула поворачивалась в сторону в которую плывёт
User prompt
Сделай так чтоб иногда припрывали ещё рыбы
User prompt
Сделай так чтоб они убегали от акулы
User prompt
Сделай так чтоб они двигались быстрее
User prompt
Сделай так чтоб рыбы двигались
User prompt
Поставь джойстик подальше от краев экрана
User prompt
Please fix the bug: 'ReferenceError: x is not defined' in or related to this line: 'var dx = x - self.base.x;' Line Number: 38
User prompt
Сделай так чтоб джойстик работал
User prompt
Помести джойстик в угол экрана
User prompt
Добавь джойстик для управления акулой
/****
* Classes
****/
// Fish class
var Fish = Container.expand(function () {
var self = Container.call(this);
var fishGraphics = self.attachAsset('fish', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Fish movement logic
var dx = self.x - playerShark.x;
var dy = self.y - playerShark.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 300) {
// If the shark is within 300 pixels
dx /= distance;
dy /= distance;
self.x += dx * 5; // Move away faster
self.y += dy * 5;
} else {
self.x += Math.random() * 4 - 2; // Random horizontal movement
self.y += Math.random() * 4 - 2; // Random vertical movement
}
// Rotate fish towards movement direction
if (dx !== 0 || dy !== 0) {
self.rotation = Math.atan2(dy, dx);
}
// Ensure fish stay within screen bounds
if (self.x < 0) {
self.x = 0;
}
if (self.x > 2048) {
self.x = 2048;
}
if (self.y < 0) {
self.y = 0;
}
if (self.y > 2732) {
self.y = 2732;
}
};
});
// Joystick class
var Joystick = Container.expand(function () {
var self = Container.call(this);
var joystickBase = self.attachAsset('joystickBase', {
anchorX: 0.5,
anchorY: 0.5
});
var joystickKnob = self.attachAsset('joystickKnob', {
anchorX: 0.5,
anchorY: 0.5
});
self.knob = joystickKnob;
self.base = joystickBase;
self.update = function () {
// Update logic if needed
};
self.down = function (x, y, obj) {
// Set the initial position of the knob to the touch point
self.knob.x = x;
self.knob.y = y;
};
self.move = function (x, y, obj) {
// Calculate the distance from the center of the joystick base
var dx = x - self.base.x;
var dy = y - self.base.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Limit the knob's movement to the joystick base's radius
var maxDistance = self.base.width / 2;
if (distance > maxDistance) {
dx = dx / distance * maxDistance;
dy = dy / distance * maxDistance;
}
// Update the knob's position
self.knob.x = self.base.x + dx;
self.knob.y = self.base.y + dy;
};
self.up = function (x, y, obj) {
// Reset the knob to the center of the joystick base
self.knob.x = self.base.x;
self.knob.y = self.base.y;
};
});
// PufferFish class
var PufferFish = Container.expand(function () {
var self = Container.call(this);
var pufferFishGraphics = self.attachAsset('pufferFish', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// PufferFish movement logic
var dx = self.x - playerShark.x;
var dy = self.y - playerShark.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 300) {
// If the shark is within 300 pixels
dx /= distance;
dy /= distance;
self.x += dx * 3; // Move away slower than regular fish
self.y += dy * 3;
} else {
self.x += Math.random() * 2 - 1; // Random horizontal movement
self.y += Math.random() * 2 - 1; // Random vertical movement
}
// Rotate pufferfish towards movement direction
if (dx !== 0 || dy !== 0) {
self.rotation = Math.atan2(dy, dx);
}
// Ensure pufferfish stay within screen bounds
if (self.x < 0) {
self.x = 0;
}
if (self.x > 2048) {
self.x = 2048;
}
if (self.y < 0) {
self.y = 0;
}
if (self.y > 2732) {
self.y = 2732;
}
};
});
// ScaredFish class
var ScaredFish = Container.expand(function () {
var self = Container.call(this);
var scaredFishGraphics = self.attachAsset('fish', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// ScaredFish movement logic
var dx = self.x - playerShark.x;
var dy = self.y - playerShark.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 500) {
// If the shark is within 500 pixels
dx /= distance;
dy /= distance;
self.x += dx * 7; // Move away faster than regular fish
self.y += dy * 7;
} else {
self.x += Math.random() * 4 - 2; // Random horizontal movement
self.y += Math.random() * 4 - 2; // Random vertical movement
}
// Rotate scared fish towards movement direction
if (dx !== 0 || dy !== 0) {
self.rotation = Math.atan2(dy, dx);
}
// Ensure scared fish stay within screen bounds
if (self.x < 0) {
self.x = 0;
}
if (self.x > 2048) {
self.x = 2048;
}
if (self.y < 0) {
self.y = 0;
}
if (self.y > 2732) {
self.y = 2732;
}
};
});
// Assets will be automatically created and loaded by the LK engine
// Shark class
var Shark = Container.expand(function () {
var self = Container.call(this);
var sharkGraphics = self.attachAsset('shark', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Update shark position based on joystick input
var dx = joystick.knob.x - joystick.base.x;
var dy = joystick.knob.y - joystick.base.y;
self.x += dx * 0.1; // Adjust speed as necessary
self.y += dy * 0.1; // Adjust speed as necessary
// Rotate shark towards movement direction
if (dx !== 0 || dy !== 0) {
self.rotation = Math.atan2(dy, dx);
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0000FF // Init game with blue background to represent underwater
});
/****
* Game Code
****/
// Play background music at game start
LK.playMusic('Base');
// Initialize score display
var score = 0;
var scoreDisplay = new Text2('Score: 0', {
size: 100,
fill: "#ffffff"
});
scoreDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreDisplay);
// Initialize shark, fish arrays, and joystick
var sharks = [];
var fishes = [];
var joystick = game.addChild(new Joystick());
joystick.x = 200; // Position joystick further from the left edge
joystick.y = 2532; // Position joystick further from the bottom edge
// Create the player's shark
var playerShark = game.addChild(new Shark());
playerShark.x = 2048 / 2; // Position the shark in the middle of the screen
playerShark.y = 2732 / 2;
// Create fishes
for (var i = 0; i < 10; i++) {
var fish = game.addChild(new Fish());
fish.x = Math.random() * 2048; // Random position for the fish
fish.y = Math.random() * 2732;
fishes.push(fish);
}
// Game update function
game.update = function () {
// Check for collisions between the shark and the fishes
for (var i = fishes.length - 1; i >= 0; i--) {
if (playerShark.intersects(fishes[i])) {
// Calculate the direction the shark is facing
var sharkFacingX = Math.cos(playerShark.rotation);
var sharkFacingY = Math.sin(playerShark.rotation);
// Calculate the direction from the shark to the fish
var toFishX = fishes[i].x - playerShark.x;
var toFishY = fishes[i].y - playerShark.y;
var toFishDistance = Math.sqrt(toFishX * toFishX + toFishY * toFishY);
toFishX /= toFishDistance;
toFishY /= toFishDistance;
// Check if the shark is facing the fish
var dotProduct = sharkFacingX * toFishX + sharkFacingY * toFishY;
if (dotProduct > 0.5) {
// Only eat if facing towards the fish
if (fishes[i] instanceof PufferFish) {
// If the shark intersects with a puffer fish, trigger game over
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
} else {
// Remove the fish from the game and the fishes array
fishes[i].destroy();
fishes.splice(i, 1);
// Update score
score += 1;
scoreDisplay.setText('Score: ' + score);
// Increase shark size and speed every 10 fish eaten
if (score % 10 === 0) {
playerShark.scaleX *= 1.5;
playerShark.scaleY *= 1.5;
playerShark.speed *= 1.5;
} else if (Math.random() < 0.005) {
// 0.5% chance to spawn a new scared fish each frame
var newScaredFish = game.addChild(new ScaredFish());
newScaredFish.x = Math.random() * 2048; // Random position for the new scared fish
newScaredFish.y = Math.random() * 2732;
fishes.push(newScaredFish);
}
}
;
}
}
}
// Occasionally spawn new fish or puffer fish
if (Math.random() < 0.01) {
// 1% chance to spawn a new fish each frame
var newFish = game.addChild(new Fish());
newFish.x = Math.random() * 2048; // Random position for the new fish
newFish.y = Math.random() * 2732;
fishes.push(newFish);
} else if (Math.random() < 0.005) {
// 0.5% chance to spawn a new puffer fish each frame
var newPufferFish = game.addChild(new PufferFish());
newPufferFish.x = Math.random() * 2048; // Random position for the new puffer fish
newPufferFish.y = Math.random() * 2732;
fishes.push(newPufferFish);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -196,8 +196,10 @@
/****
* Game Code
****/
+// Play background music at game start
+LK.playMusic('Base');
// Initialize score display
var score = 0;
var scoreDisplay = new Text2('Score: 0', {
size: 100,
По кадровая анимация акулы. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Водоросли Анимация. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Рыба анимационная. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.