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
});
block.y = 200; // 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.update = function () {
if (self.isSwinging) {
self.swingAngle += self.swingSpeed;
var swingOffset = Math.sin(self.swingAngle) * 200;
block.x = swingOffset;
// Update rope rotation to follow block
rope.rotation = Math.atan2(swingOffset, 200);
} 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 = stackHeight - 300; // Position above the stack
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 - 50) {
// Check horizontal alignment with top of stack
var topBlock = stackedBlocks[stackedBlocks.length - 1];
var horizontalDistance = Math.abs(blockPos.x - topBlock.x);
if (horizontalDistance < 100) {
// Successful stack
// Create new stacked block
var newStackedBlock = new StackedBlock();
newStackedBlock.x = blockPos.x;
newStackedBlock.y = stackHeight - 80;
game.addChild(newStackedBlock);
stackedBlocks.push(newStackedBlock);
// Update stack height
stackHeight -= 80;
// 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
if (stackHeight < gameHeight / 2) {
var targetY = Math.max(0, gameHeight / 2 - stackHeight);
game.y = targetY * 0.3; // Smooth camera follow
}
};
// Start the game
createNewSwingingBlock(); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,178 @@
-/****
+/****
+* 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
+ });
+ block.y = 200; // 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.update = function () {
+ if (self.isSwinging) {
+ self.swingAngle += self.swingSpeed;
+ var swingOffset = Math.sin(self.swingAngle) * 200;
+ block.x = swingOffset;
+ // Update rope rotation to follow block
+ rope.rotation = Math.atan2(swingOffset, 200);
+ } 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: 0x000000
-});
\ No newline at end of file
+ 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 = stackHeight - 300; // Position above the stack
+ 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 - 50) {
+ // Check horizontal alignment with top of stack
+ var topBlock = stackedBlocks[stackedBlocks.length - 1];
+ var horizontalDistance = Math.abs(blockPos.x - topBlock.x);
+ if (horizontalDistance < 100) {
+ // Successful stack
+ // Create new stacked block
+ var newStackedBlock = new StackedBlock();
+ newStackedBlock.x = blockPos.x;
+ newStackedBlock.y = stackHeight - 80;
+ game.addChild(newStackedBlock);
+ stackedBlocks.push(newStackedBlock);
+ // Update stack height
+ stackHeight -= 80;
+ // 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
+ if (stackHeight < gameHeight / 2) {
+ var targetY = Math.max(0, gameHeight / 2 - stackHeight);
+ game.y = targetY * 0.3; // Smooth camera follow
+ }
+};
+// Start the game
+createNewSwingingBlock();
\ No newline at end of file