User prompt
объект Cursor должен отображаться над всеми другими объектами
User prompt
спрячь системный курсор
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'body')' in or related to this line: 'document.body.style.cursor = 'none';' Line Number: 211
User prompt
спрячь системный курсор
Code edit (2 edits merged)
Please save this source code
User prompt
при клике проигрывает звук click или звук click2 или звук click3 или звук click4 или звук click5 или звук click6 (случайный порядок)
User prompt
при клике проигрывает звук click или звук click2 (случайный порядок)
Code edit (3 edits merged)
Please save this source code
User prompt
ошибка: звук solemn_music не проигрывается
User prompt
Please fix the bug: 'Uncaught TypeError: LK.play is not a function' in or related to this line: 'LK.play();' Line Number: 217
Code edit (1 edits merged)
Please save this source code
User prompt
когда кликаешь ещё и звук проигрывается (solemn_music)
Code edit (1 edits merged)
Please save this source code
User prompt
после того как нажали на цветок начинается обратный отсчёт в 5 секунд, по окончании - игра проиграна.
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: Pit is not defined' in or related to this line: 'var pit = game.addChild(new Pit());' Line Number: 207
User prompt
если кликаем, то в этом месте появляется pit
Code edit (1 edits merged)
Please save this source code
User prompt
если все монеты уничтожены добавить 1 очко
/**** * Classes ****/ var Arrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('Arrow', { anchorX: 0.5, anchorY: 0.5 }); self.getNearestChest = function () { var nearestChest = null; var nearestDistance = Infinity; chests.forEach(function (chest) { var dx = chest.x - self.x; var dy = chest.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < nearestDistance) { nearestChest = chest; nearestDistance = distance; } }); return nearestChest; }; }); var Chest = Container.expand(function () { var self = Container.call(this); var chestGraphics = self.attachAsset('Chest', { anchorX: 0.5, anchorY: 0.9, alpha: 0 }); self.down = function (x, y, obj) { self.destroy(); var chestOpen = game.addChild(new ChestOpen()); chestOpen.x = self.x; chestOpen.y = self.y; chestsOpened++; LK.setScore(LK.getScore() + 6); scoreTxt.setText(LK.getScore().toString()); for (var i = 0; i < 50 * (2 + chestsOpened); i++) { var coin = game.addChild(new Coin()); coin.x = self.x - Math.random() * 1; coin.y = self.y - Math.random() * 1; coin.speedY = -40 + Math.random() * 5; coin.speedX = 10 - Math.random() * 20; } if (chestsOpened >= 3) { LK.getSound('solemn_music').play(); LK.setTimeout(function () { LK.showGameOver(); }, 5000); } else { LK.getSound('ChestOpenSound').play(); } }; }); var ChestOpen = Container.expand(function () { var self = Container.call(this); var chestOpenGraphics = self.attachAsset('ChestOpen', { anchorX: 0.5, anchorY: 0.95 }); }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('Coin', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 0; self.speedY = 0; self.gravity = 1; self.update = function () { self.y += self.speedY; self.speedY += self.gravity; self.x += self.speedX; if (self.y > 2732) { self.destroy(); } }; }); var Cursor = Container.expand(function () { var self = Container.call(this); var cursorGraphics = self.attachAsset('Cursor', { anchorX: 0.5, anchorY: 0.5 }); }); var EnvironmentFlower = Container.expand(function () { var self = Container.call(this); var flowerGraphics = self.attachAsset('EnvironmentFlower', { anchorX: 0.5, anchorY: 1 }); self.isTooClose = function (x, y) { var tooClose = false; game.children.forEach(function (child) { var dx = child.x - x; var dy = child.y - y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 100) { tooClose = true; } }); return tooClose; }; self.down = function (x, y, obj) { var arrow = game.addChild(new Arrow()); arrow.x = self.x; arrow.y = self.y; // Get the nearest chest var nearestChest = arrow.getNearestChest(); // Calculate the angle between the arrow and the nearest chest var dx = nearestChest.x - self.x; var dy = nearestChest.y - self.y; var angle = Math.atan2(dy, dx); // Rotate the arrow to face the nearest chest arrow.rotation = angle; // 33% chance to create a coin and increase the score by 1 if (Math.random() < 0.33) { var coin = game.addChild(new Coin()); coin.x = self.x; coin.y = self.y; coin.speedX = -10 + Math.random() * 20; coin.speedY = -40 + Math.random() * 10; // Set the vertical speed to -40 to make the coin fly upwards LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore().toString()); } self.destroy(); }; }); var Pit = Container.expand(function () { var self = Container.call(this); var pitGraphics = self.attachAsset('pit', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 }); /**** * Game Code ****/ for (var i = 0; i < 40; i++) { var flower = new EnvironmentFlower(); var x, y; do { x = Math.random() * 2048; y = Math.random() * 2732; } while (flower.isTooClose(x, y)); flower.x = x; flower.y = y; game.addChild(flower); } var chests = []; var chestsOpened = 0; for (var i = 0; i < 3; i++) { var chest = game.addChild(new Chest()); var x, y; do { x = Math.random() * 2048; y = Math.random() * 2732; } while (isTooCloseToFlower(x, y)); chest.x = x; chest.y = y; chests.push(chest); } function isTooCloseToFlower(x, y) { var tooClose = false; game.children.forEach(function (child) { if (child instanceof EnvironmentFlower) { var dx = child.x - x; var dy = child.y - y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 33) { tooClose = true; } } }); return tooClose; } var cursor = new Cursor(); game.addChild(cursor); game.move = function (x, y, obj) { cursor.x = x; cursor.y = y; game.setChildIndex(cursor, game.children.length - 1); }; // Initialize the score LK.setScore(7); // Create a text object to display the score var scoreTxt = new Text2(LK.getScore().toString(), { size: 100, fill: "#ffffff" }); // Set the anchor to the center of the top edge of the text scoreTxt.anchor.set(0.5, 0); // Add the score text to the GUI overlay at the top-center of the screen LK.gui.top.addChild(scoreTxt); game.down = function (x, y, obj) { // Create a pit at the clicked location var pit = game.addChild(new Pit()); pit.x = x; pit.y = y; // Decrease the score by one LK.setScore(LK.getScore() - 1); // Play a random click sound var clickSounds = ['click', 'click2', 'click3', 'click4', 'click5', 'click6']; var randomSound = clickSounds[Math.floor(Math.random() * clickSounds.length)]; LK.getSound(randomSound).play(); // Update the score text scoreTxt.setText(LK.getScore().toString()); // End the game if the score is less than 0 if (LK.getScore() < 0) { LK.showGameOver(); } };
===================================================================
--- original.js
+++ change.js
@@ -184,12 +184,14 @@
}
});
return tooClose;
}
-var cursor = game.addChild(new Cursor());
+var cursor = new Cursor();
+game.addChild(cursor);
game.move = function (x, y, obj) {
cursor.x = x;
cursor.y = y;
+ game.setChildIndex(cursor, game.children.length - 1);
};
// Initialize the score
LK.setScore(7);
// Create a text object to display the score
@@ -217,7 +219,5 @@
// End the game if the score is less than 0
if (LK.getScore() < 0) {
LK.showGameOver();
}
- // Hide the system cursor
- game.canvas.style.cursor = 'none';
};
\ No newline at end of file