User prompt
Kırpma özelligi içün animasyon ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Çarpışma saglandıktan sonra carpışma alanı dısındaki alanı kes
User prompt
Uygula ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
2 blok yanyana geliyor
User prompt
Blokların hepsi birlikte kayar
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(bottomBlock, {' Line Number: 150 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yere 5 blok yerleştikten sonra gelen 6. Blok yerleştiginde alttaki blok bir blok kadar ekrandan aşagı kayar
User prompt
Gerçekçi animasyonlarla degiştir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Çarpma ve düşme animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Olmadıkı yine 2 blok yanyana gelebiliyor ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Çözümü uygula ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyun zemini ekle
User prompt
Hedef kaynagı ekle düzenle
User prompt
Çözüm ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Herşeyi olması gerektigi gibi düzelt ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Çözüm uygula ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Gerekli düzenlemeleri yap
User prompt
Düşme animasyonu sil başka ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Düşme animasyonunu yenisisiyle degiştir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mevcut düşme animasyonunu sil Farklı bir düşme animasyonu dene ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Düşme animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Çarpışma animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yumuşak geçişler saglar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
5 blok yerleştikten sonra en alttaki bloklar bir blok aşagı kayar bu sürekli devam eder
User prompt
Başlangıcta yerleştirilen 6 bloktan sonra ekran her blok yerleşiminde alttan bir blok siler
/**** * 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; // Rope starts at top of screen 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 + 100; // Extend the rope length by moving block further down rope.addChild(swingingBlock); // Natural pendulum swing variables var swingTime = 0; var swingSpeed = 0.03; // Controls swing speed var swingAmplitude = 0.6; // Controls swing range (max rotation) // 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 = 25; // Start with constant speed swingingBlock.falling = true; }; // Update function for falling blocks game.update = function () { // Update rope swing with realistic pendulum physics if (rope && !swingingBlock.falling) { swingTime += swingSpeed; // Natural pendulum motion with slight dampening var pendulumMotion = Math.sin(swingTime) * swingAmplitude; rope.rotation = pendulumMotion; // Realistic vertical motion based on pendulum physics var verticalOffset = Math.abs(Math.cos(swingTime)) * 25; // Natural arc motion swingingBlock.y = rope.height + 100 + verticalOffset; // Add subtle rope flex effect rope.scaleX = 1.0 + Math.abs(pendulumMotion) * 0.1; // Block tilts naturally with momentum swingingBlock.rotation = pendulumMotion * 0.3; } if (swingingBlock.falling) { // Use constant falling speed instead of accelerating gravity swingingBlock.velocityY = 25; // Fixed falling speed swingingBlock.y += swingingBlock.velocityY; // Add realistic falling animation effects if (!swingingBlock.fallingAnimationStarted) { swingingBlock.fallingAnimationStarted = true; // Realistic tumbling rotation - slower and more natural tween(swingingBlock, { rotation: Math.PI * 0.8 + (Math.random() - 0.5) * 0.4 }, { duration: 800, easing: tween.easeOut }); // Air resistance effect - slight compression tween(swingingBlock, { scaleX: 0.95, scaleY: 1.05 }, { duration: 300, easing: tween.easeInOut, onFinish: function onFinish() { // Return to normal with slight overshoot tween(swingingBlock, { scaleX: 1.02, scaleY: 0.98 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(swingingBlock, { scaleX: 1.0, scaleY: 1.0 }, { duration: 150, easing: tween.easeOut }); } }); } }); } // Check collision with any stacked block using built-in intersects method var hasCollision = false; for (var i = 0; i < stackedBlocks.length; i++) { var block = stackedBlocks[i]; if (swingingBlock.intersects(block)) { 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 block is close enough to the top of the target block to land var blockBottom = swingingBlock.y + swingingBlock.height / 2; var targetTop = targetBlock.y - targetBlock.height / 2; var landingDistance = Math.abs(blockBottom - targetTop); // Only land if we're within reasonable landing distance (less than falling speed) if (landingDistance <= 30) { // Award 1 point LK.setScore(LK.getScore() + 1); scoreTxt.setText('Blocks: ' + LK.getScore()); // Place block exactly on top of target block with smooth transition swingingBlock.falling = false; swingingBlock.velocityY = 0; var targetLandingY = targetBlock.y - 240; // Calculate landing position // Realistic impact animation sequence swingingBlock.tint = 0xFFFFFF; // Reset tint first // Impact squash effect - compress on landing tween(swingingBlock, { scaleX: 1.3, scaleY: 0.7 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { // Stretch back with overshoot tween(swingingBlock, { scaleX: 0.9, scaleY: 1.1 }, { duration: 150, easing: tween.easeInOut, onFinish: function onFinish() { // Settle to normal size tween(swingingBlock, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200, easing: tween.elasticOut }); } }); } }); // Impact flash with orange-red color for realism tween(swingingBlock, { tint: 0xFF8C42 }, { duration: 80, easing: tween.easeOut, onFinish: function onFinish() { // Quick flash to bright then fade to normal tween(swingingBlock, { tint: 0xFFFFCC }, { duration: 60, easing: tween.easeOut, onFinish: function onFinish() { tween(swingingBlock, { tint: 0xFFFFFF }, { duration: 200, easing: tween.easeOut }); } }); } }); // Realistic landing with multiple bounce phases tween(swingingBlock, { y: targetLandingY }, { duration: 400, easing: tween.elasticOut }); stackedBlocks.push(swingingBlock); // Update stack height to the new top stackHeight = swingingBlock.y; // After 5 blocks are placed, move all blocks down with realistic weight physics if (LK.getScore() > 5) { // Cascade movement - heavier blocks at bottom move first for (var m = 0; m < stackedBlocks.length; m++) { var targetY = stackedBlocks[m].y + 240; var delay = (stackedBlocks.length - m - 1) * 50; // Bottom blocks move first // Add slight compression before movement tween(stackedBlocks[m], { scaleY: 0.95 }, { duration: 100, easing: tween.easeOut, onFinish: function (blockIndex) { return function () { // Main movement with weight-based easing tween(stackedBlocks[blockIndex], { y: targetY, scaleY: 1.0 }, { duration: 600 + delay, easing: tween.easeInOut }); }; }(m) }); } } // Create new swinging block swingingBlock = LK.getAsset('swingingBlock', { anchorX: 0.5, anchorY: 0.5 }); swingingBlock.x = 0; swingingBlock.y = rope.height + 100; // Reset animation properties swingingBlock.rotation = 0; swingingBlock.scaleX = 1.0; swingingBlock.scaleY = 1.0; swingingBlock.tint = 0xFFFFFF; swingingBlock.fallingAnimationStarted = false; rope.addChild(swingingBlock); } else { // Not close enough to land - 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
@@ -83,44 +83,60 @@
swingingBlock.falling = true;
};
// Update function for falling blocks
game.update = function () {
- // Update rope swing with natural pendulum motion
+ // Update rope swing with realistic pendulum physics
if (rope && !swingingBlock.falling) {
swingTime += swingSpeed;
- rope.rotation = Math.sin(swingTime) * swingAmplitude;
- // Add vertical swinging motion to the swinging block
- var verticalOffset = Math.cos(swingTime * 2) * 30; // Vertical swing with smaller amplitude
+ // Natural pendulum motion with slight dampening
+ var pendulumMotion = Math.sin(swingTime) * swingAmplitude;
+ rope.rotation = pendulumMotion;
+ // Realistic vertical motion based on pendulum physics
+ var verticalOffset = Math.abs(Math.cos(swingTime)) * 25; // Natural arc motion
swingingBlock.y = rope.height + 100 + verticalOffset;
+ // Add subtle rope flex effect
+ rope.scaleX = 1.0 + Math.abs(pendulumMotion) * 0.1;
+ // Block tilts naturally with momentum
+ swingingBlock.rotation = pendulumMotion * 0.3;
}
if (swingingBlock.falling) {
// Use constant falling speed instead of accelerating gravity
swingingBlock.velocityY = 25; // Fixed falling speed
swingingBlock.y += swingingBlock.velocityY;
- // Add falling animation effects
+ // Add realistic falling animation effects
if (!swingingBlock.fallingAnimationStarted) {
swingingBlock.fallingAnimationStarted = true;
- // Add rotation while falling
+ // Realistic tumbling rotation - slower and more natural
tween(swingingBlock, {
- rotation: Math.PI * 2
+ rotation: Math.PI * 0.8 + (Math.random() - 0.5) * 0.4
}, {
- duration: 1500,
- easing: tween.linear
+ duration: 800,
+ easing: tween.easeOut
});
- // Add slight scaling effect
+ // Air resistance effect - slight compression
tween(swingingBlock, {
- scaleX: 1.1,
- scaleY: 1.1
+ scaleX: 0.95,
+ scaleY: 1.05
}, {
- duration: 200,
- easing: tween.easeOut,
+ duration: 300,
+ easing: tween.easeInOut,
onFinish: function onFinish() {
+ // Return to normal with slight overshoot
tween(swingingBlock, {
- scaleX: 1.0,
- scaleY: 1.0
+ scaleX: 1.02,
+ scaleY: 0.98
}, {
duration: 200,
- easing: tween.easeOut
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(swingingBlock, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 150,
+ easing: tween.easeOut
+ });
+ }
});
}
});
}
@@ -156,45 +172,96 @@
// Place block exactly on top of target block with smooth transition
swingingBlock.falling = false;
swingingBlock.velocityY = 0;
var targetLandingY = targetBlock.y - 240; // Calculate landing position
- // Add collision animation with flash effect
+ // Realistic impact animation sequence
swingingBlock.tint = 0xFFFFFF; // Reset tint first
+ // Impact squash effect - compress on landing
tween(swingingBlock, {
- tint: 0xFF6B6B
+ scaleX: 1.3,
+ scaleY: 0.7
}, {
- duration: 150,
+ duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
- // Flash back to normal color
+ // Stretch back with overshoot
tween(swingingBlock, {
- tint: 0xFFFFFF
+ scaleX: 0.9,
+ scaleY: 1.1
}, {
duration: 150,
- easing: tween.easeOut
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ // Settle to normal size
+ tween(swingingBlock, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 200,
+ easing: tween.elasticOut
+ });
+ }
});
}
});
- // Landing animation with bounce effect
+ // Impact flash with orange-red color for realism
tween(swingingBlock, {
+ tint: 0xFF8C42
+ }, {
+ duration: 80,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ // Quick flash to bright then fade to normal
+ tween(swingingBlock, {
+ tint: 0xFFFFCC
+ }, {
+ duration: 60,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(swingingBlock, {
+ tint: 0xFFFFFF
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ }
+ });
+ }
+ });
+ // Realistic landing with multiple bounce phases
+ tween(swingingBlock, {
y: targetLandingY
}, {
- duration: 300,
- easing: tween.bounceOut
+ duration: 400,
+ easing: tween.elasticOut
});
stackedBlocks.push(swingingBlock);
// Update stack height to the new top
stackHeight = swingingBlock.y;
- // After 5 blocks are placed, move all blocks down by one block height
+ // After 5 blocks are placed, move all blocks down with realistic weight physics
if (LK.getScore() > 5) {
- // Move all stacked blocks down smoothly by one block height (240 pixels)
+ // Cascade movement - heavier blocks at bottom move first
for (var m = 0; m < stackedBlocks.length; m++) {
var targetY = stackedBlocks[m].y + 240;
+ var delay = (stackedBlocks.length - m - 1) * 50; // Bottom blocks move first
+ // Add slight compression before movement
tween(stackedBlocks[m], {
- y: targetY
+ scaleY: 0.95
}, {
- duration: 800,
- easing: tween.easeOut
+ duration: 100,
+ easing: tween.easeOut,
+ onFinish: function (blockIndex) {
+ return function () {
+ // Main movement with weight-based easing
+ tween(stackedBlocks[blockIndex], {
+ y: targetY,
+ scaleY: 1.0
+ }, {
+ duration: 600 + delay,
+ easing: tween.easeInOut
+ });
+ };
+ }(m)
});
}
}
// Create new swinging block