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
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,37 @@
/****
* Classes
****/
+var BouncingBall = Container.expand(function () {
+ var self = Container.call(this);
+ self.direction = Math.random() > 0.5 ? 'left' : 'right';
+ self.isMoving = false;
+ self.move = function () {
+ if (!self.isMoving) {
+ return;
+ }
+ var tileWidth = 250;
+ var tileHeight = 270;
+ var targetX = self.x + (self.direction === 'left' ? -tileWidth / 2 : tileWidth / 2);
+ var targetY = self.y + tileHeight - 90;
+ var tileBelow = game.grid.getTileAt(targetX, targetY);
+ if (tileBelow) {
+ self.x = tileBelow.x;
+ self.y = tileBelow.y;
+ self.direction = Math.random() > 0.5 ? 'left' : 'right';
+ } else {
+ self.isMoving = false;
+ self.destroy();
+ }
+ };
+ var ballGraphics = self.attachAsset('tile', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFF0000
+ });
+ ballGraphics.width = 100;
+ ballGraphics.height = 100;
+});
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
@@ -76,39 +106,29 @@
self.x = targetX;
self.y = targetY;
LK.off('tick');
self.isJumping = false;
- // Drop a bouncing ball when Zbert moves
- var newBall = new BouncingBall();
- newBall.x = self.x;
- newBall.y = self.y;
- game.addChild(newBall);
var tileBelow = game.grid.getTileAt(self.x, self.y + tileHeight);
if (tileBelow) {
tileBelow.flipColor();
- } else if (direction === 'upRight' && !game.grid.getTileAt(targetX, targetY)) {
- // If moving upRight and no tile to jump to, run fall routine
- self.x = targetX;
- self.y = targetY;
+ } 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 = startY + (fallToY - startY) * fallProgress;
+ self.y = fallProgress * fallToY;
} else {
self.y = fallToY;
LK.off('tick');
self.isJumping = false;
}
});
- } else {
- // Reset Zbert's position to the starting tile
- self.x = game.grid.x - self.width;
- self.y = 0;
}
}
});
};
@@ -123,21 +143,8 @@
});
// Grid class to manage the puzzle grid
var Grid = Container.expand(function () {
var self = Container.call(this);
- // Method to get the tile below a given x and y position
- self.getTileBelow = function (x, y) {
- var tileBelow = null;
- var closestDistance = Number.MAX_VALUE;
- for (var i = 0; i < this.children.length; i++) {
- var tile = this.children[i];
- if (tile instanceof Tile && y < tile.y && Math.abs(x - tile.x) < closestDistance) {
- tileBelow = tile;
- closestDistance = Math.abs(x - tile.x);
- }
- }
- return tileBelow;
- };
// 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++) {
@@ -235,64 +242,8 @@
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);
- self.isBouncing = false;
- self.move = function () {
- if (!self.isBouncing) {
- return;
- }
- var possibleDirections = ['downLeft', 'downRight'];
- var direction = possibleDirections[Math.floor(Math.random() * possibleDirections.length)];
- var targetTile = game.grid.getTileBelow(self.x, self.y);
- if (targetTile) {
- var targetX = targetTile.x;
- var targetY = targetTile.y;
- var bounceHeight = 50;
- var travelTime = 300;
- var startTime = Date.now();
- var startX = self.x;
- var startY = self.y;
- var distanceX = targetX - startX;
- var distanceY = targetY - startY;
- 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 - bounceHeight * arcProgress;
- } else {
- self.x = targetX;
- self.y = targetY;
- LK.off('tick');
- self.isBouncing = false;
- }
- });
- }
- };
- var ballGraphics = self.attachAsset('tile', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- ballGraphics.tint = 0xFF0000; // Tint the ball red
- self.isBouncing = true;
- // Add a tick event to allow the ball to bounce down the grid
- LK.on('tick', function () {
- if (!self.isBouncing) {
- return;
- }
- var targetTile = game.grid.getTileBelow(self.x, self.y + tileHeight);
- if (targetTile) {
- self.move();
- } else {
- self.destroy(); // Destroy the ball when it falls off the grid
- }
- });
-});
/****
* Initialize Game
****/
@@ -345,13 +296,20 @@
setBackgroundByNumber(Math.floor(Math.random() * 6) + 1);
} else {
LK.showGameOver(); // Show game over screen when max size is reached
}
-}; // Initialize the bouncing ball and add it to the game
-var bouncingBall = game.addChild(new BouncingBall());
-var topTile = game.grid.children.find(function (child) {
+};
+var bouncingBall = new BouncingBall();
+var firstRowMiddleTile = game.grid.children.find(function (child) {
return child instanceof Tile && child.gridY === 0;
});
-if (topTile) {
- bouncingBall.x = topTile.x;
- bouncingBall.y = topTile.y - topTile.height;
-}
\ No newline at end of file
+if (firstRowMiddleTile) {
+ bouncingBall.x = firstRowMiddleTile.x;
+ bouncingBall.y = firstRowMiddleTile.y - 135; // Position the ball above the first tile
+ game.addChild(bouncingBall);
+ bouncingBall.isMoving = true;
+}
+LK.on('tick', function () {
+ if (bouncingBall.isMoving) {
+ bouncingBall.move();
+ }
+});
\ 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.