User prompt
Добавь звук
User prompt
Please fix the bug: 'ReferenceError: pos is not defined' in or related to this line: 'var crosshairGraphics = game.attachAsset('crosshair', {' Line Number: 66
User prompt
Перекрестье появляеться на месте выстрела
User prompt
Please fix the bug: 'Timeout.tick error: crosshairGraphics is not defined' in or related to this line: 'self.removeChild(crosshairGraphics);' Line Number: 68
User prompt
Перекрестье появляеться даже если игрок не попал по утке
User prompt
При встрели появляеться перекрестье
User prompt
Как сделать такой же счёт но смаленькими изменениями
User prompt
Добавь анимацию утке
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'toString')' in or related to this line: 'var bulletsCounterTxt = new Text2(bulletsLeft.toString(), {' Line Number: 71
User prompt
Оптимизируй игру
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toString')' in or related to this line: 'var bulletsCounterTxt = new Text2(bulletsLeft.toString(), {' Line Number: 78
User prompt
С низув правом углу добавь счетчик патронов
User prompt
Сделай перезарядку после 7 выстрелов
User prompt
Сделай так чтоб труп утки падал до низа экрана
User prompt
Сделай так чтоб при выстрели мы видели труп утки
Initial prompt
Shot, duck shot
/****
* Classes
****/
// Assets are automatically created based on usage in the code.
// Duck class
var Duck = Container.expand(function () {
var self = Container.call(this);
var duckGraphics = self.attachAsset('duck', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 2 + 1; // Random speed between 1 and 3
self.direction = Math.random() < 0.5 ? -1 : 1; // Random direction left or right
self.move = function () {
self.x += self.speed * self.direction;
// Reverse direction if hitting screen bounds
if (self.x < 0 || self.x > 2048) {
self.direction *= -1;
}
};
self.on('down', function () {
// Check if there are bullets left before registering a hit
if (bulletsLeft > 0) {
// Decrease bullets left
bulletsLeft--;
// Increase score when duck is tapped
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
// Change duck to a dead duck asset
var deadDuckGraphics = self.attachAsset('deadDuck', {
anchorX: 0.5,
anchorY: 0.5
});
// Remove movement and falling logic
self.move = function () {
self.y += 5; // Make the dead duck fall down
};
} else {
// If no bullets left, ignore the tap
console.log("Out of bullets! Reload to continue.");
}
// Change duck to a dead duck asset
var deadDuckGraphics = self.attachAsset('deadDuck', {
anchorX: 0.5,
anchorY: 0.5
});
// Remove movement and falling logic
self.move = function () {
self.y += 5; // Make the dead duck fall down
};
// Remove duck from game after it falls off the screen
LK.on('tick', function () {
if (self.y > 2732) {
// Check if duck has fallen off the screen
self.destroy();
}
});
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Light blue background to simulate sky
});
/****
* Game Code
****/
var ducks = []; // Array to keep track of ducks
var bulletsLeft = 7; // Initialize bullets left for reload
var maxBullets = 7; // Maximum bullets before reload
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
LK.gui.top.addChild(scoreTxt); // Add score text to the top-center of the screen
// Function to spawn a duck
function spawnDuck() {
var duck = new Duck();
duck.x = Math.random() * 2048; // Random starting x position
duck.y = Math.random() * 2732 / 2; // Random starting y position, only in the top half of the screen
game.addChild(duck);
ducks.push(duck);
}
// Game tick function
LK.on('tick', function () {
// Move each duck
ducks.forEach(function (duck, index) {
duck.move();
// Remove duck if it goes off the top of the screen
if (duck.y < -50) {
duck.destroy();
ducks.splice(index, 1);
}
});
// Reload bullets every 2 seconds if out
if (bulletsLeft <= 0 && LK.ticks % 120 == 0) {
bulletsLeft = maxBullets;
console.log("Bullets reloaded!");
}
// Spawn a new duck every 60 frames (about 1 second)
if (LK.ticks % 60 == 0) {
spawnDuck();
}
}); ===================================================================
--- original.js
+++ change.js
@@ -18,11 +18,28 @@
self.direction *= -1;
}
};
self.on('down', function () {
- // Increase score when duck is tapped
- LK.setScore(LK.getScore() + 1);
- scoreTxt.setText(LK.getScore());
+ // Check if there are bullets left before registering a hit
+ if (bulletsLeft > 0) {
+ // Decrease bullets left
+ bulletsLeft--;
+ // Increase score when duck is tapped
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ // Change duck to a dead duck asset
+ var deadDuckGraphics = self.attachAsset('deadDuck', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Remove movement and falling logic
+ self.move = function () {
+ self.y += 5; // Make the dead duck fall down
+ };
+ } else {
+ // If no bullets left, ignore the tap
+ console.log("Out of bullets! Reload to continue.");
+ }
// Change duck to a dead duck asset
var deadDuckGraphics = self.attachAsset('deadDuck', {
anchorX: 0.5,
anchorY: 0.5
@@ -51,8 +68,10 @@
/****
* Game Code
****/
var ducks = []; // Array to keep track of ducks
+var bulletsLeft = 7; // Initialize bullets left for reload
+var maxBullets = 7; // Maximum bullets before reload
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
@@ -75,8 +94,13 @@
duck.destroy();
ducks.splice(index, 1);
}
});
+ // Reload bullets every 2 seconds if out
+ if (bulletsLeft <= 0 && LK.ticks % 120 == 0) {
+ bulletsLeft = maxBullets;
+ console.log("Bullets reloaded!");
+ }
// Spawn a new duck every 60 frames (about 1 second)
if (LK.ticks % 60 == 0) {
spawnDuck();
}
Измени счёт который щас используется у этого объекта. Текстура для 2д утки с полета утка из одиночной игры про охоту рисунков анмации
Прицел. 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.