User prompt
ENSURE THAT THE NEXT ONE IS STOP ON THE TOP OF THE PREVIOUS ONE OR THE HORIZONTAL LINE
User prompt
do it
User prompt
why dont you stop the next bricks falling when they touch the previous one?
User prompt
Add collision event to every brick
User prompt
do it
User prompt
not working
User prompt
do it
User prompt
Add colision event to the bricks and stop them when they touch to each other
User prompt
then load the next cubic when the previous one has stopped
User prompt
the bricks loading is countinously
User prompt
do it
User prompt
Ensure that Stop the block rotation after it has stopped
User prompt
ensure that load to the map the next brick in time when the previous has stopped
User prompt
load the next brick unit when the previous is stopped
User prompt
Stop the block rotation after it has stopped
User prompt
ensure that the brick do not move after it stopped
User prompt
change it to the center of bricks unit
User prompt
Move the horizontal line down by 5 units
User prompt
Move the horizontal line down by 10 unitsuΜ
User prompt
Move the horizontal line down by 10 units
User prompt
load the center of the bricks from the top center of the map
User prompt
Change the center of rotation to the center of the bricks unit
User prompt
Change the center of rotation point from the left brick to the center of the bricks unit
User prompt
Change the pivot point of the bricks unit from the left brick to the center of the bricks unit
User prompt
change the bricks pivot point from the left brick to the center of the bricks unit
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define a class for Tetris blocks var TetrisBlock = Container.expand(function () { var self = Container.call(this); self.blocks = []; self.shape = 'I'; // Default shape // Initialize the block with a specific shape self.init = function (shape) { self.shape = shape; self.blocks.forEach(function (block) { return block.destroy(); }); self.blocks = []; // Create blocks based on the shape switch (shape) { case 'I': for (var i = 0; i < 4; i++) { var block = self.attachAsset('brick', { anchorX: 0.5, anchorY: 0.5 }); block.x = i * block.width; self.blocks.push(block); } break; case 'T': for (var i = 0; i < 3; i++) { var block = self.attachAsset('brick', { anchorX: 0.5, anchorY: 0.5 }); block.x = i * block.width; self.blocks.push(block); } var middleBlock = self.attachAsset('brick', { anchorX: 0.5, anchorY: 0.5 }); middleBlock.x = block.width; middleBlock.y = block.height; self.blocks.push(middleBlock); break; case 'Z': for (var i = 0; i < 2; i++) { var block = self.attachAsset('brick', { anchorX: 0.5, anchorY: 0.5 }); block.x = i * block.width; self.blocks.push(block); } for (var i = 0; i < 2; i++) { var block = self.attachAsset('brick', { anchorX: 0.5, anchorY: 0.5 }); block.x = (i + 1) * block.width; block.y = block.height; self.blocks.push(block); } break; } }; // Add rotation logic self.rotate = function () { if (self.update === function () {} || self.y + self.height >= 2732) { // Check if the block has stopped moving or reached the bottom return; // If it has, do not rotate } var centerX = 0; var centerY = 0; self.blocks.forEach(function (block) { centerX += block.x; centerY += block.y; }); centerX /= self.blocks.length; centerY /= self.blocks.length; self.blocks.forEach(function (block) { var x = block.y - centerY; var y = block.x - centerX; block.x = centerX - x; block.y = centerY + y; }); }; // Update the position of the block self.update = function () { if (self.y < 2732 / 2) { self.y += 5; // Move downwards } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize variables var tetrisBlocks = []; var currentBlock = null; var blockShapes = ['I', 'T', 'Z']; // Function to spawn a new block function spawnBlock() { var shape = blockShapes[Math.floor(Math.random() * blockShapes.length)]; currentBlock = new TetrisBlock(); currentBlock.init(shape); currentBlock.x = 1024 - currentBlock.width / 2; // Center horizontally currentBlock.y = 0; // Start at the top game.addChild(currentBlock); tetrisBlocks.push(currentBlock); } // Add screen asset to the top of the map var screen = game.attachAsset('screen', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 880 }); // Add horizontal line to the half of the map var horizontalLine = game.attachAsset('horizontalLine', { anchorX: 0.5, anchorY: 0.5, x: 1024 - 50, y: 1366 + 165 }); // Add a thin lined black frame 100 units from the top of the map and move it right by 650 units var frame = game.attachAsset('frame', { anchorX: 0.5, anchorY: 0.0, x: 1024 + 650, // Move the frame right by 650 units y: 100 }); // Add handconsole asset to the game background var handconsole = game.attachAsset('handconsole', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); game.setChildIndex(handconsole, game.children.length - 1); // Handle game update game.update = function () { if (!currentBlock) { spawnBlock(); } else { for (var i = 0; i < tetrisBlocks.length; i++) { if (currentBlock !== tetrisBlocks[i] && currentBlock.intersects(tetrisBlocks[i])) { currentBlock = null; spawnBlock(); break; } } if (currentBlock) { if (currentBlock.y + currentBlock.height > 2732) { currentBlock.y = 2732 - currentBlock.height; currentBlock.update = function () {}; // Stop the block from moving } else { currentBlock.update(); } } } if (!currentBlock) { spawnBlock(); } }; // Start the game by spawning the first block spawnBlock(); // Add click event to the game game.down = function (x, y, obj) { if (currentBlock) { currentBlock.rotate(); } else { spawnBlock(); } };
===================================================================
--- original.js
+++ change.js
@@ -66,15 +66,12 @@
}
};
// Add rotation logic
self.rotate = function () {
- if (self.update === function () {}) {
- // Check if the block has stopped moving
+ if (self.update === function () {} || self.y + self.height >= 2732) {
+ // Check if the block has stopped moving or reached the bottom
return; // If it has, do not rotate
}
- if (self.y + self.height >= 2732) {
- return; // If the block has reached the bottom, do not rotate
- }
var centerX = 0;
var centerY = 0;
self.blocks.forEach(function (block) {
centerX += block.x;