User prompt
Ekranı aşağıya doğru indirelim ve büyütelim
User prompt
Daha fazla belirginleşir daha fazla görünsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyuna bir gem daha ekleyelim bomba görüntüsü oluşsun ve bu bomba görüntüsü ancak 5 gem birleştiği zaman çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Gemlerin renk tonunu açık yap ve matlaştır ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Timeout.tick error: bounceGem is not a function' in or related to this line: 'bounceGem(bounceGem);' Line Number: 413 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Daha fazla efetk olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Gemlerin renklerini hafif solgun yap ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Genler yok olduklarında bir patlama efekti ekle partikül olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Eğer eşleştirme olduysa kaybolan gemleri yukarindan aşağıya düşür ve yenilerini getir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Daha büyük hale getir
User prompt
Oyun alanını ve icersindeki gemleri ekrana tamamen doldur
User prompt
Yer değiştirmeyi birer kare olarak yap eğer birbirinle eşleşmiyorsa geri dönsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yer değiştirmesini kaydırma yap ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Gem Swap Adventure
Initial prompt
Candy crush ve jewel ancient benzeri
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Gem = Container.expand(function (gemType, gridX, gridY) { var self = Container.call(this); self.gemType = gemType; self.gridX = gridX; self.gridY = gridY; self.isAnimating = false; var gemAssets = ['gemRed', 'gemBlue', 'gemGreen', 'gemYellow', 'gemPurple', 'gemOrange']; var gemGraphics = self.attachAsset(gemAssets[gemType], { anchorX: 0.5, anchorY: 0.5 }); self.setGridPosition = function (x, y) { self.gridX = x; self.gridY = y; }; self.animateToPosition = function (targetX, targetY, duration, onComplete) { if (!duration) duration = 200; self.isAnimating = true; tween(self, { x: targetX, y: targetY }, { duration: duration, easing: tween.easeOut, onFinish: function onFinish() { self.isAnimating = false; if (onComplete) onComplete(); } }); }; self.destroy = function () { if (self.parent) { self.parent.removeChild(self); } }; return self; }); var Particle = Container.expand(function (x, y, color) { var self = Container.call(this); var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); // Set particle color particleGraphics.tint = color; // Set initial position self.x = x; self.y = y; // Random velocity self.velocityX = (Math.random() - 0.5) * 300; self.velocityY = (Math.random() - 0.5) * 300; self.gravity = 500; self.life = 1.0; self.fadeSpeed = 2.0; self.update = function () { // Update position based on velocity self.x += self.velocityX * (1 / 60); self.y += self.velocityY * (1 / 60); // Apply gravity self.velocityY += self.gravity * (1 / 60); // Fade out over time self.life -= self.fadeSpeed * (1 / 60); self.alpha = Math.max(0, self.life); // Remove when fully faded if (self.life <= 0) { self.destroy(); } }; self.destroy = function () { if (self.parent) { self.parent.removeChild(self); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2C1810 }); /**** * Game Code ****/ var GRID_SIZE = 8; var CELL_SIZE = 200; var BOARD_OFFSET_X = (2048 - GRID_SIZE * CELL_SIZE) / 2; var BOARD_OFFSET_Y = 200; var gameBoard = []; var selectedGem = null; var draggedGem = null; var dragStartPos = null; var isDragging = false; var isSwapping = false; var score = 0; var comboMultiplier = 1; // Create explosion effect at gem position function createExplosion(x, y, gemColor) { var particleCount = 12; var gemColors = [0xff4444, 0x4444ff, 0x44ff44, 0xffff44, 0xff44ff, 0xff8844]; var color = gemColors[gemColor] || 0xffffff; for (var i = 0; i < particleCount; i++) { var particle = new Particle(x, y, color); game.addChild(particle); } } // Add screen shake effect function shakeScreen(intensity, duration) { var originalX = game.x; var originalY = game.y; var shakeTimer = 0; var shakeInterval = LK.setInterval(function () { shakeTimer += 16; var shakeX = (Math.random() - 0.5) * intensity; var shakeY = (Math.random() - 0.5) * intensity; game.x = originalX + shakeX; game.y = originalY + shakeY; if (shakeTimer >= duration) { LK.clearInterval(shakeInterval); game.x = originalX; game.y = originalY; } }, 16); } // Add screen flash effect with color tinting function flashScreenColor(color, duration) { LK.effects.flashScreen(color, duration); } // Add gem scaling bounce effect function bounceGem(gem) { tween(gem, { scaleX: 1.3, scaleY: 1.3 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(gem, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100, easing: tween.bounceOut }); } }); } // Create board background var boardBg = game.attachAsset('boardBg', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: BOARD_OFFSET_Y + GRID_SIZE * CELL_SIZE / 2 }); // Create score display var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 100; // Initialize empty board function initializeBoard() { gameBoard = []; for (var x = 0; x < GRID_SIZE; x++) { gameBoard[x] = []; for (var y = 0; y < GRID_SIZE; y++) { gameBoard[x][y] = null; } } } // Fill board with random gems function fillBoard() { for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { if (!gameBoard[x][y]) { var gemType = Math.floor(Math.random() * 6); var gem = new Gem(gemType, x, y); var worldPos = gridToWorld(x, y); gem.x = worldPos.x; gem.y = worldPos.y; gameBoard[x][y] = gem; game.addChild(gem); } } } } // Convert grid coordinates to world coordinates function gridToWorld(gridX, gridY) { return { x: BOARD_OFFSET_X + gridX * CELL_SIZE + CELL_SIZE / 2, y: BOARD_OFFSET_Y + gridY * CELL_SIZE + CELL_SIZE / 2 }; } // Convert world coordinates to grid coordinates function worldToGrid(worldX, worldY) { var gridX = Math.floor((worldX - BOARD_OFFSET_X) / CELL_SIZE); var gridY = Math.floor((worldY - BOARD_OFFSET_Y) / CELL_SIZE); if (gridX < 0 || gridX >= GRID_SIZE || gridY < 0 || gridY >= GRID_SIZE) { return null; } return { x: gridX, y: gridY }; } // Check if two grid positions are adjacent function areAdjacent(pos1, pos2) { var dx = Math.abs(pos1.x - pos2.x); var dy = Math.abs(pos1.y - pos2.y); return dx === 1 && dy === 0 || dx === 0 && dy === 1; } // Check for matches starting at position function checkMatches(startX, startY) { var gem = gameBoard[startX][startY]; if (!gem) return []; var matches = []; var gemType = gem.gemType; // Check horizontal matches var horizontalMatches = [gem]; // Check left for (var x = startX - 1; x >= 0; x--) { if (gameBoard[x][startY] && gameBoard[x][startY].gemType === gemType) { horizontalMatches.unshift(gameBoard[x][startY]); } else { break; } } // Check right for (var x = startX + 1; x < GRID_SIZE; x++) { if (gameBoard[x][startY] && gameBoard[x][startY].gemType === gemType) { horizontalMatches.push(gameBoard[x][startY]); } else { break; } } if (horizontalMatches.length >= 3) { matches = matches.concat(horizontalMatches); } // Check vertical matches var verticalMatches = [gem]; // Check up for (var y = startY - 1; y >= 0; y--) { if (gameBoard[startX][y] && gameBoard[startX][y].gemType === gemType) { verticalMatches.unshift(gameBoard[startX][y]); } else { break; } } // Check down for (var y = startY + 1; y < GRID_SIZE; y++) { if (gameBoard[startX][y] && gameBoard[startX][y].gemType === gemType) { verticalMatches.push(gameBoard[startX][y]); } else { break; } } if (verticalMatches.length >= 3) { matches = matches.concat(verticalMatches); } // Remove duplicates var uniqueMatches = []; for (var i = 0; i < matches.length; i++) { var found = false; for (var j = 0; j < uniqueMatches.length; j++) { if (matches[i] === uniqueMatches[j]) { found = true; break; } } if (!found) { uniqueMatches.push(matches[i]); } } return uniqueMatches; } // Find all matches on the board function findAllMatches() { var allMatches = []; var processedGems = []; for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { if (gameBoard[x][y]) { var matches = checkMatches(x, y); for (var i = 0; i < matches.length; i++) { var gem = matches[i]; var found = false; for (var j = 0; j < processedGems.length; j++) { if (processedGems[j] === gem) { found = true; break; } } if (!found) { allMatches.push(gem); processedGems.push(gem); } } } } } return allMatches; } // Clear matched gems function clearMatches(matches) { if (matches.length === 0) return; LK.getSound('match').play(); var points = matches.length * 10 * comboMultiplier; score += points; scoreTxt.setText('Score: ' + score); // Enhanced effects based on match size if (matches.length >= 5) { // Large match - intense effects shakeScreen(20, 300); flashScreenColor(0xffffff, 400); } else if (matches.length >= 4) { // Medium match - moderate effects shakeScreen(12, 200); flashScreenColor(0xffff00, 300); } else { // Small match - subtle effects shakeScreen(6, 150); } for (var i = 0; i < matches.length; i++) { var gem = matches[i]; // Add scaling effect before destruction tween(gem, { scaleX: 1.5, scaleY: 1.5, alpha: 0.3 }, { duration: 150, easing: tween.easeIn }); // Create explosion effect at gem position createExplosion(gem.x, gem.y, gem.gemType); gameBoard[gem.gridX][gem.gridY] = null; // Delay gem destruction to allow scaling animation LK.setTimeout(function (destroyGem) { return function () { destroyGem.destroy(); }; }(gem), 150); } // After clearing gems, apply gravity and fill empty spaces LK.setTimeout(function () { var moved = applyGravity(); fillEmptySpaces(); // Check for new matches after falling gems settle LK.setTimeout(function () { var newMatches = findAllMatches(); if (newMatches.length > 0) { comboMultiplier++; clearMatches(newMatches); } else { comboMultiplier = 1; isSwapping = false; } }, 500); }, 200); } // Apply gravity to make gems fall function applyGravity() { var moved = false; for (var x = 0; x < GRID_SIZE; x++) { for (var y = GRID_SIZE - 1; y >= 0; y--) { if (!gameBoard[x][y]) { // Find gem above to fall down for (var searchY = y - 1; searchY >= 0; searchY--) { if (gameBoard[x][searchY]) { var gem = gameBoard[x][searchY]; gameBoard[x][y] = gem; gameBoard[x][searchY] = null; gem.setGridPosition(x, y); var worldPos = gridToWorld(x, y); gem.animateToPosition(worldPos.x, worldPos.y, 300); // Add bounce effect when gem lands LK.setTimeout(function (bounceGem) { return function () { bounceGem(bounceGem); }; }(gem), 300); moved = true; break; } } } } } return moved; } // Fill empty spaces with new gems function fillEmptySpaces() { for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { if (!gameBoard[x][y]) { var gemType = Math.floor(Math.random() * 6); var gem = new Gem(gemType, x, y); var worldPos = gridToWorld(x, y); gem.x = worldPos.x; gem.y = worldPos.y - GRID_SIZE * CELL_SIZE; gameBoard[x][y] = gem; game.addChild(gem); gem.animateToPosition(worldPos.x, worldPos.y, 400); // Add bounce effect when new gem lands LK.setTimeout(function (bounceGem) { return function () { bounceGem(bounceGem); }; }(gem), 400); } } } } // Swap two gems function swapGems(gem1, gem2) { if (isSwapping) return; isSwapping = true; // Store original positions var originalGem1X = gem1.gridX; var originalGem1Y = gem1.gridY; var originalGem2X = gem2.gridX; var originalGem2Y = gem2.gridY; // Update grid positions gem1.setGridPosition(gem2.gridX, gem2.gridY); gem2.setGridPosition(originalGem1X, originalGem1Y); gameBoard[gem1.gridX][gem1.gridY] = gem1; gameBoard[gem2.gridX][gem2.gridY] = gem2; var pos1 = gridToWorld(gem1.gridX, gem1.gridY); var pos2 = gridToWorld(gem2.gridX, gem2.gridY); // Animate the swap gem1.animateToPosition(pos1.x, pos1.y, 200); gem2.animateToPosition(pos2.x, pos2.y, 200); LK.setTimeout(function () { var matches = findAllMatches(); if (matches.length > 0) { // Valid swap - play sound and process matches LK.getSound('swap').play(); clearMatches(matches); } else { // Invalid move - animate back to original positions gem1.setGridPosition(originalGem1X, originalGem1Y); gem2.setGridPosition(originalGem2X, originalGem2Y); gameBoard[gem1.gridX][gem1.gridY] = gem1; gameBoard[gem2.gridX][gem2.gridY] = gem2; var pos1 = gridToWorld(gem1.gridX, gem1.gridY); var pos2 = gridToWorld(gem2.gridX, gem2.gridY); gem1.animateToPosition(pos1.x, pos1.y, 200); gem2.animateToPosition(pos2.x, pos2.y, 200); LK.setTimeout(function () { isSwapping = false; }, 200); } }, 200); } // Game input handling game.down = function (x, y, obj) { if (isSwapping) return; var gridPos = worldToGrid(x, y); if (!gridPos) return; var clickedGem = gameBoard[gridPos.x][gridPos.y]; if (!clickedGem) return; draggedGem = clickedGem; dragStartPos = { x: x, y: y }; isDragging = true; draggedGem.alpha = 0.7; // Add glowing effect to selected gem tween(draggedGem, { tint: 0xffffff }, { duration: 200, easing: tween.easeInOut }); bounceGem(draggedGem); }; game.move = function (x, y, obj) { if (!isDragging || !draggedGem || isSwapping) return; // Calculate drag distance var dragDeltaX = x - dragStartPos.x; var dragDeltaY = y - dragStartPos.y; var dragDistance = Math.sqrt(dragDeltaX * dragDeltaX + dragDeltaY * dragDeltaY); // Only process if drag distance is significant enough if (dragDistance > CELL_SIZE * 0.3) { // Determine drag direction var targetGridX = draggedGem.gridX; var targetGridY = draggedGem.gridY; if (Math.abs(dragDeltaX) > Math.abs(dragDeltaY)) { // Horizontal drag if (dragDeltaX > 0) { targetGridX = Math.min(GRID_SIZE - 1, draggedGem.gridX + 1); } else { targetGridX = Math.max(0, draggedGem.gridX - 1); } } else { // Vertical drag if (dragDeltaY > 0) { targetGridY = Math.min(GRID_SIZE - 1, draggedGem.gridY + 1); } else { targetGridY = Math.max(0, draggedGem.gridY - 1); } } // Update visual position to show intended swap var targetWorldPos = gridToWorld(targetGridX, targetGridY); draggedGem.x = targetWorldPos.x; draggedGem.y = targetWorldPos.y; // Store target position for later use draggedGem.targetGridX = targetGridX; draggedGem.targetGridY = targetGridY; } }; game.up = function (x, y, obj) { if (!isDragging || !draggedGem || isSwapping) return; var startGridPos = { x: draggedGem.gridX, y: draggedGem.gridY }; // Check if we have a target position from dragging if (draggedGem.targetGridX !== undefined && draggedGem.targetGridY !== undefined) { var targetGridPos = { x: draggedGem.targetGridX, y: draggedGem.targetGridY }; // Check if target position is valid and adjacent if (areAdjacent(startGridPos, targetGridPos) && gameBoard[targetGridPos.x][targetGridPos.y]) { var targetGem = gameBoard[targetGridPos.x][targetGridPos.y]; // Attempt swap swapGems(draggedGem, targetGem); } else { // Invalid swap - animate back to original position var worldPos = gridToWorld(draggedGem.gridX, draggedGem.gridY); draggedGem.animateToPosition(worldPos.x, worldPos.y, 200); } // Clean up target position draggedGem.targetGridX = undefined; draggedGem.targetGridY = undefined; } else { // No significant drag - just return to original position var worldPos = gridToWorld(draggedGem.gridX, draggedGem.gridY); draggedGem.animateToPosition(worldPos.x, worldPos.y, 200); } draggedGem.alpha = 1.0; // Reset tint to original color tween.stop(draggedGem, { tint: true }); draggedGem.tint = 0xffffff; draggedGem = null; dragStartPos = null; isDragging = false; }; // Initialize the game initializeBoard(); fillBoard(); // Initial match clearing LK.setTimeout(function () { var matches = findAllMatches(); if (matches.length > 0) { clearMatches(matches); } }, 100); ;
===================================================================
--- original.js
+++ change.js
@@ -105,16 +105,57 @@
var score = 0;
var comboMultiplier = 1;
// Create explosion effect at gem position
function createExplosion(x, y, gemColor) {
- var particleCount = 8;
- var gemColors = [0xaa6666, 0x6666aa, 0x66aa66, 0xaaaa66, 0xaa66aa, 0xaa7755];
+ var particleCount = 12;
+ var gemColors = [0xff4444, 0x4444ff, 0x44ff44, 0xffff44, 0xff44ff, 0xff8844];
var color = gemColors[gemColor] || 0xffffff;
for (var i = 0; i < particleCount; i++) {
var particle = new Particle(x, y, color);
game.addChild(particle);
}
}
+// Add screen shake effect
+function shakeScreen(intensity, duration) {
+ var originalX = game.x;
+ var originalY = game.y;
+ var shakeTimer = 0;
+ var shakeInterval = LK.setInterval(function () {
+ shakeTimer += 16;
+ var shakeX = (Math.random() - 0.5) * intensity;
+ var shakeY = (Math.random() - 0.5) * intensity;
+ game.x = originalX + shakeX;
+ game.y = originalY + shakeY;
+ if (shakeTimer >= duration) {
+ LK.clearInterval(shakeInterval);
+ game.x = originalX;
+ game.y = originalY;
+ }
+ }, 16);
+}
+// Add screen flash effect with color tinting
+function flashScreenColor(color, duration) {
+ LK.effects.flashScreen(color, duration);
+}
+// Add gem scaling bounce effect
+function bounceGem(gem) {
+ tween(gem, {
+ scaleX: 1.3,
+ scaleY: 1.3
+ }, {
+ duration: 100,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(gem, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 100,
+ easing: tween.bounceOut
+ });
+ }
+ });
+}
// Create board background
var boardBg = game.attachAsset('boardBg', {
anchorX: 0.5,
anchorY: 0.5,
@@ -277,14 +318,41 @@
LK.getSound('match').play();
var points = matches.length * 10 * comboMultiplier;
score += points;
scoreTxt.setText('Score: ' + score);
+ // Enhanced effects based on match size
+ if (matches.length >= 5) {
+ // Large match - intense effects
+ shakeScreen(20, 300);
+ flashScreenColor(0xffffff, 400);
+ } else if (matches.length >= 4) {
+ // Medium match - moderate effects
+ shakeScreen(12, 200);
+ flashScreenColor(0xffff00, 300);
+ } else {
+ // Small match - subtle effects
+ shakeScreen(6, 150);
+ }
for (var i = 0; i < matches.length; i++) {
var gem = matches[i];
+ // Add scaling effect before destruction
+ tween(gem, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0.3
+ }, {
+ duration: 150,
+ easing: tween.easeIn
+ });
// Create explosion effect at gem position
createExplosion(gem.x, gem.y, gem.gemType);
gameBoard[gem.gridX][gem.gridY] = null;
- gem.destroy();
+ // Delay gem destruction to allow scaling animation
+ LK.setTimeout(function (destroyGem) {
+ return function () {
+ destroyGem.destroy();
+ };
+ }(gem), 150);
}
// After clearing gems, apply gravity and fill empty spaces
LK.setTimeout(function () {
var moved = applyGravity();
@@ -316,8 +384,14 @@
gameBoard[x][searchY] = null;
gem.setGridPosition(x, y);
var worldPos = gridToWorld(x, y);
gem.animateToPosition(worldPos.x, worldPos.y, 300);
+ // Add bounce effect when gem lands
+ LK.setTimeout(function (bounceGem) {
+ return function () {
+ bounceGem(bounceGem);
+ };
+ }(gem), 300);
moved = true;
break;
}
}
@@ -338,8 +412,14 @@
gem.y = worldPos.y - GRID_SIZE * CELL_SIZE;
gameBoard[x][y] = gem;
game.addChild(gem);
gem.animateToPosition(worldPos.x, worldPos.y, 400);
+ // Add bounce effect when new gem lands
+ LK.setTimeout(function (bounceGem) {
+ return function () {
+ bounceGem(bounceGem);
+ };
+ }(gem), 400);
}
}
}
}
@@ -397,8 +477,16 @@
y: y
};
isDragging = true;
draggedGem.alpha = 0.7;
+ // Add glowing effect to selected gem
+ tween(draggedGem, {
+ tint: 0xffffff
+ }, {
+ duration: 200,
+ easing: tween.easeInOut
+ });
+ bounceGem(draggedGem);
};
game.move = function (x, y, obj) {
if (!isDragging || !draggedGem || isSwapping) return;
// Calculate drag distance
@@ -464,8 +552,13 @@
var worldPos = gridToWorld(draggedGem.gridX, draggedGem.gridY);
draggedGem.animateToPosition(worldPos.x, worldPos.y, 200);
}
draggedGem.alpha = 1.0;
+ // Reset tint to original color
+ tween.stop(draggedGem, {
+ tint: true
+ });
+ draggedGem.tint = 0xffffff;
draggedGem = null;
dragStartPos = null;
isDragging = false;
};
Alev spiral parçacık. In-Game asset. 2d. High contrast. No shadows
Su damlası patlama parçacık. In-Game asset. 2d. High contrast. No shadows
Karadelik vortex parçacık spiral. In-Game asset. 2d. High contrast. No shadows
Yeşil yaprak süzülen. In-Game asset. 2d. High contrast. No shadows
Yıldız patlama parlak. In-Game asset. 2d. High contrast. No shadows
Lav topu erimiş. In-Game asset. 2d. High contrast. No shadows
Health bar, grandyan, green,. In-Game asset. 2d. High contrast. No shadows
Hiç birşeye dokunma sadece yeşil olan kısımları kırmızı ile yer değiştir
Bomba şeklinide grandyan ama çizgili rengarenk olsun