User prompt
250 yap
User prompt
Üst blok konumunu biraz aşagı indir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Üst blogu biraz aşagı indir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İpin uzunlugunu kısalt blok ve ip temas bölgesi ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İp ve blok sallantısını saga ve sola dahada arttır ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İpi boyutu üstteki blok kesişim alanı kadar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yukardaki ipi üst blok düzeyinde kısalt ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Çarpma fizikleri düşme fiziklerini düzelt ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kırmızı blok aşagı düştükten sonra yeni bir blok yumutlanmalı ve döngü devam etmeli ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kırmızı blok aşagı düşdügünde ipte yeni bir blok yumurtlasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Düzelt ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bloklar arası çarpışma düşme fiziklerini ekle dogal olmalı ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İp sallantısı hiç durmasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Üstteki ip ve blok sallantısını daha stilize et ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yukardan düşen kırmızı blok alttakinin en az yarısını kaplamalı aksi halde kırmızı blok düşer ve oyuncu ölür ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mavi blogun üzerine Yerleştirilen ikinci kızmızı bloktan sonra mavi blok aşagı kayar kırmızı bloklar gözükür sonra her yerleştirilen kırmızı blokta 1 blok aşagı kayar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mavi blogu ekran alt kısmına taşi
User prompt
Eger kırmızı blok mavi blogun üzerine denk gelmez ise oyuncu ölür
User prompt
Olmuyor
User prompt
Eger üsttki blok mavi blogun üzerine düşerse oyuncu 1 puan kazanır
User prompt
Oyuncu dokundugunda üstteki blok için ipe sabitlenme kodunu iptal et ve blok aşagıya düşsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Amacım yukardaki bloga dokundugumda blogun aşagı düşmesi ve eger alttaki mavi blogun üzerine denk gelirse oyuncu 1 puan kazanıcak ayarla ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Hayır olmadı ipe baglı blok yere düşecek
User prompt
Şimdi oyuncu ekrana dokundugunda üsteki blok ayrılıp yere düşücek eger alttaki mavi karenin üzerine gelirse 1 puan ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Dahada
/**** * 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; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Game state var stackedBlocks = []; var gameHeight = 2732; var gameWidth = 2048; var groundLevel = gameHeight - 120; var stackHeight = 0; var gameActive = true; // Create foundation block var foundation = new StackedBlock(); foundation.x = gameWidth / 2; foundation.y = gameHeight - 120; // Move to bottom of screen game.addChild(foundation); stackedBlocks.push(foundation); stackHeight = foundation.y; // Create rope hanging from top center var rope = LK.getAsset('rope', { anchorX: 0.5, anchorY: 0 }); rope.x = gameWidth / 2; rope.y = 0; game.addChild(rope); // Create swinging block at the end of rope var swingingBlock = LK.getAsset('swingingBlock', { anchorX: 0.5, anchorY: 0.5 }); swingingBlock.x = 0; swingingBlock.y = rope.height; rope.addChild(swingingBlock); // Start rope swinging animation function startRopeSwing() { // Swing right tween(rope, { rotation: 0.5 }, { duration: 1500, easing: tween.easeInOut, onFinish: function onFinish() { // Swing left tween(rope, { rotation: -0.5 }, { duration: 3000, easing: tween.easeInOut, onFinish: function onFinish() { // Swing back right and repeat tween(rope, { rotation: 0.5 }, { duration: 3000, easing: tween.easeInOut, onFinish: startRopeSwing }); } }); } }); } // Start the swinging motion startRopeSwing(); // Score display var scoreTxt = new Text2('Blocks: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Touch handler to drop the block game.down = function (x, y, obj) { if (!gameActive || !swingingBlock.parent) return; // Get the current world position of the swinging block var worldPos = rope.toGlobal(swingingBlock.position); var gamePos = game.toLocal(worldPos); // Detach from rope and add to game rope.removeChild(swingingBlock); game.addChild(swingingBlock); // Set position in game coordinates swingingBlock.x = gamePos.x; swingingBlock.y = gamePos.y; // Add falling velocity swingingBlock.velocityY = 0; swingingBlock.gravity = 0.8; swingingBlock.falling = true; }; // Update function for falling blocks game.update = function () { if (swingingBlock.falling) { swingingBlock.velocityY += swingingBlock.gravity; swingingBlock.y += swingingBlock.velocityY; // Check collision with any stacked block var hasCollision = false; for (var i = 0; i < stackedBlocks.length; i++) { if (swingingBlock.intersects(stackedBlocks[i])) { hasCollision = true; break; } } if (hasCollision) { // Find the topmost block that the swinging block collided with var targetBlock = null; var highestY = gameHeight; for (var k = 0; k < stackedBlocks.length; k++) { if (swingingBlock.intersects(stackedBlocks[k]) && stackedBlocks[k].y < highestY) { targetBlock = stackedBlocks[k]; highestY = stackedBlocks[k].y; } } if (targetBlock) { // Check if the swinging block covers at least half of the target block var swingingLeft = swingingBlock.x - swingingBlock.width / 2; var swingingRight = swingingBlock.x + swingingBlock.width / 2; var targetLeft = targetBlock.x - targetBlock.width / 2; var targetRight = targetBlock.x + targetBlock.width / 2; // Calculate overlap var overlapLeft = Math.max(swingingLeft, targetLeft); var overlapRight = Math.min(swingingRight, targetRight); var overlapWidth = Math.max(0, overlapRight - overlapLeft); // Check if overlap is at least half of the target block width var requiredCoverage = targetBlock.width / 2; if (overlapWidth >= requiredCoverage) { // Award 1 point LK.setScore(LK.getScore() + 1); scoreTxt.setText('Blocks: ' + LK.getScore()); // Place block on stack swingingBlock.falling = false; swingingBlock.velocityY = 0; stackHeight -= 240; // Move stack up by block height swingingBlock.y = stackHeight; stackedBlocks.push(swingingBlock); // If this is the second red block (score 2), start sliding foundation down if (LK.getScore() >= 2) { // Move foundation and all stacked blocks down by one block height for (var j = 0; j < stackedBlocks.length; j++) { tween(stackedBlocks[j], { y: stackedBlocks[j].y + 240 }, { duration: 500, easing: tween.easeInOut }); } // Update stack height stackHeight += 240; } // Create new swinging block swingingBlock = LK.getAsset('swingingBlock', { anchorX: 0.5, anchorY: 0.5 }); swingingBlock.x = 0; swingingBlock.y = rope.height; rope.addChild(swingingBlock); } else { // Not enough coverage - continue falling swingingBlock.falling = true; } } } // Check if block has fallen below the screen else if (swingingBlock.y > gameHeight + 200) { // Game over - player missed the target gameActive = false; LK.showGameOver(); } } }; ;
===================================================================
--- original.js
+++ change.js
@@ -123,39 +123,66 @@
break;
}
}
if (hasCollision) {
- // Award 1 point
- LK.setScore(LK.getScore() + 1);
- scoreTxt.setText('Blocks: ' + LK.getScore());
- // Place block on stack
- swingingBlock.falling = false;
- swingingBlock.velocityY = 0;
- stackHeight -= 240; // Move stack up by block height
- swingingBlock.y = stackHeight;
- stackedBlocks.push(swingingBlock);
- // If this is the second red block (score 2), start sliding foundation down
- if (LK.getScore() >= 2) {
- // Move foundation and all stacked blocks down by one block height
- for (var j = 0; j < stackedBlocks.length; j++) {
- tween(stackedBlocks[j], {
- y: stackedBlocks[j].y + 240
- }, {
- duration: 500,
- easing: tween.easeInOut
+ // Find the topmost block that the swinging block collided with
+ var targetBlock = null;
+ var highestY = gameHeight;
+ for (var k = 0; k < stackedBlocks.length; k++) {
+ if (swingingBlock.intersects(stackedBlocks[k]) && stackedBlocks[k].y < highestY) {
+ targetBlock = stackedBlocks[k];
+ highestY = stackedBlocks[k].y;
+ }
+ }
+ if (targetBlock) {
+ // Check if the swinging block covers at least half of the target block
+ var swingingLeft = swingingBlock.x - swingingBlock.width / 2;
+ var swingingRight = swingingBlock.x + swingingBlock.width / 2;
+ var targetLeft = targetBlock.x - targetBlock.width / 2;
+ var targetRight = targetBlock.x + targetBlock.width / 2;
+ // Calculate overlap
+ var overlapLeft = Math.max(swingingLeft, targetLeft);
+ var overlapRight = Math.min(swingingRight, targetRight);
+ var overlapWidth = Math.max(0, overlapRight - overlapLeft);
+ // Check if overlap is at least half of the target block width
+ var requiredCoverage = targetBlock.width / 2;
+ if (overlapWidth >= requiredCoverage) {
+ // Award 1 point
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText('Blocks: ' + LK.getScore());
+ // Place block on stack
+ swingingBlock.falling = false;
+ swingingBlock.velocityY = 0;
+ stackHeight -= 240; // Move stack up by block height
+ swingingBlock.y = stackHeight;
+ stackedBlocks.push(swingingBlock);
+ // If this is the second red block (score 2), start sliding foundation down
+ if (LK.getScore() >= 2) {
+ // Move foundation and all stacked blocks down by one block height
+ for (var j = 0; j < stackedBlocks.length; j++) {
+ tween(stackedBlocks[j], {
+ y: stackedBlocks[j].y + 240
+ }, {
+ duration: 500,
+ easing: tween.easeInOut
+ });
+ }
+ // Update stack height
+ stackHeight += 240;
+ }
+ // Create new swinging block
+ swingingBlock = LK.getAsset('swingingBlock', {
+ anchorX: 0.5,
+ anchorY: 0.5
});
+ swingingBlock.x = 0;
+ swingingBlock.y = rope.height;
+ rope.addChild(swingingBlock);
+ } else {
+ // Not enough coverage - continue falling
+ swingingBlock.falling = true;
}
- // Update stack height
- stackHeight += 240;
}
- // Create new swinging block
- swingingBlock = LK.getAsset('swingingBlock', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- swingingBlock.x = 0;
- swingingBlock.y = rope.height;
- rope.addChild(swingingBlock);
}
// Check if block has fallen below the screen
else if (swingingBlock.y > gameHeight + 200) {
// Game over - player missed the target