User prompt
Bring bouncing ball infront of tiles
User prompt
Ass bouncingball asset to
User prompt
bring bouncing ball infront of grid
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in or related to this line: 'self.x = randomTopTile.x;' Line Number: 255
User prompt
start bouncing ball on top row of grid. display ball
User prompt
set a timer to randomly drop bouncing ball. time between 25 and 90 seconds
User prompt
add bouncing ball to code. Ball will drop on to first row tile and bounce its way down grid taking a random path. Only move ball in downward direction. bounce from one tile to another. when ball dropped keep it moving till it falls off grid
User prompt
add bouncing ball to code. Ball will drop on to first row tile and bounce its way down grid taking a random path. Only move ball in downward direction. bounce from one tile to another. when ball dropped keep it moving till it falls off grid
User prompt
when zbert moves then drop bouncing ball. add tick to allow ball to bounce down grid until it falls off
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'bouncingBall.x = topTile.x;' Line Number: 337
User prompt
add bouncing ball to code. Ball will drop on top tile and bounce its way down grid taking a random path. Only mov ball in downward direction. bounce from one tile to another
User prompt
when using upright control, if no tile available to jump to then jump and run fall routine
User prompt
when zbert reaches the end of the rows 1 to 7 and jumps using upright control then run fall routine
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
when Zbert is moving Up right or up left check when zberet is about to jump if a tile is there for Zebert to jump to if not jump and then have zebert fall to bottom of screen
Code edit (11 edits merged)
Please save this source code
User prompt
When Zbert jumps off last tile going up left or up right then run fall rountine
User prompt
When zebert moves up and to right check if tile exists below zbert. if not then run fall routine
Code edit (1 edits merged)
Please save this source code
User prompt
When zbert is jumping ignore additional control kep presses until after tile flip code run
User prompt
When Zbert moves from tile to tile create a smooth upward arc in direction of travel for Zbert
User prompt
Fix Bug: 'ReferenceError: startTime is not defined' in or related to this line: 'if (currentTime - startTime < hopDuration) {' Line Number: 59
User prompt
When Zbert moves from tile to tile animate a little hop
User prompt
When Zbert moves from tile to tile animate a little vertical hop
/**** * 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, alpha: 0.5 }); self.controlDirection = controlDirection; self.on('down', function (obj) { buttonGraphics.tint = 0x000000; // 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.isJumping = false; self.move = function (direction) { if (self.isJumping) { return; } self.isJumping = true; var moveX = 0; var moveY = 0; var tileWidth = 250; var tileHeight = 270; var arcHeight = 100; var targetX = self.x; var targetY = self.y; switch (direction) { case 'upLeft': targetX -= tileWidth / 2 + 2; targetY -= tileHeight - 90; break; case 'upRight': targetX += tileWidth / 2; targetY -= tileHeight - 90; break; case 'downLeft': targetX -= tileWidth / 2; targetY += tileHeight - 90; break; case 'downRight': targetX += tileWidth / 2; targetY += tileHeight - 90; break; } var startX = self.x; var startY = self.y; var distanceX = targetX - startX; var distanceY = targetY - startY; var startTime = Date.now(); var travelTime = 400; LK.on('tick', function () { var currentTime = Date.now(); var timeElapsed = currentTime - startTime; if (timeElapsed < travelTime) { var progress = timeElapsed / travelTime; var arcProgress = Math.sin(progress * Math.PI); self.x = startX + distanceX * progress; self.y = startY + distanceY * progress - arcHeight * arcProgress; } else { self.x = targetX; self.y = targetY; LK.off('tick'); self.isJumping = false; var tileBelow = game.grid.getTileAt(self.x, self.y + tileHeight); if (tileBelow) { tileBelow.flipColor(); } else { self.x = game.grid.x - self.width; self.y = 0; var fallToY = game.height - self.height / 2; var fallDuration = 4000; var fallStartTime = Date.now(); LK.on('tick', function () { var currentTime = Date.now(); var timeElapsed = currentTime - fallStartTime; if (timeElapsed < fallDuration) { var fallProgress = timeElapsed / fallDuration; self.y = fallProgress * fallToY; } else { self.y = fallToY; LK.off('tick'); self.isJumping = false; } }); } } }); }; 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 var tileColorCounter = { whiteCount: 0, greenCount: 0 }; // Object to keep track of tile colors // 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); for (var j = 0; j < numTilesInRow; j++) { var tile = new Tile(i, j, tileWidth, tileHeight, this.gridSize); tile.x = rowOffset + j * tileWidth; tile.y = i * (tileHeight - 90); self.addChild(tile); tileArray[i][j] = tile; if (i === this.gridSize - 1 && j === 0) { var zbert = new Zbert(tile.x, tile.y - 150, 180, 180); self.addChild(zbert); } } } }; // 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(); }, 500); } }; // 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 ? targetColours[targetColourIndex] : 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 = targetColours[targetColourIndex]; tileGraphics.tint = self.color; }; }); var TileColorCounter = Container.expand(function () { var self = Container.call(this); self.whiteCount = 0; self.greenCount = 0; // Method to update the counts of white and green tiles self.updateCounts = function (whiteCount, greenCount) { self.whiteCount = whiteCount; self.greenCount = greenCount; // Here you can add code to update the display of the counts if needed }; }); var BouncingBall = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('bouncingBall', { anchorX: 0.5, anchorY: 0.5 }); self.vx = 5; self.vy = -5; self.bounce = function () { self.x += self.vx; self.y += self.vy; if (self.x < 0 || self.x > 2048) { self.vx *= -1; } if (self.y < 0 || self.y > 2732) { self.vy *= -1; } }; }); /**** * 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 targetColours = [0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0x800000, 0x808000, 0x008000, 0x800080, 0x008080, 0x000080]; var targetColourIndex = 0; 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); // Add Corner asset to the screen var CCupL = game.addChild(new ControlButton('CCupL', -120, 2500, -45, 'upLeft')); var CCupR = game.addChild(new ControlButton('CCupR', 2168, 2512, 45, 'upRight')); var CCdownL = game.addChild(new ControlButton('CCdownL', 345, 2785, -45, 'downLeft')); var CCdownR = game.addChild(new ControlButton('CCdownR', 1700, 2800, 45, 'downRight')); // Add the grid to the game game.grid = game.addChild(new Grid()); game.grid.initGrid(); // Add bouncing ball after the grid to ensure it's in front of the tiles var bouncingBall = game.addChild(new BouncingBall()); bouncingBall.x = 1024; // Start in the middle of the screen horizontally bouncingBall.y = 1366; // Start in the middle of the screen vertically var tileWidth = 250; var tileHeight = 270; game.grid.x = (2048 - tileWidth * game.grid.gridSize) / 2 + tileWidth / 2; game.grid.y = (2732 - tileHeight * game.grid.gridSize) / 2 + tileHeight / 2 + 600; // 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 - 50; game.grid.y = (2732 - tileHeight * game.grid.gridSize) / 2 + tileHeight / 2 + 600; setBackgroundByNumber(Math.floor(Math.random() * 6) + 1); } else { LK.showGameOver(); // Show game over screen when max size is reached } }; LK.on('tick', function () { bouncingBall.bounce(); // Rest of the tick code... });
===================================================================
--- original.js
+++ change.js
@@ -242,11 +242,8 @@
/****
* Game Code
****/
-var bouncingBall = game.addChild(new BouncingBall());
-bouncingBall.x = 1024; // Start in the middle of the screen horizontally
-bouncingBall.y = 1366; // Start in the middle of the screen vertically
// Function to select and set background by variable number
var targetColours = [0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0x800000, 0x808000, 0x008000, 0x800080, 0x008080, 0x000080];
var targetColourIndex = 0;
var setBackgroundByNumber = function setBackgroundByNumber() {
@@ -273,8 +270,12 @@
var CCdownR = game.addChild(new ControlButton('CCdownR', 1700, 2800, 45, 'downRight'));
// Add the grid to the game
game.grid = game.addChild(new Grid());
game.grid.initGrid();
+// Add bouncing ball after the grid to ensure it's in front of the tiles
+var bouncingBall = game.addChild(new BouncingBall());
+bouncingBall.x = 1024; // Start in the middle of the screen horizontally
+bouncingBall.y = 1366; // Start in the middle of the screen vertically
var tileWidth = 250;
var tileHeight = 270;
game.grid.x = (2048 - tileWidth * game.grid.gridSize) / 2 + tileWidth / 2;
game.grid.y = (2732 - tileHeight * game.grid.gridSize) / 2 + tileHeight / 2 + 600;
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.