User prompt
when i drop a block from a crane, new block is apearing immediately which is not good. you should add an animation where crane gets that new block delayed, maybe it can take it from somewhere ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
when i drop a block there should be an animation where crane brings another block from outside of the scene
User prompt
increase swinging range meaning wiggling block should be more at the bottom
User prompt
increase the range and increase length of the rope
User prompt
when faulty alignment is close to right it does rotate and fall to right but when it is vice versa it still rotates and falls to right.
User prompt
use base_block asset for base block also make it bigger.
User prompt
maybe it should spin or something change rotation and trajectory when the block falls due to wrong alignment before game over.
User prompt
maybe it should spin or something change rotation and trajectory.
User prompt
the block doesnt fall before it says game over. cmon dont be lazy
User prompt
if a block is aligned not very correctly with previous block. the block should fall and game over
Code edit (1 edits merged)
Please save this source code
User prompt
blocks should fall faster
User prompt
not just that button check if every button is falling. every block should not be falling when you count for 5
User prompt
it shouldnt remove block while they are falling and less than 5
User prompt
okay there is an issue. it removes block while they are in the air. in order to remove block they should be touching.
User prompt
block is removed but the blocks above that block hangs in air like there is no gravity. fix it please
User prompt
Please fix the bug: 'Timeout.tick error: baseBlock is null' in or related to this line: 'baseBlock.y += 5;' Line Number: 162
User prompt
base block doesnt go down it doesnt count that as blocks
User prompt
Please fix the bug: 'TypeError: LK.playSound is not a function' in or related to this line: 'LK.playSound('gameover'); // Play game over sound' Line Number: 123
User prompt
Please fix the bug: 'TypeError: LK.playSound is not a function' in or related to this line: 'LK.playSound('place'); // Play the place sound' Line Number: 97
Code edit (1 edits merged)
Please save this source code
User prompt
when block at the bottom removed the blocks stacked on that block doesnt go down.
User prompt
it shouldnt remove and say it exceedes 5 before they make contact. because currently it removes while they are in air. also it doesnt slide down.
User prompt
you should include base block with that condition too. also when you destroy block. before destroying slide it to the bottom where it is invisible then destroy it.
User prompt
when stacked blocks exceedes 5 block remove a block at the bottom
/****
* Classes
****/
// Class for the base block
var BaseBlock = Container.expand(function () {
var self = Container.call(this);
var baseBlockGraphics = self.attachAsset('block', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Class for the blocks
var Block = Container.expand(function () {
var self = Container.call(this);
var blockGraphics = self.attachAsset('block', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.falling = false;
self.speed = 5;
self.update = function () {
if (self.falling) {
self.y += self.speed;
self.x += self.momentum;
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for the swinging crane
var Crane = Container.expand(function () {
var self = Container.call(this);
var craneGraphics = self.attachAsset('crane', {
anchorX: 0.5,
anchorY: 0.0
});
self.angle = 0;
self.speed = 0.03;
self.direction = 1;
self.update = function () {
self.angle += self.speed * self.direction;
if (self.angle > 1.5 || self.angle < -1.5) {
self.direction *= -1;
}
self.rotation = self.angle;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Initialize variables
var crane = game.addChild(new Crane());
var baseBlock = game.addChild(new BaseBlock());
baseBlock.x = 2048 / 2;
baseBlock.y = 2732 - baseBlock.height / 2;
crane.x = 2048 / 2;
crane.y = 50; // Move the crane up
var blocks = [];
var currentBlock = null;
var towerHeight = 0;
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to drop a block
function dropBlock() {
if (currentBlock && !currentBlock.falling) {
currentBlock.falling = true;
// Calculate the horizontal speed based on the crane's angular velocity
var horizontalSpeed = Math.sin(crane.rotation) * crane.speed * 10; // Reduced scaling factor
currentBlock.momentum = horizontalSpeed;
blocks.push(currentBlock);
currentBlock = null;
}
}
// Function to check for collisions and update score
function checkCollisions() {
for (var i = blocks.length - 1; i >= 0; i--) {
if (!blocks[i].falling) {
continue;
}
if (blocks[i].intersects(baseBlock)) {
blocks[i].falling = false;
blocks[i].y = baseBlock.y - baseBlock.height / 2 - blocks[i].height / 2 - towerHeight * 100;
towerHeight++;
LK.setScore(towerHeight);
scoreTxt.setText(LK.getScore());
} else {
for (var j = 0; j < blocks.length; j++) {
if (i !== j && blocks[i].falling && blocks[j].y < 2732 && !blocks[j].falling && blocks[i].intersects(blocks[j])) {
blocks[i].falling = false;
blocks[i].y = blocks[j].y - blocks[j].height / 2 - blocks[i].height / 2;
break;
}
}
if (blocks[i].falling && blocks[i].y > 2732) {
game.removeChild(blocks[i]);
blocks.splice(i, 1);
console.log("Block lost!");
}
}
}
}
// Game update loop
game.update = function () {
crane.update();
if (!currentBlock) {
currentBlock = new Block();
// Position the new block directly attached to the crane's end
currentBlock.x = crane.x + Math.sin(crane.rotation) * (crane.width / 2 + currentBlock.width / 2 + 200); // Increase the length of the rope
currentBlock.y = crane.y + Math.cos(crane.rotation) * (crane.height / 2 + currentBlock.height / 2 + 200); // Increase the length of the rope
game.addChild(currentBlock);
} else if (!currentBlock.falling) {
// Update the block's position to stay synced with the crane
currentBlock.x = crane.x + Math.sin(crane.rotation) * (crane.width / 2 + currentBlock.width / 2 + 200); // Increase the length of the rope
currentBlock.y = crane.y + Math.cos(crane.rotation) * (crane.height / 2 + currentBlock.height / 2 + 200); // Increase the length of the rope
}
if (currentBlock) {
currentBlock.update();
}
checkCollisions();
// Check if the number of blocks exceeds 5 and remove the bottom block
if (blocks.length > 5) {
var bottomBlock = blocks.shift();
game.removeChild(bottomBlock);
}
};
// Event listener for dropping blocks
game.down = function (x, y, obj) {
dropBlock();
};