User prompt
after first blocks makes contact with the base block on bottom other blocks are not falling.
User prompt
when a block reaches to bottom the game kind of stops. i mean when i drop other blocks they are not falling they are just stuck on crane. you can fix it by adding a base block where player stacks the blocks onto. oh and when you are adding that make sure they dont go through themselves and stack
User prompt
when a block reaches bottom the game stops and i cant release any more blocks. fix that.
User prompt
the block i dropped from crane goes through basis block. it should stack instead.
User prompt
the game stops when block hits the bottom and i can release any more blocks. i suppose you think that the game is over but there is no basis block to drop to. so add a basis block so i can stack on that.
User prompt
now they are moving in opposite directions. i want block on the crane move synced with crane
User prompt
block on crane is not moving with the crane
User prompt
first block is too close to the block on the crane. fix that
User prompt
regardless of the crane motion and when i release the block, the block falls from same place everytime so please fix that.
Initial prompt
Skyline Stacker
===================================================================
--- original.js
+++ change.js
@@ -1,97 +1,97 @@
-/****
+/****
* Classes
-****/
+****/
// 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
- });
- self.falling = false;
- self.speed = 5;
- self.update = function () {
- if (self.falling) {
- self.y += self.speed;
- }
- };
+ var self = Container.call(this);
+ var blockGraphics = self.attachAsset('block', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.falling = false;
+ self.speed = 5;
+ self.update = function () {
+ if (self.falling) {
+ self.y += self.speed;
+ }
+ };
});
//<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.05;
- self.direction = 1;
- self.update = function () {
- self.angle += self.speed * self.direction;
- if (self.angle > 0.5 || self.angle < -0.5) {
- self.direction *= -1;
- }
- self.rotation = self.angle;
- };
+ var self = Container.call(this);
+ var craneGraphics = self.attachAsset('crane', {
+ anchorX: 0.5,
+ anchorY: 0.0
+ });
+ self.angle = 0;
+ self.speed = 0.05;
+ self.direction = 1;
+ self.update = function () {
+ self.angle += self.speed * self.direction;
+ if (self.angle > 0.5 || self.angle < -0.5) {
+ self.direction *= -1;
+ }
+ self.rotation = self.angle;
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x87CEEB // Sky blue background
+ backgroundColor: 0x87CEEB // Sky blue background
});
-/****
+/****
* Game Code
-****/
+****/
// Initialize variables
var crane = game.addChild(new Crane());
crane.x = 2048 / 2;
crane.y = 200;
var blocks = [];
var currentBlock = null;
var towerHeight = 0;
var scoreTxt = new Text2('0', {
- size: 100,
- fill: 0xFFFFFF
+ 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 = true;
- blocks.push(currentBlock);
- currentBlock = null;
- }
+ if (currentBlock) {
+ currentBlock.falling = true;
+ 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].y > 2732 - towerHeight * 100) {
- blocks[i].falling = false;
- towerHeight++;
- LK.setScore(towerHeight);
- scoreTxt.setText(LK.getScore());
- }
- }
+ for (var i = blocks.length - 1; i >= 0; i--) {
+ if (blocks[i].y > 2732 - towerHeight * 100) {
+ blocks[i].falling = false;
+ towerHeight++;
+ LK.setScore(towerHeight);
+ scoreTxt.setText(LK.getScore());
+ }
+ }
}
// Game update loop
game.update = function () {
- crane.update();
- if (!currentBlock) {
- currentBlock = new Block();
- currentBlock.x = crane.x;
- currentBlock.y = crane.y + 100;
- game.addChild(currentBlock);
- }
- currentBlock.update();
- checkCollisions();
+ crane.update();
+ if (!currentBlock) {
+ currentBlock = new Block();
+ currentBlock.x = crane.x + Math.sin(crane.rotation) * 100;
+ currentBlock.y = crane.y + Math.cos(crane.rotation) * 100;
+ game.addChild(currentBlock);
+ }
+ currentBlock.update();
+ checkCollisions();
};
// Event listener for dropping blocks
game.down = function (x, y, obj) {
- dropBlock();
+ dropBlock();
};
\ No newline at end of file