kodu ekle","generatedCode":"
===================================================================\n--- original.js\n+++ change.js\n@@ -52,8 +52,20 @@\n \t\t\tself.destroy();\n \t\t}\n \t};\n });\n+// Define a class for the left button\n+var LeftButton = Container.expand(function () {\n+\tvar self = Container.call(this);\n+\tvar buttonGraphics = self.attachAsset('leftButton', {\n+\t\tanchorX: 0.5,\n+\t\tanchorY: 0.5\n+\t});\n+\tself.down = function (x, y, obj) {\n+\t\tcharacter.x -= 20;\n+\t\tupdateCharacterPosition();\n+\t};\n+});\n var NewEnemy = Container.expand(function () {\n \tvar self = Container.call(this);\n \tvar newEnemyGraphics = self.attachAsset('newEnemy', {\n \t\tanchorX: 0.5,\n@@ -123,8 +135,20 @@\n \t\t\tself.speedX = 0; // Reset horizontal speed\n \t\t}\n \t};\n });\n+// Define a class for the right button\n+var RightButton = Container.expand(function () {\n+\tvar self = Container.call(this);\n+\tvar buttonGraphics = self.attachAsset('rightButton', {\n+\t\tanchorX: 0.5,\n+\t\tanchorY: 0.5\n+\t});\n+\tself.down = function (x, y, obj) {\n+\t\tcharacter.x += 20;\n+\t\tupdateCharacterPosition();\n+\t};\n+});\n // Define a class for the up button\n var UpButton = Container.expand(function () {\n \tvar self = Container.call(this);\n \tvar buttonGraphics = self.attachAsset('upButton', {\n@@ -145,37 +169,8 @@\n \n /**** \n * Game Code\n ****/ \n-// Create left and right buttons for character movement\n-var leftButton = LK.getAsset('leftButton', {\n-\tanchorX: 0.5,\n-\tanchorY: 0.5\n-});\n-leftButton.x = 50;\n-leftButton.y = 2732 - 150; // Position at the bottom left\n-var rightButton = LK.getAsset('rightButton', {\n-\tanchorX: 0.5,\n-\tanchorY: 0.5\n-});\n-rightButton.x = 200;\n-rightButton.y = 2732 - 150; // Position at the bottom left\n-game.addChild(leftButton);\n-game.addChild(rightButton);\n-// Event listeners for left and right button presses\n-leftButton.down = function () {\n-\tcharacter.x -= 20;\n-\tupdateCharacterPosition();\n-};\n-rightButton.down = function () {\n-\tcharacter.x += 20;\n-\tupdateCharacterPosition();\n-};\n-// Function to update character position\n-function updateCharacterPosition() {\n-\tcharacter.x = Math.max(0, Math.min(2048, character.x)); // Ensure character stays within bounds\n-\tcharacter.element.style.left = character.x + "px";\n-}\n // Function to spawn flowers on the screen\n function spawnFlowers() {\n \t// Number of flowers to spawn\n \tfor (var i = 0; i < Math.floor(Math.random() * 6) + 5; i++) {\n@@ -375,8 +370,21 @@\n // Initialize down button\n var downButton = game.addChild(new DownButton());\n downButton.x = 2048 - 500 - 50; // Right edge minus button width and margin\n downButton.y = 2732 - 500 - 250; // Move the down button slightly more upwards\n+// Initialize left button\n+var leftButton = game.addChild(new LeftButton());\n+leftButton.x = 50; // Position on the left\n+leftButton.y = 2732 - 150; // Position near the bottom\n+// Initialize right button\n+var rightButton = game.addChild(new RightButton());\n+rightButton.x = 160; // Position next to the left button\n+rightButton.y = 2732 - 150; // Position near the bottom\n+// Function to update character position\n+function updateCharacterPosition() {\n+\tcharacter.x = Math.max(0, Math.min(2048, character.x)); // Keep character within bounds\n+\tcharacter.element.style.left = character.x + "px";\n+}\n // Initialize enemies\n var enemies = [];\n var enemySpawnInterval = 80; // Decrease interval to increase spawn rate\n var enemySpawnIncreaseInterval = 40000; // Increase spawn rate every 40 seconds\n
"} Upit | Learn about creating the game Beemario vs Beastbee with gen AI