\n\n","generatedCode":"
===================================================================\n--- original.js\n+++ change.js\n@@ -1,4 +1,30 @@\n+var Match3Game = Container.expand(function () {\n+\tvar self = Container.call(this);\n+\tvar grid = [];\n+\tvar BLOCK_SIZE = 2048 / 16;\n+\tvar GRID_WIDTH = 16;\n+\tvar GRID_HEIGHT = 12;\n+\tvar COLORS = ['red', 'green', 'blue'];\n+\tfunction createGrid() {\n+\t\tfor (var row = 0; row < GRID_HEIGHT; row++) {\n+\t\t\tgrid[row] = [];\n+\t\t\tfor (var col = 0; col < GRID_WIDTH; col++) {\n+\t\t\t\tvar color = COLORS[Math.floor(Math.random() * COLORS.length)];\n+\t\t\t\tvar block = self.addChild(new Block(color));\n+\t\t\t\tblock.x = col * BLOCK_SIZE + BLOCK_SIZE / 2;\n+\t\t\t\tblock.y = row * BLOCK_SIZE + BLOCK_SIZE / 2;\n+\t\t\t\tgrid[row][col] = block;\n+\t\t\t}\n+\t\t}\n+\t}\n+\tcreateGrid();\n+});\n+var Block = Container.expand(function (color) {\n+\tvar self = Container.call(this);\n+\tself.color = color;\n+\tvar blockGraphics = self.createAsset('block_' + color, 'Block Graphics', 0.5, 0.5);\n+});\n var Ghost = Container.expand(function () {\n \tvar self = Container.call(this);\n \tvar ghostGraphics = self.createAsset('ghost', 'Ghost character', .5, .5);\n \tself.move = function () {};\n@@ -18,37 +44,6 @@\n \tself.solve = function () {};\n });\n var Game = Container.expand(function () {\n \tvar self = Container.call(this);\n-\tLK.stageContainer.setBackgroundColor(0x000000);\n-\tvar hero = self.addChild(new Hero());\n-\thero.x = 2048 / 2;\n-\thero.y = 2732 / 2;\n-\tvar ghost = self.addChild(new Ghost());\n-\tghost.x = 2048 / 2;\n-\tghost.y = 2732 / 4;\n-\tvar puzzles = [];\n-\tfor (var i = 0; i < 5; i++) {\n-\t\tvar puzzle = self.addChild(new Puzzle());\n-\t\tpuzzle.x = 2048 / 2;\n-\t\tpuzzle.y = 2732 / 2 + i * 100;\n-\t\tpuzzles.push(puzzle);\n-\t}\n-\tvar scoreTxt = new Text2('0', {\n-\t\tsize: 150,\n-\t\tfill: "#ffffff"\n-\t});\n-\tscoreTxt.anchor.set(.5, 0);\n-\tLK.gui.topCenter.addChild(scoreTxt);\n-\tvar isGameOver = false;\n-\tLK.on('tick', function () {\n-\t\thero.update();\n-\t\tghost.update();\n-\t\tpuzzles.forEach(function (puzzle) {\n-\t\t\tpuzzle.update();\n-\t\t});\n-\t\tif (isGameOver) {\n-\t\t\tLK.effects.flashScreen(0xff0000, 1000);\n-\t\t\tLK.showGameOver();\n-\t\t}\n-\t});\n+\tvar match3Game = self.addChild(new Match3Game());\n });\n
"} \n\n","generatedCode":"
===================================================================\n--- original.js\n+++ change.js\n@@ -1,4 +1,30 @@\n+var Match3Game = Container.expand(function () {\n+\tvar self = Container.call(this);\n+\tvar grid = [];\n+\tvar BLOCK_SIZE = 2048 / 16;\n+\tvar GRID_WIDTH = 16;\n+\tvar GRID_HEIGHT = 12;\n+\tvar COLORS = ['red', 'green', 'blue'];\n+\tfunction createGrid() {\n+\t\tfor (var row = 0; row < GRID_HEIGHT; row++) {\n+\t\t\tgrid[row] = [];\n+\t\t\tfor (var col = 0; col < GRID_WIDTH; col++) {\n+\t\t\t\tvar color = COLORS[Math.floor(Math.random() * COLORS.length)];\n+\t\t\t\tvar block = self.addChild(new Block(color));\n+\t\t\t\tblock.x = col * BLOCK_SIZE + BLOCK_SIZE / 2;\n+\t\t\t\tblock.y = row * BLOCK_SIZE + BLOCK_SIZE / 2;\n+\t\t\t\tgrid[row][col] = block;\n+\t\t\t}\n+\t\t}\n+\t}\n+\tcreateGrid();\n+});\n+var Block = Container.expand(function (color) {\n+\tvar self = Container.call(this);\n+\tself.color = color;\n+\tvar blockGraphics = self.createAsset('block_' + color, 'Block Graphics', 0.5, 0.5);\n+});\n var Ghost = Container.expand(function () {\n \tvar self = Container.call(this);\n \tvar ghostGraphics = self.createAsset('ghost', 'Ghost character', .5, .5);\n \tself.move = function () {};\n@@ -18,37 +44,6 @@\n \tself.solve = function () {};\n });\n var Game = Container.expand(function () {\n \tvar self = Container.call(this);\n-\tLK.stageContainer.setBackgroundColor(0x000000);\n-\tvar hero = self.addChild(new Hero());\n-\thero.x = 2048 / 2;\n-\thero.y = 2732 / 2;\n-\tvar ghost = self.addChild(new Ghost());\n-\tghost.x = 2048 / 2;\n-\tghost.y = 2732 / 4;\n-\tvar puzzles = [];\n-\tfor (var i = 0; i < 5; i++) {\n-\t\tvar puzzle = self.addChild(new Puzzle());\n-\t\tpuzzle.x = 2048 / 2;\n-\t\tpuzzle.y = 2732 / 2 + i * 100;\n-\t\tpuzzles.push(puzzle);\n-\t}\n-\tvar scoreTxt = new Text2('0', {\n-\t\tsize: 150,\n-\t\tfill: "#ffffff"\n-\t});\n-\tscoreTxt.anchor.set(.5, 0);\n-\tLK.gui.topCenter.addChild(scoreTxt);\n-\tvar isGameOver = false;\n-\tLK.on('tick', function () {\n-\t\thero.update();\n-\t\tghost.update();\n-\t\tpuzzles.forEach(function (puzzle) {\n-\t\t\tpuzzle.update();\n-\t\t});\n-\t\tif (isGameOver) {\n-\t\t\tLK.effects.flashScreen(0xff0000, 1000);\n-\t\t\tLK.showGameOver();\n-\t\t}\n-\t});\n+\tvar match3Game = self.addChild(new Match3Game());\n });\n
"} Upit | Learn about creating the game ParaPuzzles 👻 with gen AI