User prompt
Игрок победит на 1000 очков
User prompt
Каждые 100 балов Спавн враг куб
User prompt
Куб быстрее при 200 балов
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'enemyCube.update();' Line Number: 126
User prompt
Добавить фон
User prompt
Когда 10 балов каждые 3 секунды минус 1 бал
User prompt
Если нажать на фон мюнус 1 бал
User prompt
Добавить фон
User prompt
При -1 бал игра закончится
User prompt
При нажатие на Враг куб минус 5 балов
User prompt
Куб враг Движется за куб
User prompt
При 150 балов спавн на середине кадра *39* враг куб
User prompt
При 100 балов куб движется быстрее
User prompt
Куб не выходит за кадр
User prompt
Куб движется по к краям карты
User prompt
Куб движется быстрее
User prompt
Куб при нажатия по нему. Спаун мини "21" и летят в разные стороны от куба и умирают через 3. Секунд
User prompt
При 50 балов куб ходит по карте
User prompt
При получение 1 бал куб становится больше
User prompt
При нажатие куба куб немного радует
User prompt
Куб расширяется при нажатии
User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.scaleTo is not a function' in or related to this line: 'LK.effects.scaleTo(self, 1.5, 1.5, 200, function () {' Line Number: 24
User prompt
При нажатее Куб расширяется и уменьшается
Initial prompt
Кликер кубика ахаххахахаххахах
/**** * Classes ****/ // Assets will be automatically created and loaded during gameplay var Cube = Container.expand(function () { var self = Container.call(this); var cubeGraphics = self.attachAsset('cube', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // No specific update logic for the cube }; self.down = function (x, y, obj) { // Increase score when the cube is clicked LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Spawn mini '21' and make them fly in different directions for (var i = 0; i < 5; i++) { var mini21 = new Mini21(); mini21.x = self.x; mini21.y = self.y; game.addChild(mini21); } }; }); var EnemyCube = Container.expand(function () { var self = Container.call(this); var enemyCubeGraphics = self.attachAsset('enemyCube', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Move enemy cube towards the main cube var dx = cube.x - self.x; var dy = cube.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); var speed = 5; // Speed of the enemy cube if (distance > 0) { self.x += dx / distance * speed; self.y += dy / distance * speed; } }; }); var Mini21 = Container.expand(function () { var self = Container.call(this); var mini21Graphics = self.attachAsset('mini21', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = Math.random() * 10 - 5; self.speedY = Math.random() * 10 - 5; self.update = function () { self.x += self.speedX; self.y += self.speedY; }; LK.setTimeout(function () { self.destroy(); LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); }, 3000); }); /**** * Initialize Game ****/ // Update mini '21' positions var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Add background image var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(background); var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var cube = game.addChild(new Cube()); game.enemyCubeSpawned = false; cube.speedX = 10; game.scoreDecrementInterval = null; cube.speedY = 10; cube.speedIncreased = false; cube.x = 2048 / 2; cube.y = 2732 / 2; game.update = function () { if (LK.getScore() >= 10 && !game.scoreDecrementInterval) { game.scoreDecrementInterval = LK.setInterval(function () { LK.setScore(LK.getScore() - 1); scoreTxt.setText(LK.getScore()); }, 3000); } else if (LK.getScore() < 10 && game.scoreDecrementInterval) { LK.clearInterval(game.scoreDecrementInterval); game.scoreDecrementInterval = null; } if (LK.getScore() >= 150 && !game.enemyCubeSpawned) { var enemyCube = new EnemyCube(); enemyCube.x = 2048 / 2; enemyCube.y = 2732 / 2; game.addChild(enemyCube); game.enemyCubeSpawned = true; } else if (LK.getScore() >= 100 && !cube.speedIncreased) { cube.speedX *= 1.5; cube.speedY *= 1.5; cube.speedIncreased = true; } else if (LK.getScore() <= -1) { LK.showGameOver(); return; } else if (LK.getScore() >= 50) { // Move cube towards the edges of the map if (cube.x < cube.width / 2 || cube.x > 2048 - cube.width / 2) { cube.speedX = -cube.speedX; } if (cube.y < cube.height / 2 || cube.y > 2732 - cube.height / 2) { cube.speedY = -cube.speedY; } cube.x += cube.speedX; cube.y += cube.speedY; } // Update enemy cube position if (game.enemyCubeSpawned) { enemyCube.update(); } // No duplicate cube movement logic }; game.down = function (x, y, obj) {}; game.up = function (x, y, obj) { // No specific logic for game up event }; game.move = function (x, y, obj) { // No specific logic for game move event }; // Update mini '21' positions for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Mini21) { game.children[i].update(); } }
===================================================================
--- original.js
+++ change.js
@@ -88,13 +88,23 @@
LK.gui.top.addChild(scoreTxt);
var cube = game.addChild(new Cube());
game.enemyCubeSpawned = false;
cube.speedX = 10;
+game.scoreDecrementInterval = null;
cube.speedY = 10;
cube.speedIncreased = false;
cube.x = 2048 / 2;
cube.y = 2732 / 2;
game.update = function () {
+ if (LK.getScore() >= 10 && !game.scoreDecrementInterval) {
+ game.scoreDecrementInterval = LK.setInterval(function () {
+ LK.setScore(LK.getScore() - 1);
+ scoreTxt.setText(LK.getScore());
+ }, 3000);
+ } else if (LK.getScore() < 10 && game.scoreDecrementInterval) {
+ LK.clearInterval(game.scoreDecrementInterval);
+ game.scoreDecrementInterval = null;
+ }
if (LK.getScore() >= 150 && !game.enemyCubeSpawned) {
var enemyCube = new EnemyCube();
enemyCube.x = 2048 / 2;
enemyCube.y = 2732 / 2;
@@ -123,14 +133,9 @@
enemyCube.update();
}
// No duplicate cube movement logic
};
-game.down = function (x, y, obj) {
- if (obj.target === background) {
- LK.setScore(LK.getScore() - 1);
- scoreTxt.setText(LK.getScore());
- }
-};
+game.down = function (x, y, obj) {};
game.up = function (x, y, obj) {
// No specific logic for game up event
};
game.move = function (x, y, obj) {