User prompt
Until it's in the middle of the screen
User prompt
Can you make it so the player block starts near the bottom and goes up
User prompt
Update the part where it checks if the block has a block directly under it to only check downward the height of the blocks
User prompt
Can you make it a thin line
User prompt
Can you make the outline go around the edge of the hitbox
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var hitboxOutline = new Graphics();' Line Number: 24
User prompt
Can you add a red line the outlines all the hitboxes
User prompt
If the code checks the newly placed block and all the other blocks for overlaps then can you remove the part where the code checks the other blocks
User prompt
Can you make it so if the overlap isn't 100% it is touching
User prompt
Can you temporarily move the player block down so quarter of it is inside the placed block
Code edit (1 edits merged)
Please save this source code
User prompt
Can you make hitbox of every block one px taller
User prompt
A little more
User prompt
Move it a little to the left
User prompt
Can you put it under the score
User prompt
Can you temporarily add a thing that says what made you lose the game
User prompt
Make it so if the player block is not touching anything then the game will end
User prompt
Can you make it so when the game changes the visual size it also changes the blocks hitbox by the same amount
User prompt
Make the playerBlocks hitbox match the size of the playerBlocks visual size
User prompt
Make the player go to the start after each block placement
Code edit (1 edits merged)
Please save this source code
User prompt
The starting block should be in the center but the player should start on the left
User prompt
Make the player spawn more on the left
User prompt
Ot only cut the overlap on the right if the overlap is on the left it still cuts the right side
User prompt
Everything that doesn't have a block directly under it (except the starting block) should be cut off
/**** * Classes ****/ // Assets will be automatically created and loaded by the LK engine based on usage in the code. // Block class for stackable game blocks var Block = Container.expand(function () { var self = Container.call(this); // Attach a square asset to represent the block var blockGraphics = self.attachAsset('block', { width: 600, height: 150, color: 0xFFFFFF, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); }); // HeightIndicator class for the height indicator var HeightIndicator = Container.expand(function () { var self = Container.call(this); // Attach a Text2 object to represent the height indicator var heightIndicatorText = new Text2('0', { size: 50, fill: "#ffffff" }); self.addChild(heightIndicatorText); // Update method called every game tick self.update = function () { // Update the text to display the current height heightIndicatorText.setText(blocks.length); }; }); // Player class for the block that the player controls var PlayerBlock = Container.expand(function () { var self = Container.call(this); // Attach a square asset to represent the player block var playerBlockGraphics = self.attachAsset('playerBlock', { width: 600, height: 150, color: 0xFFD700, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); // Set initial speed for horizontal movement self.speed = 5; // Direction of movement, 1 for right, -1 for left self.direction = 1; // Update method called every game tick self.update = function () { // Move the player block left or right self.x += self.speed * self.direction; // Reverse direction when hitting screen bounds if (self.x <= 300 || self.x >= 1748) { self.direction *= -1; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize height indicator var heightIndicator = game.addChild(new HeightIndicator()); // Set initial position of the height indicator heightIndicator.x = 1024; // Center of the screen heightIndicator.y = 100; // Near the top // Initialize player block var playerBlock = game.addChild(new PlayerBlock()); // Set initial position of the player block playerBlock.x = 1024; // Center of the screen playerBlock.y = 1366; // Middle of the screen // Initialize an array to keep track of stacked blocks var blocks = []; // Add a starting block to the game addBlock(); // Function to add a new block to the stack function addBlock() { var block = new Block(); block.x = playerBlock.x; // Set the new block's position to the player block's current position block.y = playerBlock.y + 150; // Position it under the player block blocks.push(block); // Add the new block to the array game.addChild(block); // Add the new block to the game // Move all existing blocks down for (var i = 0; i < blocks.length - 1; i++) { blocks[i].y += 150; } // Cut off the part of the block that doesn't have a block under it and adjust the size of the player block if (blocks.length > 1) { var previousBlock = blocks[blocks.length - 2]; var overlap = block.x - previousBlock.x; if (overlap > 0) { block.width -= overlap; block.x -= overlap / 2; } else if (overlap < 0) { block.width += overlap; block.x -= overlap / 2; playerBlock.x += overlap; } // Update the size of the player block to match the size of the overlap with the last placed block playerBlock.width = block.width; } // Update the size of the placed block to match the size of the player block block.width = playerBlock.width; // Check if the placed block is touching any other blocks var isTouching = false; for (var i = 0; i < blocks.length - 1; i++) { if (block.intersects(blocks[i])) { isTouching = true; break; } } // If the placed block is not touching any other blocks and it's not the first block, end the game if (!isTouching && blocks.length > 1) {} } // Event listener for touch or mouse down to place the player block var canPlaceBlock = true; game.down = function (x, y, obj) { if (canPlaceBlock) { addBlock(); // Add the current player block to the stack canPlaceBlock = false; LK.setTimeout(function () { canPlaceBlock = true; }, 100); // Check if the placed block is touching any other blocks var isTouching = false; for (var i = 0; i < blocks.length - 1; i++) { if (blocks[blocks.length - 1].intersects(blocks[i])) { isTouching = true; break; } } // If the placed block is not touching any other blocks and it's not the first block, end the game LK.setTimeout(function () { if (!isTouching && blocks.length > 1) {} }, 32); } }; // Update function called every game tick game.update = function () { // Removed the game over condition when the score reaches 20 // Update the height indicator heightIndicator.update(); }; // Note: The game does not handle dynamic resizing, orientation changes, or provide pause functionality as per the LK engine's automatic handling.
===================================================================
--- original.js
+++ change.js
@@ -100,9 +100,10 @@
block.width -= overlap;
block.x -= overlap / 2;
} else if (overlap < 0) {
block.width += overlap;
- block.x += overlap / 2;
+ block.x -= overlap / 2;
+ playerBlock.x += overlap;
}
// Update the size of the player block to match the size of the overlap with the last placed block
playerBlock.width = block.width;
}