User prompt
Çarpışma 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
Çarpışma animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Carpışma animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Blok düşerken havada dönme animasyonu ekle fakat çarpışma alanına düz iner ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Taş dönme animasyonu carpma alanınanyaklaştıgında düzelir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Çarpışma gerçekleştiginde dönme animasyonu durur ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Düşme sırasında blok dönme animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Sallanma animasyonu için rüzgar efecti ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Carpışma animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Sallanma yumuşak hareketlerle saglansın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyun görüntülerini bi tık küçült ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Sallantı Hızı her blokta degil 5 blokta bir hızlandır ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyıncu blok düşme süresi boyunca ekran dokunmayı iptal et
User prompt
Oyun nesneleri büyült ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Alt blok ve üst blok boyutunu büyülttügüm için çarpışma alanları bozuldu
User prompt
Keailme animasyonu yüzde 95 kadar parça kesiyorsa oyın biter ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İp saga sola daha fazla sallanabilir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Üst ip sallantısını giderek hızlandır ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Blok kayma animasyonunu yumuşat ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kesme animasyonu resim varlıgı ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Blok kesme animasyonunu kaldır yeni bir tane ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Blok kırpma animasyonunu degiştir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
6. Bloktan sonra alt blok kayma işlemini 3. Bloktan olarak degiştir
User prompt
Kırpma animasyon parçacık ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * 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 TrimParticle = Container.expand(function () { var self = Container.call(this); var particle = self.attachAsset('block', { anchorX: 0.5, anchorY: 0.5 }); self.launch = function (startX, startY, targetX, targetY) { self.x = startX; self.y = startY; particle.alpha = 1.0; particle.scaleX = 1.0; particle.scaleY = 1.0; particle.tint = 0xFFAAAA; // Light red tint for trimmed pieces // First phase: Quick scale down and rotate tween(particle, { scaleX: 0.6, scaleY: 0.6, rotation: Math.PI * 0.5 }, { duration: 200, easing: tween.easeOut }); // Second phase: Fly away with bouncy motion tween(self, { x: targetX, y: targetY }, { duration: 1200, easing: tween.bounceOut }); // Final fade and shrink LK.setTimeout(function () { tween(particle, { alpha: 0, scaleX: 0.1, scaleY: 0.1, rotation: Math.PI * 4, tint: 0xFF6666 }, { duration: 600, easing: tween.easeIn, onFinish: function onFinish() { self.destroy(); } }); }, 400); }; 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 natural pendulum motion 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 swingingBlock.y = rope.height + 100 + verticalOffset; } if (swingingBlock.falling) { // Use constant falling speed instead of accelerating gravity swingingBlock.velocityY = 25; // Fixed falling speed swingingBlock.y += swingingBlock.velocityY; // 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()); // Calculate collision overlap and trim the block var targetLeft = targetBlock.x - targetBlock.width / 2; var targetRight = targetBlock.x + targetBlock.width / 2; var swingingLeft = swingingBlock.x - swingingBlock.width / 2; var swingingRight = swingingBlock.x + swingingBlock.width / 2; // Find the overlapping area var overlapLeft = Math.max(targetLeft, swingingLeft); var overlapRight = Math.min(targetRight, swingingRight); var overlapWidth = overlapRight - overlapLeft; // Only proceed if there's actual overlap if (overlapWidth > 0) { // Place block exactly on top of target block swingingBlock.falling = false; swingingBlock.velocityY = 0; swingingBlock.y = targetBlock.y - 240; // Place exactly one block height above // Create particles for trimmed parts var leftTrimmed = swingingLeft < overlapLeft; var rightTrimmed = swingingRight > overlapRight; if (leftTrimmed) { // Create particle for left trimmed part var leftParticle = new TrimParticle(); game.addChild(leftParticle); var leftPartX = swingingLeft + (overlapLeft - swingingLeft) / 2; leftParticle.launch(leftPartX, swingingBlock.y, leftPartX - 300, swingingBlock.y + 200); } if (rightTrimmed) { // Create particle for right trimmed part var rightParticle = new TrimParticle(); game.addChild(rightParticle); var rightPartX = overlapRight + (swingingRight - overlapRight) / 2; rightParticle.launch(rightPartX, swingingBlock.y, rightPartX + 300, swingingBlock.y + 200); } // Trim the block to only show the overlapping area var newCenterX = overlapLeft + overlapWidth / 2; swingingBlock.x = newCenterX; swingingBlock.width = overlapWidth; stackedBlocks.push(swingingBlock); } else { // No overlap, block falls off swingingBlock.falling = true; } // Update stack height to the new top stackHeight = swingingBlock.y; // After 2 blocks are placed (3rd block landing), start sliding all blocks down if (LK.getScore() > 2) { // Animate all blocks sliding down by one block height (240px) for (var b = 0; b < stackedBlocks.length; b++) { var block = stackedBlocks[b]; tween(block, { y: block.y + 240 }, { duration: 500 }); } // Get the bottom block for destruction after animation var bottomBlock = stackedBlocks[0]; // Set a timeout to destroy the bottom block after animation completes LK.setTimeout(function () { bottomBlock.destroy(); stackedBlocks.splice(0, 1); }, 500); } // Create new swinging block swingingBlock = LK.getAsset('swingingBlock', { anchorX: 0.5, anchorY: 0.5 }); swingingBlock.x = 0; swingingBlock.y = rope.height + 100; 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
@@ -22,31 +22,45 @@
});
self.launch = function (startX, startY, targetX, targetY) {
self.x = startX;
self.y = startY;
- particle.alpha = 0.8;
- particle.scaleX = 0.3;
- particle.scaleY = 0.3;
- // Animate particle flying away and fading
+ particle.alpha = 1.0;
+ particle.scaleX = 1.0;
+ particle.scaleY = 1.0;
+ particle.tint = 0xFFAAAA; // Light red tint for trimmed pieces
+ // First phase: Quick scale down and rotate
+ tween(particle, {
+ scaleX: 0.6,
+ scaleY: 0.6,
+ rotation: Math.PI * 0.5
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ // Second phase: Fly away with bouncy motion
tween(self, {
x: targetX,
y: targetY
}, {
- duration: 800,
- easing: tween.easeOut
+ duration: 1200,
+ easing: tween.bounceOut
});
- tween(particle, {
- alpha: 0,
- scaleX: 0.1,
- scaleY: 0.1,
- rotation: Math.PI * 2
- }, {
- duration: 800,
- easing: tween.easeOut,
- onFinish: function onFinish() {
- self.destroy();
- }
- });
+ // Final fade and shrink
+ LK.setTimeout(function () {
+ tween(particle, {
+ alpha: 0,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ rotation: Math.PI * 4,
+ tint: 0xFF6666
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ }, 400);
};
return self;
});