User prompt
если Coin улетела за нижнюю границу экрана - она уничтожена.
Code edit (4 edits merged)
Please save this source code
User prompt
все сундуки стоят более чем в 33 пикселях от цветов
Code edit (1 edits merged)
Please save this source code
User prompt
End the game when three chests are opened Replace Chest with ChestOpen when clicked
User prompt
когда кликаешь по chest он replace to openchest
User prompt
когда нажимаешь на chest он превращается в openchest
Code edit (5 edits merged)
Please save this source code
User prompt
Если на экране три открытых сундука - игра выиграна
User prompt
Когда кликаем по Chest с alpha=1 превращается в ChestOpen
User prompt
игра не заканчивается после открытия двух сундуков. игра оканчивается победой после открытия трёх сундуков
User prompt
игра не заканчивается после нахождения одного сундука
User prompt
игра не заканчивается после нахождения первых двух сундуков. игра оканчивается победой после нахождения трёх сундуков
User prompt
на карте 3 сундука. стрелки появляющиеся из цветов указывают направление к ближайшему сундуку.
User prompt
на карте 3 сундука. стрелки указывают направление к ближайшему сундуку
Code edit (1 edits merged)
Please save this source code
User prompt
некоторые цветы развёрнуты по горизонтали
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: chestGraphics is not defined' in or related to this line: 'chestGraphics.alpha = 1;' Line Number: 155
User prompt
Please fix the bug: 'Uncaught ReferenceError: chestGraphics is not defined' in or related to this line: 'chestGraphics.alpha = 1;' Line Number: 155
User prompt
Show the chest when the score is less than or equal to 0
User prompt
когда очки кончились - показать сундук
User prompt
игра заканчивается после нахождения трёх сундуков
Code edit (2 edits merged)
Please save this source code
User prompt
когда Coin вылетает из EnvironmentFlower - она взлетает вверх со скоростью 40
/**** * 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 && 1 == 1) { LK.showGameOver(); } }; }); 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: 0.5 }); 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(); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 }); /**** * Game Code ****/ for (var i = 0; i < 20; 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 = game.addChild(new Cursor()); game.move = function (x, y, obj) { cursor.x = x; cursor.y = y; }; // 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) { // Decrease the score by one LK.setScore(LK.getScore() - 1); // 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
@@ -36,16 +36,16 @@
chestOpen.y = self.y;
chestsOpened++;
LK.setScore(LK.getScore() + 6);
scoreTxt.setText(LK.getScore().toString());
- for (var i = 0; i < 50 * (1 + chestsOpened); i++) {
+ 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) {
+ if (chestsOpened >= 3 && 1 == 1) {
LK.showGameOver();
}
};
});
@@ -68,8 +68,11 @@
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);