User prompt
Dahada büyült
User prompt
Alt blok ve üst blok boyutlarını eşitle ve büyüt
User prompt
Üstteki kutuyu ipe yapıştır ve ip nereye giderse kutu oraya gitsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Üstteki blok ip ile kordineli saga sola sallanmal ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Şimdi bu ipin ucuna bir kare yap bu kare iple baraber sallanıcak ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Biraz daha sallansın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bu ip saga ve sola sallanıcak ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Şimdi bana tam ortadan aşagı inecek şekilde bir ip yap aşagı uzunlugu orta kısmın biraz üzerinde kalsın
User prompt
Ozaman ipi ve blogu sil tekrar kodlıcaz
User prompt
Üstteki blok ve ipi birleştir ikisi kordine hareket etsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Üstteki ip be blok ekran dısında kalıyor
User prompt
Üstten gelen blogu iple birleştir ve ekran tepesine sabitle
User prompt
Blokları kare yap ve büyüt
User prompt
Blok dimini ekran bitişinde kayboluyor neden oyun sonsuza kadar yukarı dogru ddvam etmeli
Code edit (1 edits merged)
Please save this source code
User prompt
City Bloxx - Stack the Blocks
Initial prompt
Ctiy bloxx oyunu yapıcaz anlatıyorum zemine bir kutu koyucaz sonra yukardan bir ip ucunda yeni bir blok dogacak dogan blok saga sola sallanıcak oyuncu dokundugunda aşagı düşecek amac blokları üst üste yerleştirmek
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var StackedBlock = Container.expand(function () {
var self = Container.call(this);
var block = self.attachAsset('block', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var SwingingBlock = Container.expand(function () {
var self = Container.call(this);
// Create rope
var rope = self.attachAsset('rope', {
anchorX: 0.5,
anchorY: 0
});
// Create block attached to rope
var block = self.attachAsset('block', {
anchorX: 0.5,
anchorY: 0.5
});
// Swing properties
self.swingAngle = 0;
self.swingSpeed = 0.05;
self.swingRadius = Math.PI / 3; // 60 degrees swing
self.isSwinging = true;
self.isFalling = false;
self.ropeLength = 250;
// Position rope at top of screen (fixed anchor point)
rope.y = 0;
self.update = function () {
if (self.isSwinging) {
self.swingAngle += self.swingSpeed;
var swingOffset = Math.sin(self.swingAngle) * 200; // Horizontal swing distance
// Position block at end of rope
block.x = swingOffset;
block.y = self.ropeLength;
// Update rope rotation to follow block
rope.rotation = Math.atan2(swingOffset, self.ropeLength);
// Adjust rope height to reach the block
rope.height = self.ropeLength;
} else if (self.isFalling) {
block.y += 8; // Fall speed
}
};
self.drop = function () {
if (self.isSwinging) {
self.isSwinging = false;
self.isFalling = true;
rope.visible = false; // Hide rope when dropped
LK.getSound('drop').play();
}
};
self.getBlockPosition = function () {
return {
x: self.x + block.x,
y: self.y + block.y
};
};
self.getBlock = function () {
return block;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game state
var stackedBlocks = [];
var currentSwingingBlock = null;
var gameHeight = 2732;
var gameWidth = 2048;
var groundLevel = gameHeight - 200;
var stackHeight = 0;
var gameActive = true;
// Create foundation block
var foundation = new StackedBlock();
foundation.x = gameWidth / 2;
foundation.y = groundLevel;
game.addChild(foundation);
stackedBlocks.push(foundation);
stackHeight = foundation.y;
// Score display
var scoreTxt = new Text2('Blocks: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create first swinging block
function createNewSwingingBlock() {
if (currentSwingingBlock) {
currentSwingingBlock.destroy();
}
currentSwingingBlock = new SwingingBlock();
currentSwingingBlock.x = gameWidth / 2;
currentSwingingBlock.y = 50; // Fixed position at top of screen
game.addChild(currentSwingingBlock);
}
// Check if dropped block landed on stack
function checkBlockLanding(droppedBlock) {
var blockPos = droppedBlock.getBlockPosition();
var block = droppedBlock.getBlock();
// Check if block has fallen to stack level
if (blockPos.y >= stackHeight - 60) {
// Check horizontal alignment with top of stack
var topBlock = stackedBlocks[stackedBlocks.length - 1];
var horizontalDistance = Math.abs(blockPos.x - topBlock.x);
if (horizontalDistance < 80) {
// Successful stack
// Create new stacked block
var newStackedBlock = new StackedBlock();
newStackedBlock.x = blockPos.x;
newStackedBlock.y = stackHeight - 120;
game.addChild(newStackedBlock);
stackedBlocks.push(newStackedBlock);
// Update stack height
stackHeight -= 120;
// Update score
LK.setScore(LK.getScore() + 1);
scoreTxt.setText('Blocks: ' + LK.getScore());
// Remove swinging block
currentSwingingBlock.destroy();
currentSwingingBlock = null;
// Play stack sound
LK.getSound('stack').play();
// Create next block after short delay
LK.setTimeout(function () {
if (gameActive) {
createNewSwingingBlock();
}
}, 500);
} else {
// Missed stack - game over
gameActive = false;
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
}
// Check if block fell off screen
if (blockPos.y > gameHeight + 100) {
gameActive = false;
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
}
}
// Touch/tap handler
game.down = function (x, y, obj) {
if (currentSwingingBlock && gameActive) {
currentSwingingBlock.drop();
}
};
// Main game update loop
game.update = function () {
if (!gameActive) return;
// Check if dropped block needs landing check
if (currentSwingingBlock && currentSwingingBlock.isFalling) {
checkBlockLanding(currentSwingingBlock);
}
// Move camera up as tower grows (infinite upward movement)
var targetY = gameHeight / 2 - stackHeight;
game.y = targetY * 0.3; // Smooth camera follow
};
// Start the game
createNewSwingingBlock(); ===================================================================
--- original.js
+++ change.js
@@ -23,24 +23,30 @@
});
// Create block attached to rope
var block = self.attachAsset('block', {
anchorX: 0.5,
- anchorY: 0
+ anchorY: 0.5
});
- block.y = 250; // Position block at end of rope
// Swing properties
self.swingAngle = 0;
self.swingSpeed = 0.05;
self.swingRadius = Math.PI / 3; // 60 degrees swing
self.isSwinging = true;
self.isFalling = false;
+ self.ropeLength = 250;
+ // Position rope at top of screen (fixed anchor point)
+ rope.y = 0;
self.update = function () {
if (self.isSwinging) {
self.swingAngle += self.swingSpeed;
- var swingOffset = Math.sin(self.swingAngle) * 250;
+ var swingOffset = Math.sin(self.swingAngle) * 200; // Horizontal swing distance
+ // Position block at end of rope
block.x = swingOffset;
+ block.y = self.ropeLength;
// Update rope rotation to follow block
- rope.rotation = Math.atan2(swingOffset, 250);
+ rope.rotation = Math.atan2(swingOffset, self.ropeLength);
+ // Adjust rope height to reach the block
+ rope.height = self.ropeLength;
} else if (self.isFalling) {
block.y += 8; // Fall speed
}
};
@@ -102,13 +108,9 @@
currentSwingingBlock.destroy();
}
currentSwingingBlock = new SwingingBlock();
currentSwingingBlock.x = gameWidth / 2;
- currentSwingingBlock.y = stackHeight - 350; // Position above the stack
- // Ensure rope and block are always visible above current stack
- if (currentSwingingBlock.y < -200) {
- currentSwingingBlock.y = stackHeight - 350;
- }
+ currentSwingingBlock.y = 50; // Fixed position at top of screen
game.addChild(currentSwingingBlock);
}
// Check if dropped block landed on stack
function checkBlockLanding(droppedBlock) {