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 CutPiece = Container.expand(function () {
var self = Container.call(this);
var piece = self.attachAsset('cutPiece', {
anchorX: 0.5,
anchorY: 0.5
});
self.animate = function (direction, blockWidth) {
// Set initial appearance
piece.alpha = 1;
piece.width = blockWidth;
// Animate piece falling and rotating
var fallDirection = direction === 'left' ? -1 : 1;
tween(self, {
x: self.x + fallDirection * 400,
y: self.y + 600,
rotation: fallDirection * Math.PI * 2
}, {
duration: 1200,
easing: tween.easeIn
});
tween(piece, {
alpha: 0
}, {
duration: 1200,
easing: tween.linear,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
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 = 1.2; // Controls swing range (max rotation) - increased for wider swing
// 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 || swingingBlock.falling) 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) {
// Gradually increase swing speed based on score - every 5 blocks
var currentSwingSpeed = swingSpeed + Math.floor(LK.getScore() / 5) * 0.005; // Increase speed by 0.005 every 5 blocks
swingTime += currentSwingSpeed;
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) {
// Add collision animation effects
// Screen shake effect
tween(game, {
x: 10
}, {
duration: 50,
easing: tween.linear
});
tween(game, {
x: -10
}, {
duration: 50,
easing: tween.linear,
onFinish: function onFinish() {
tween(game, {
x: 5
}, {
duration: 50,
easing: tween.linear
});
tween(game, {
x: -5
}, {
duration: 50,
easing: tween.linear,
onFinish: function onFinish() {
tween(game, {
x: 0
}, {
duration: 50,
easing: tween.linear
});
}
});
}
});
// Flash both blocks white for collision effect
var originalSwingingTint = swingingBlock.tint || 0xFFFFFF;
var originalTargetTint = targetBlock.tint || 0xFFFFFF;
swingingBlock.tint = 0xFFFFFF;
targetBlock.tint = 0xFFFFFF;
tween(swingingBlock, {
tint: originalSwingingTint
}, {
duration: 200,
easing: tween.linear
});
tween(targetBlock, {
tint: originalTargetTint
}, {
duration: 200,
easing: tween.linear
});
// 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 - 256; // Place exactly one block height above
// Create cut pieces for trimmed parts
var leftTrimmed = swingingLeft < overlapLeft;
var rightTrimmed = swingingRight > overlapRight;
if (leftTrimmed) {
// Create cut piece for left trimmed part
var leftCutPiece = new CutPiece();
game.addChild(leftCutPiece);
var leftTrimWidth = overlapLeft - swingingLeft;
leftCutPiece.x = swingingLeft + leftTrimWidth / 2;
leftCutPiece.y = swingingBlock.y;
leftCutPiece.animate('left', leftTrimWidth);
}
if (rightTrimmed) {
// Create cut piece for right trimmed part
var rightCutPiece = new CutPiece();
game.addChild(rightCutPiece);
var rightTrimWidth = swingingRight - overlapRight;
rightCutPiece.x = overlapRight + rightTrimWidth / 2;
rightCutPiece.y = swingingBlock.y;
rightCutPiece.animate('right', rightTrimWidth);
}
// Calculate how much of the original block remains
var originalWidth = 280; // Original block width
var remainingPercentage = overlapWidth / originalWidth * 100;
// Check if 95% or more was trimmed (only 5% or less remains)
if (remainingPercentage <= 5) {
// Game over - too much of the block was cut off
gameActive = false;
LK.showGameOver();
return;
}
// 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 (256px)
for (var b = 0; b < stackedBlocks.length; b++) {
var block = stackedBlocks[b];
tween(block, {
y: block.y + 256
}, {
duration: 800,
easing: tween.easeInOut
});
}
// 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);
}, 800);
}
// 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
@@ -115,49 +115,17 @@
swingingBlock.falling = true;
};
// Update function for falling blocks
game.update = function () {
- // Update rope swing with smooth tween-based pendulum motion
+ // Update rope swing with natural pendulum motion
if (rope && !swingingBlock.falling) {
- // Check if we need to start a new swing cycle
- if (!rope.swingDirection) {
- rope.swingDirection = 1; // 1 for right, -1 for left
- rope.isSwinging = false;
- }
- // Start new swing tween if not currently swinging
- if (!rope.isSwinging) {
- rope.isSwinging = true;
- var targetRotation = rope.swingDirection * swingAmplitude;
- // Calculate swing duration based on score - every 5 blocks
- var speedMultiplier = 1 + Math.floor(LK.getScore() / 5) * 0.3; // Increase speed by 30% every 5 blocks
- var swingDuration = 1200 / speedMultiplier; // Base duration of 1200ms
- // Smooth swing to target position
- tween(rope, {
- rotation: targetRotation
- }, {
- duration: swingDuration,
- easing: tween.easeInOut,
- onFinish: function onFinish() {
- rope.swingDirection *= -1; // Reverse direction
- rope.isSwinging = false; // Allow next swing
- }
- });
- // Add subtle vertical bobbing motion to swinging block
- tween(swingingBlock, {
- y: rope.height + 120
- }, {
- duration: swingDuration / 2,
- easing: tween.easeInOut,
- onFinish: function onFinish() {
- tween(swingingBlock, {
- y: rope.height + 100
- }, {
- duration: swingDuration / 2,
- easing: tween.easeInOut
- });
- }
- });
- }
+ // Gradually increase swing speed based on score - every 5 blocks
+ var currentSwingSpeed = swingSpeed + Math.floor(LK.getScore() / 5) * 0.005; // Increase speed by 0.005 every 5 blocks
+ swingTime += currentSwingSpeed;
+ 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
@@ -181,8 +149,61 @@
highestY = stackedBlocks[k].y;
}
}
if (targetBlock) {
+ // Add collision animation effects
+ // Screen shake effect
+ tween(game, {
+ x: 10
+ }, {
+ duration: 50,
+ easing: tween.linear
+ });
+ tween(game, {
+ x: -10
+ }, {
+ duration: 50,
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ tween(game, {
+ x: 5
+ }, {
+ duration: 50,
+ easing: tween.linear
+ });
+ tween(game, {
+ x: -5
+ }, {
+ duration: 50,
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ tween(game, {
+ x: 0
+ }, {
+ duration: 50,
+ easing: tween.linear
+ });
+ }
+ });
+ }
+ });
+ // Flash both blocks white for collision effect
+ var originalSwingingTint = swingingBlock.tint || 0xFFFFFF;
+ var originalTargetTint = targetBlock.tint || 0xFFFFFF;
+ swingingBlock.tint = 0xFFFFFF;
+ targetBlock.tint = 0xFFFFFF;
+ tween(swingingBlock, {
+ tint: originalSwingingTint
+ }, {
+ duration: 200,
+ easing: tween.linear
+ });
+ tween(targetBlock, {
+ tint: originalTargetTint
+ }, {
+ duration: 200,
+ easing: tween.linear
+ });
// 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);