Code edit (1 edits merged)
Please save this source code
User prompt
in tile set cell Zbert starts on to target colour
Code edit (1 edits merged)
Please save this source code
User prompt
set flipped colour to target colour.. add target colours to array and start at index 0
User prompt
add variable called targetcolours. set a choice of 12 colours for this variable
Code edit (4 edits merged)
Please save this source code
User prompt
check when moving Zbert that if he is not on a tile then move Zbert back behind grid and let him fall to the bottom of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
check when moving Zbert that when button released he is on a tile. If not then move Zbert back behind grid and let him drop fast to the bottom of the screen
User prompt
check when moving Zbert that when button released he is on a tile. If not then move Zbert back behind grid and apply gravity
Code edit (3 edits merged)
Please save this source code
User prompt
Add alpha to control buttons
User prompt
when detecting the tile Zbert is on, pick the tile directly below Zbert
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: tileColorCounter.updateCounts is not a function' in or related to this line: 'tileColorCounter.updateCounts(tileColorCounter.whiteCount, tileColorCounter.greenCount);' Line Number: 117
User prompt
Fix Bug: 'Uncaught ReferenceError: tileColorCounter is not defined' in or related to this line: 'tileColorCounter.whiteCount++;' Line Number: 107
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: initializeTileColorCounter is not defined' in or related to this line: 'initializeTileColorCounter();' Line Number: 218
User prompt
remove tile colour counter from game
User prompt
when Zbert moves from one tile to the next detect where Zbert is and flip tile that Zbert interacts with
Code edit (7 edits merged)
Please save this source code
User prompt
When controlbuttons are pressed, tint buttons orange. remove tint when buttons are released
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Set rotation point of control buttons to centre point of asset
/**** * Classes ****/ var ControlButton = Container.expand(function (assetId, x, y, rotation, controlDirection) { var self = Container.call(this); self.on('up', function (obj) { buttonGraphics.tint = 0xFFFFFF; // Remove tint }); var buttonGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5, x: x, y: y, rotation: rotation }); self.controlDirection = controlDirection; self.on('down', function (obj) { buttonGraphics.tint = 0xFFA500; // Tint button orange var zbert = game.grid.children.find(function (child) { return child instanceof Zbert; }); if (zbert) { zbert.move(self.controlDirection); } }); }); var Zbert = Container.expand(function (gridX, gridY, width, height) { var self = Container.call(this); self.move = function (direction) { var moveX = 0; var moveY = 0; var tileWidth = 250; var tileHeight = 270; switch (direction) { case 'upLeft': moveX = -tileWidth / 2; moveY = -tileHeight + 90; break; case 'upRight': moveX = tileWidth / 2; moveY = -tileHeight + 90; break; case 'downLeft': moveX = -tileWidth / 2; moveY = tileHeight - 90; break; case 'downRight': moveX = tileWidth / 2; moveY = tileHeight - 90; break; } self.x += moveX; self.y += moveY; // Detect the tile Zbert is moving to and flip its color var currentTile = game.grid.getTileAt(self.x, self.y); if (currentTile) { currentTile.flipColor(); } }; var zbertGraphics = self.attachAsset('Zbert1', { anchorX: 0.5, anchorY: 0.5 }); zbertGraphics.width = width; zbertGraphics.height = height; self.x = gridX; self.y = gridY; }); // Grid class to manage the puzzle grid var Grid = Container.expand(function () { var self = Container.call(this); // Method to get the tile at a specific x and y position self.getTileAt = function (x, y) { for (var i = 0; i < tileArray.length; i++) { for (var j = 0; j < tileArray[i].length; j++) { var tile = tileArray[i][j]; if (x >= tile.x - tile.width / 2 && x <= tile.x + tile.width / 2 && y >= tile.y - tile.height / 2 && y <= tile.y + tile.height / 2) { return tile; } } } return null; }; this.gridSize = 13; // Gridsize control - 13 gives 7 wide middle var tileArray = []; // Array to hold the tiles // Initialize the grid with tiles self.initGrid = function () { var tileWidth = 250; var tileHeight = 270; for (var i = 0; i < this.gridSize; i++) { tileArray[i] = []; var numTilesInRow = i < 7 ? i + 1 : this.gridSize - i; var rowOffset = (this.gridSize - numTilesInRow) * (tileWidth / 2 + 5); for (var j = 0; j < numTilesInRow; j++) { var tile = new Tile(i, j, tileWidth, tileHeight, this.gridSize); tile.x = rowOffset + j * (tileWidth + 0); tile.y = i * (tileHeight - 90); self.addChild(tile); tileArray[i][j] = tile; // Attach Zbert to the left hand bottom grid cell if (i === this.gridSize - 1 && j === 0) { var zbert = new Zbert(tile.x, tile.y - 150, 180, 180); self.addChild(zbert); } // Update color counts if (tile.color === 0xFFFFFF) { tileColorCounter.whiteCount++; } else if (tile.color === 0x33d62a) { tileColorCounter.greenCount++; } // Update the TileColorCounter display with the new counts after reinitialization if (tileColorCounter) { tileColorCounter.updateCounts(tileColorCounter.whiteCount, tileColorCounter.greenCount); } } } }; // Function to flip the color of a tile and its neighbors self.flipTiles = function (x, y) { // Highlight the clicked tile in red var tileToFlip = tileArray[x][y]; if (tileToFlip) { tileToFlip.highlight(0xff0000); // Flip the tile color after a delay LK.setTimeout(function () { tileToFlip.flipColor(); }, 700); } // Update color counts after a delay to ensure it happens after all tiles have flipped LK.setTimeout(function () { var whiteCount = 0; var greenCount = 0; for (var i = 0; i < self.gridSize; i++) { for (var j = 0; j < tileArray[i].length; j++) { if (tileArray[i][j].color === 0xFFFFFF) { whiteCount++; } else if (tileArray[i][j].color === 0x33d62a) { greenCount++; } } } if (tileColorCounter) { tileColorCounter.updateCounts(whiteCount, greenCount); } // Check if either tile count is at 0 and run the win routine if so if (whiteCount === 0 || greenCount === 0) { game.showWin(); } }, 900); }; // Check if all tiles are the same color self.checkWinCondition = function () { var firstColor = tileArray[0][0].color; for (var i = 0; i < this.gridSize; i++) { for (var j = 0; j < tileArray[i].length; j++) { if (tileArray[i][j].color !== firstColor) { return false; } } } return true; }; }); var Tile = Container.expand(function (gridX, gridY, width, height, gridSize) { var self = Container.call(this); self.gridSize = gridSize; self.color = gridX === self.gridSize - 1 && gridY === 0 ? 0x33d62a : 0xFFFFFF; // Set all cells to white apart from the cell Zbert is on in the bottom left corner, set this cell to green var tileGraphics = self.attachAsset('tile', { anchorX: 0.5, anchorY: 0.5 }); tileGraphics.width = width; tileGraphics.height = height; tileGraphics.tint = self.color; // Function to highlight the tile self.highlight = function (color) { tileGraphics.tint = color; LK.setTimeout(function () { tileGraphics.tint = self.color; }, 500); // Reset tint after 500ms }; // Function to flip the color of the tile self.flipColor = function () { self.color = self.color === 0xFFFFFF ? 0x33d62a : 0xFFFFFF; tileGraphics.tint = self.color; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Function to select and set background by variable number var setBackgroundByNumber = function setBackgroundByNumber() { var backgroundNumber = Math.floor(Math.random() * 6) + 1; // Remove the current background if it exists if (game.background) { game.removeChild(game.background); } // Create a new background asset based on the provided number game.background = game.createAsset('backgroundImage' + backgroundNumber, {}); game.background.width = 3000; game.background.height = 3000; game.background.x = 2048 / 2 - game.background.width / 2; game.background.y = 2732 / 2 - game.background.height / 2; // Add the new background to the game game.addChildAt(game.background, 0); }; // Set an initial background setBackgroundByNumber(2); // Initialize the TileColorCounter and add it to the game initializeTileColorCounter(); // Add Corner asset to the screen var CCupL = game.addChild(new ControlButton('CCupL', -120, 2500, -45, 'upLeft')); var CCupR = game.addChild(new ControlButton('CCupR', 2098, 2732, -90, 'upRight')); var CCdownL = game.addChild(new ControlButton('CCdownL', 345, 2785, -45, 'downLeft')); var CCdownR = game.addChild(new ControlButton('CCdownR', 2098, 2732, -45, 'downRight')); // Add the grid to the game game.grid = game.addChild(new Grid()); game.grid.initGrid(); var tileWidth = 150; var tileHeight = 150; game.grid.x = (2048 - tileWidth * game.grid.gridSize) / 2 + tileWidth / 2 - 620; game.grid.y = (2732 - tileHeight * game.grid.gridSize) / 2 + tileHeight / 2 - 100; // Function to show win condition and increase grid size game.showWin = function () { LK.effects.flashScreen(0xFF0000, 1000); // Flash the screen green for 1 second if (game.grid.gridSize < 9) { game.grid.initGrid(); game.grid.x = (2048 - tileWidth * game.grid.gridSize) / 2 + tileWidth / 2 - 620; game.grid.y = (2732 - tileHeight * game.grid.gridSize) / 2 + tileHeight / 2 - 100; setBackgroundByNumber(Math.floor(Math.random() * 6) + 1); } else { LK.showGameOver(); // Show game over screen when max size is reached } };
===================================================================
--- original.js
+++ change.js
@@ -184,55 +184,8 @@
self.color = self.color === 0xFFFFFF ? 0x33d62a : 0xFFFFFF;
tileGraphics.tint = self.color;
};
});
-// TileColorCounter class to manage the count of each tile color
-var TileColorCounter = Container.expand(function () {
- var self = Container.call(this);
- this.whiteCount = 0;
- this.greenCount = 0;
- this.whiteTile = new TileCounter(0xFFFFFF);
- this.greenTile = new TileCounter(0x33d62a);
- // Position the tiles
- this.whiteTile.x = 180;
- this.whiteTile.y = 2732 - 2085;
- this.greenTile.x = 1570;
- this.greenTile.y = 2732 - 2085;
- // Add the tiles to the container
- self.addChild(this.whiteTile);
- self.addChild(this.greenTile);
- // Method to update the counts
- self.updateCounts = function (whiteCount, greenCount) {
- this.whiteTile.updateCount(whiteCount);
- this.greenTile.updateCount(greenCount);
- };
-});
-// TileCounter class to manage the display of each tile type count
-var TileCounter = Container.expand(function (color) {
- var self = Container.call(this);
- this.color = color;
- var tileGraphics = self.attachAsset('tile', {});
- tileGraphics.width = 350;
- tileGraphics.height = 400;
- tileGraphics.tint = this.color;
- this.countText = new Text2('0', {
- size: 230,
- weight: 800,
- fill: this.color === 0xFFFFFF ? "#000000" : "#ffffff",
- align: 'center'
- });
- this.countText.anchor.set(0.5);
- this.countText.x = tileGraphics.width / 2;
- this.countText.y = tileGraphics.height / 2;
- self.addChild(tileGraphics);
- self.addChild(this.countText);
- // Method to update the count
- self.updateCount = function (count) {
- if (typeof count !== 'undefined') {
- this.countText.setText(count.toString());
- }
- };
-});
/****
* Initialize Game
****/
@@ -285,11 +238,5 @@
setBackgroundByNumber(Math.floor(Math.random() * 6) + 1);
} else {
LK.showGameOver(); // Show game over screen when max size is reached
}
-};
-// Initialize the TileColorCounter and add it to the game
-var tileColorCounter;
-function initializeTileColorCounter() {
- tileColorCounter = game.addChild(new TileColorCounter());
-}
-initializeTileColorCounter();
\ No newline at end of file
+};
\ No newline at end of file
beautiful landscape. starry sky, pastel colours, high definition, alien world. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
beautiful landscape. starry sky, pastel colours, high definition, alien world.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
beautiful expansive landscape. starry sky, pastel colours, high definition, alien world.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
beautiful expansive landscape. starry sky, pastel colours, high definition, alien world.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A little cube person. 2 legs. back to viewer. facing 45 degrees to the right. multicoloured skin, cartoon style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white circle. metallic. light bevel on edge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Round furry, cute alien ball with big eyes. vivid colours, looking at 45 degrees to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bright 3d present with bow, vivd colours. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Change to be vivid multicoloured cube
A simple Triangle, flat shaded, bevelled edges. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Speech bubble with expletive word in it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
parachute. multicoloured. cartoon style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white circle with a single thin black border. flat shade. simple graphic. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
small star shape, vivid metallic blue, varying length spikes on star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.