User prompt
Eğer oyuncu 5 adet gem patlatırsa bir havai fişek varlığı oluştur asseti olsun ve sesi olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyundaki hataları düzeltin
User prompt
Yavaşca kendi etrafında dönebilsin nabizi değiştir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Titreme animasyonunu nabız atışı olarak değiştir hafif olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Daha az agresif olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Animasyonu titreme olarak değiştir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bütün gemleri hafif çalkalanıyor şekilde animasyon ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Aynı zamanda 3 lü sıralı eşlemede olsun
User prompt
Gemlerin patlamasını 2x2 olduğu zamanda patlasın
User prompt
Gemler 4x4 olduğu zaman da patlayabilir yap
User prompt
Gemleri 4x4 oluncada patlayabilir sin
User prompt
M1 ve m11 olan bütün assetleri oyundan sil varlıklarınıda sil ve yaptığım skor değişikliklerini geri al
User prompt
Ey UPit, skor kaçsa onu rakamlara böl, her rakamı uygun resimle değiştir.
User prompt
skor kaçsa onu rakamlara böl, her rakamı uygun resimle değiştir.
User prompt
Bunları hepsini 4 cu katmana taşı ve sağ alt kısma dikey olarak sırala
User prompt
Ey UPit, skor kaçsa onu rakamlara böl, her rakamı uygun resimle değiştir. Bu uygun resimler sırayla 1=1M,2=2M,3=3M,4=4M,5=5M,6=6M,7=7M,8=8M,9=9M=0=10M
User prompt
Oyuna ekleme
User prompt
Bana 10 adet M2 varlığı gibi asset oluştur ve onları M2 varlığındaki görsel gibi yap ama sırayla olsun 2,3,4 gibi
User prompt
Hayır geri al
User prompt
Bu M1 varlığına rakam olarak bakalım
User prompt
Bana iki adet yeni asset oluştur ve isimleri M1 M2 olsun
User prompt
Arkaplan döngüsünü sıfırla ve hataları duzelt ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Birbirlerinin içinden geçmesini engelle
User prompt
İki arkaplanı üst üste birleştir
User prompt
İkinci kahverengi arkaplanın assetini ekle
/****
* 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 () {
// Special animation for red gems (gemType 0)
if (self.gemType === 0) {
self.createFlameExplosion();
}
// Special animation for blue gems (gemType 1)
if (self.gemType === 1) {
self.createWaterExplosion();
}
// Special animation for green gems (gemType 2)
if (self.gemType === 2) {
self.createLeafSpiral();
}
// Special animation for yellow gems (gemType 3)
if (self.gemType === 3) {
self.createStarExplosion();
}
// Special animation for purple gems (gemType 4)
if (self.gemType === 4) {
self.createPurpleImplosion();
}
// Special animation for orange gems (gemType 5)
if (self.gemType === 5) {
self.createLavaMelting();
}
// Create tween effect before actually destroying
tween(self, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.parent) {
self.parent.removeChild(self);
}
}
});
};
self.createFlameExplosion = function () {
var flameCount = 8;
var radius = 100;
for (var i = 0; i < flameCount; i++) {
var angle = i / flameCount * Math.PI * 2;
var flameParticle = LK.getAsset('flameParticle', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial position at gem center
flameParticle.x = self.x;
flameParticle.y = self.y;
flameParticle.zIndex = 5;
// Add to game
if (self.parent) {
self.parent.addChild(flameParticle);
}
// Calculate spiral target position
var targetX = self.x + Math.cos(angle) * radius;
var targetY = self.y + Math.sin(angle) * radius;
// Create spiral rotation and movement animation
tween(flameParticle, {
x: targetX,
y: targetY,
rotation: Math.PI * 4,
// 2 full rotations
scaleX: 3.0,
scaleY: 3.0
}, {
duration: 400,
easing: tween.easeOut
});
// Fade out and disappear
tween(flameParticle, {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (flameParticle.parent) {
flameParticle.parent.removeChild(flameParticle);
}
}
});
// Add flame color transition from orange to red
tween(flameParticle, {
tint: 0xff0000
}, {
duration: 300,
easing: tween.easeInOut
});
}
};
self.createWaterExplosion = function () {
var dropletCount = 12;
var maxRadius = 120;
for (var i = 0; i < dropletCount; i++) {
var angle = i / dropletCount * Math.PI * 2;
var waterDroplet = LK.getAsset('waterDroplet', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial position at gem center
waterDroplet.x = self.x;
waterDroplet.y = self.y;
waterDroplet.zIndex = 5;
// Random radius for scattered effect
var radius = 60 + Math.random() * 60;
// Add to game
if (self.parent) {
self.parent.addChild(waterDroplet);
}
// Calculate target position for water droplet
var targetX = self.x + Math.cos(angle) * radius;
var targetY = self.y + Math.sin(angle) * radius;
// Create bouncing water droplet movement
tween(waterDroplet, {
x: targetX,
y: targetY,
scaleX: 2.5,
scaleY: 2.5
}, {
duration: 350,
easing: tween.bounceOut
});
// Create ripple effect with scaling
tween(waterDroplet, {
scaleX: 0.8,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeInOut
});
// Fade out like evaporating water
tween(waterDroplet, {
alpha: 0,
scaleY: 0.2
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (waterDroplet.parent) {
waterDroplet.parent.removeChild(waterDroplet);
}
}
});
// Add water color transition from light blue to transparent
tween(waterDroplet, {
tint: 0x00aaff
}, {
duration: 250,
easing: tween.easeInOut
});
}
};
self.createPurpleImplosion = function () {
var vortexCount = 16;
var initialRadius = 150;
for (var i = 0; i < vortexCount; i++) {
var angle = i / vortexCount * Math.PI * 2;
var purpleVortex = LK.getAsset('purpleVortex', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial position in a circle around the gem
var startX = self.x + Math.cos(angle) * initialRadius;
var startY = self.y + Math.sin(angle) * initialRadius;
purpleVortex.x = startX;
purpleVortex.y = startY;
purpleVortex.zIndex = 5;
// Add purple tint and initial scale
purpleVortex.tint = 0x8B00FF;
purpleVortex.scaleX = 0.5;
purpleVortex.scaleY = 0.5;
// Add to game
if (self.parent) {
self.parent.addChild(purpleVortex);
}
// Create spiral inward movement animation
tween(purpleVortex, {
x: self.x,
y: self.y,
rotation: Math.PI * 6,
// 3 full rotations inward
scaleX: 3.5,
scaleY: 3.5
}, {
duration: 600,
easing: tween.easeIn
});
// Fade in then fade out with implosion effect
tween(purpleVortex, {
alpha: 1.0
}, {
duration: 200,
easing: tween.easeOut
});
// Final implosion - scale down and disappear
tween(purpleVortex, {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 400,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (purpleVortex.parent) {
purpleVortex.parent.removeChild(purpleVortex);
}
}
});
// Color transition from purple to dark purple
tween(purpleVortex, {
tint: 0x4B0082
}, {
duration: 300,
easing: tween.easeInOut
});
}
};
self.createLeafSpiral = function () {
var leafCount = 10;
var spiralRadius = 140;
for (var i = 0; i < leafCount; i++) {
var angle = i / leafCount * Math.PI * 2;
var leafParticle = LK.getAsset('leafParticle', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial position at gem center
leafParticle.x = self.x;
leafParticle.y = self.y;
leafParticle.zIndex = 5;
// Add natural green tint and initial scale
leafParticle.tint = 0x228B22;
leafParticle.scaleX = 0.8;
leafParticle.scaleY = 0.8;
leafParticle.rotation = angle; // Initial rotation based on position
// Add to game
if (self.parent) {
self.parent.addChild(leafParticle);
}
// Create spiral outward movement with natural floating motion
var targetX = self.x + Math.cos(angle) * spiralRadius;
var targetY = self.y + Math.sin(angle) * spiralRadius;
// Add some randomness for natural leaf movement
targetX += (Math.random() - 0.5) * 60;
targetY += (Math.random() - 0.5) * 60;
// Create floating leaf movement animation
tween(leafParticle, {
x: targetX,
y: targetY,
rotation: angle + Math.PI * 3,
// 1.5 full rotations
scaleX: 2.8,
scaleY: 2.8
}, {
duration: 500,
easing: tween.easeOut
});
// Add gentle swaying motion like leaves in wind
tween(leafParticle, {
x: targetX + Math.sin(angle * 2) * 30,
y: targetY + Math.cos(angle * 2) * 20
}, {
duration: 800,
easing: tween.easeInOut
});
// Fade out like autumn leaves
tween(leafParticle, {
alpha: 0,
scaleX: 0.3,
scaleY: 0.3,
rotation: angle + Math.PI * 5 // Continue rotating as it fades
}, {
duration: 700,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (leafParticle.parent) {
leafParticle.parent.removeChild(leafParticle);
}
}
});
// Add leaf color transition from green to brown
tween(leafParticle, {
tint: 0x8B4513 // Brown color
}, {
duration: 400,
easing: tween.easeInOut
});
}
};
self.createStarExplosion = function () {
var starCount = 14;
var maxRadius = 160;
for (var i = 0; i < starCount; i++) {
var angle = i / starCount * Math.PI * 2;
var starParticle = LK.getAsset('starParticle', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial position at gem center
starParticle.x = self.x;
starParticle.y = self.y;
starParticle.zIndex = 5;
// Add golden yellow tint and initial scale
starParticle.tint = 0xFFD700;
starParticle.scaleX = 0.3;
starParticle.scaleY = 0.3;
starParticle.rotation = angle;
// Add to game
if (self.parent) {
self.parent.addChild(starParticle);
}
// Create spiral outward sun burst movement
var radius = 80 + Math.random() * 80;
var targetX = self.x + Math.cos(angle) * radius;
var targetY = self.y + Math.sin(angle) * radius;
// Add sparkle randomness for star effect
targetX += (Math.random() - 0.5) * 40;
targetY += (Math.random() - 0.5) * 40;
// Create explosive star movement animation
tween(starParticle, {
x: targetX,
y: targetY,
rotation: angle + Math.PI * 4,
// 2 full rotations
scaleX: 5.0,
scaleY: 5.0
}, {
duration: 450,
easing: tween.easeOut
});
// Add pulsing sparkle effect
tween(starParticle, {
scaleX: 6.5,
scaleY: 6.5
}, {
duration: 150,
easing: tween.easeInOut
});
// Create secondary sparkle pulse
tween(starParticle, {
scaleX: 4.5,
scaleY: 4.5,
rotation: angle + Math.PI * 6 // Continue rotating
}, {
duration: 300,
easing: tween.easeInOut
});
// Fade out like fading starlight
tween(starParticle, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2,
rotation: angle + Math.PI * 8 // Final rotation burst
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (starParticle.parent) {
starParticle.parent.removeChild(starParticle);
}
}
});
// Add star color transition from gold to bright white
tween(starParticle, {
tint: 0xFFFFFF // Bright white
}, {
duration: 350,
easing: tween.easeInOut
});
}
};
self.createLavaMelting = function () {
var lavaCount = 12;
var meltRadius = 130;
for (var i = 0; i < lavaCount; i++) {
var angle = i / lavaCount * Math.PI * 2;
var lavaParticle = LK.getAsset('lavaParticle', {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial position at gem center
lavaParticle.x = self.x;
lavaParticle.y = self.y;
lavaParticle.zIndex = 5;
// Add molten orange-red tint and initial scale
lavaParticle.tint = 0xFF4500;
lavaParticle.scaleX = 0.6;
lavaParticle.scaleY = 0.6;
lavaParticle.rotation = Math.random() * Math.PI * 2;
// Add to game
if (self.parent) {
self.parent.addChild(lavaParticle);
}
// Create melting downward movement with spiral motion
var radius = 70 + Math.random() * 60;
var targetX = self.x + Math.cos(angle) * radius;
var targetY = self.y + Math.sin(angle) * radius;
// Add downward melting bias
targetY += Math.random() * 80 + 40;
// Add some randomness for natural lava flow
targetX += (Math.random() - 0.5) * 50;
// Create lava melting movement animation
tween(lavaParticle, {
x: targetX,
y: targetY,
rotation: angle + Math.PI * 3,
// 1.5 full rotations
scaleX: 3.2,
scaleY: 3.2
}, {
duration: 550,
easing: tween.easeOut
});
// Add viscous lava dripping effect
tween(lavaParticle, {
y: targetY + 60,
scaleY: 4.0 // Stretch vertically like dripping lava
}, {
duration: 400,
easing: tween.easeIn
});
// Create molten glow pulsing effect
tween(lavaParticle, {
scaleX: 4.0,
tint: 0xFF6600 // Brighter orange
}, {
duration: 300,
easing: tween.easeInOut
});
// Cool down and solidify effect
tween(lavaParticle, {
alpha: 0,
scaleX: 0.4,
scaleY: 0.2,
tint: 0x8B0000,
// Dark red when cooling
rotation: angle + Math.PI * 5 // Continue rotating as it cools
}, {
duration: 650,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (lavaParticle.parent) {
lavaParticle.parent.removeChild(lavaParticle);
}
}
});
// Add secondary heat shimmer effect
tween(lavaParticle, {
scaleX: 2.8,
scaleY: 3.5
}, {
duration: 200,
easing: tween.easeInOut
});
}
};
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 - increased for more dramatic effect
self.velocityX = (Math.random() - 0.5) * 500;
self.velocityY = (Math.random() - 0.5) * 500;
self.gravity = 800;
self.life = 1.5;
self.fadeSpeed = 1.0;
self.scale = 1.0;
self.scaleSpeed = 0.5;
// Add initial scale animation
tween(self, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
easing: tween.easeOut
});
self.update = function () {
// Update position based on velocity
self.x += self.velocityX * (1 / 60);
self.y += self.velocityY * (1 / 60);
// Apply gravity (positive for flipped board - particles fall down visually)
self.velocityY += self.gravity * (1 / 60);
// Fade out over time
self.life -= self.fadeSpeed * (1 / 60);
self.alpha = Math.max(0, self.life);
// Scale down over time for dramatic effect
self.scale -= self.scaleSpeed * (1 / 60);
if (self.scale > 0) {
self.scaleX = self.scale;
self.scaleY = self.scale;
}
// 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_X = 6;
var GRID_SIZE_Y = 9;
var CELL_SIZE = 170;
var BOARD_OFFSET_X = (2048 - GRID_SIZE_X * CELL_SIZE) / 2;
var BOARD_OFFSET_Y = (2732 - GRID_SIZE_Y * CELL_SIZE) / 2 + 600;
var gameBoard = [];
var selectedGem = null;
var draggedGem = null;
var dragStartPos = null;
var isDragging = false;
var isSwapping = false;
var score = 0;
var comboMultiplier = 1;
// Create brown background (scrolling)
var k1 = game.attachAsset('brownBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
k1.zIndex = 1;
// Create second brown background positioned directly above the first one
var k1_second = game.attachAsset('brownBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 2732
});
k1_second.zIndex = 1;
// Variables to track background animation state
var backgroundSpeed = 2;
var backgroundY1 = 2732 / 2;
var backgroundY2 = 2732 / 2 - 2732;
// Function to update background positions
function updateBackgrounds() {
// Move both backgrounds down
backgroundY1 += backgroundSpeed;
backgroundY2 += backgroundSpeed;
k1.y = backgroundY1;
k1_second.y = backgroundY2;
// Reset positions when they move off screen
if (backgroundY1 > 2732 / 2 + 2732) {
backgroundY1 = backgroundY2 - 2732;
}
if (backgroundY2 > 2732 / 2 + 2732) {
backgroundY2 = backgroundY1 - 2732;
}
}
// Create board background
var boardBg = game.attachAsset('boardBg', {
anchorX: 0.5,
anchorY: 1.0,
x: 2048 / 2,
y: 2732 + 850
});
boardBg.zIndex = 2;
// Create explosion effect at gem position
function createExplosion(x, y, gemColor) {
var particleCount = 15;
var gemColors = [0xff2222, 0x2222ff, 0x22ff22, 0xffff22, 0xff22ff, 0xff6622];
var color = gemColors[gemColor] || 0xffffff;
for (var i = 0; i < particleCount; i++) {
var particle = new Particle(x, y, color);
game.addChild(particle);
}
}
// Create enhanced explosion effect for 4x4 groups
function createEnhancedExplosion(x, y, gemColor) {
var particleCount = 35; // More particles for enhanced effect
var gemColors = [0xff2222, 0x2222ff, 0x22ff22, 0xffff22, 0xff22ff, 0xff6622];
var color = gemColors[gemColor] || 0xffffff;
// Create main explosion with larger particles
for (var i = 0; i < particleCount; i++) {
var particle = new Particle(x, y, color);
// Make particles larger and faster for enhanced effect
particle.velocityX *= 2;
particle.velocityY *= 2;
particle.scaleX = 2.0;
particle.scaleY = 2.0;
particle.life = 2.0; // Longer lasting
game.addChild(particle);
}
// Add secondary ring explosion
for (var i = 0; i < 20; i++) {
var angle = i / 20 * Math.PI * 2;
var ringParticle = new Particle(x, y, color);
ringParticle.velocityX = Math.cos(angle) * 400;
ringParticle.velocityY = Math.sin(angle) * 400;
ringParticle.scaleX = 1.5;
ringParticle.scaleY = 1.5;
ringParticle.life = 1.8;
game.addChild(ringParticle);
}
// Flash screen effect for dramatic impact
LK.effects.flashScreen(color, 300);
}
// Create board frame
var C1 = game.attachAsset('boardFrame', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 450
});
C1.zIndex = 3;
// 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; x++) {
gameBoard[x] = [];
for (var y = 0; y < GRID_SIZE_Y; y++) {
gameBoard[x][y] = null;
}
}
}
// Fill board with random gems
function fillBoard() {
for (var x = 0; x < GRID_SIZE_X; x++) {
for (var y = 0; y < GRID_SIZE_Y; 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;
gem.zIndex = 4;
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 + (GRID_SIZE_Y - 1 - 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 = GRID_SIZE_Y - 1 - Math.floor((worldY - BOARD_OFFSET_Y) / CELL_SIZE);
if (gridX < 0 || gridX >= GRID_SIZE_X || gridY < 0 || gridY >= GRID_SIZE_Y) {
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; 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; 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;
}
// Check for 4x4 groups of same gem type
function check4x4Groups() {
var groups = [];
var processedGems = [];
for (var x = 0; x <= GRID_SIZE_X - 4; x++) {
for (var y = 0; y <= GRID_SIZE_Y - 4; y++) {
var centerGem = gameBoard[x + 1][y + 1]; // Use center gem for type checking
if (!centerGem) continue;
var gemType = centerGem.gemType;
var is4x4 = true;
var groupGems = [];
// Check all 16 positions in the 4x4 grid
for (var dx = 0; dx < 4; dx++) {
for (var dy = 0; dy < 4; dy++) {
var checkGem = gameBoard[x + dx][y + dy];
if (!checkGem || checkGem.gemType !== gemType) {
is4x4 = false;
break;
}
groupGems.push(checkGem);
}
if (!is4x4) break;
}
// If we found a valid 4x4 group, add all gems to groups
if (is4x4) {
for (var i = 0; i < groupGems.length; i++) {
var gem = groupGems[i];
var found = false;
for (var j = 0; j < processedGems.length; j++) {
if (processedGems[j] === gem) {
found = true;
break;
}
}
if (!found) {
groups.push(gem);
processedGems.push(gem);
}
}
}
}
}
return groups;
}
// Find all matches on the board
function findAllMatches() {
var allMatches = [];
var processedGems = [];
// First check for 4x4 groups (these take priority)
var groups4x4 = check4x4Groups();
for (var i = 0; i < groups4x4.length; i++) {
allMatches.push(groups4x4[i]);
processedGems.push(groups4x4[i]);
}
// Then check for regular 3+ matches
for (var x = 0; x < GRID_SIZE_X; x++) {
for (var y = 0; y < GRID_SIZE_Y; 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();
// Check if we have a 4x4 group (16 gems of same type)
var is4x4Group = false;
if (matches.length >= 16) {
// Group gems by type and check if any type has exactly 16 gems
var gemTypeCounts = {};
for (var i = 0; i < matches.length; i++) {
var gemType = matches[i].gemType;
gemTypeCounts[gemType] = (gemTypeCounts[gemType] || 0) + 1;
}
for (var type in gemTypeCounts) {
if (gemTypeCounts[type] >= 16) {
is4x4Group = true;
break;
}
}
}
// Calculate points with bonus for 4x4 groups
var basePoints = matches.length * 10;
if (is4x4Group) {
basePoints = matches.length * 50; // 5x bonus for 4x4 groups
}
var points = basePoints * comboMultiplier;
score += points;
scoreTxt.setText('SCORE: ' + score);
for (var i = 0; i < matches.length; i++) {
var gem = matches[i];
// Create enhanced explosion effect for 4x4 groups
if (is4x4Group) {
createEnhancedExplosion(gem.x, gem.y, gem.gemType);
} else {
createExplosion(gem.x, gem.y, gem.gemType);
}
gameBoard[gem.gridX][gem.gridY] = null;
gem.destroy();
}
// After clearing gems, apply gravity and fill empty spaces
LK.setTimeout(function () {
// Apply gravity repeatedly until no more gems fall
function applyGravityRepeatedly() {
var moved = applyGravity();
if (moved) {
LK.setTimeout(applyGravityRepeatedly, 100);
} else {
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);
}
}
applyGravityRepeatedly();
}, 200);
}
// Apply gravity to make gems fall
function applyGravity() {
var moved = false;
for (var x = 0; x < GRID_SIZE_X; x++) {
// Process each column from top to bottom (since board is flipped, gems fall upward)
var writeIndex = 0;
for (var y = 0; y < GRID_SIZE_Y; y++) {
if (gameBoard[x][y]) {
// If gem is not at the write position, move it up
if (y !== writeIndex) {
var gem = gameBoard[x][y];
gameBoard[x][writeIndex] = gem;
gameBoard[x][y] = null;
gem.setGridPosition(x, writeIndex);
var worldPos = gridToWorld(x, writeIndex);
gem.animateToPosition(worldPos.x, worldPos.y, 300);
moved = true;
}
writeIndex++;
}
}
}
return moved;
}
// Fill empty spaces with new gems
function fillEmptySpaces() {
for (var x = 0; x < GRID_SIZE_X; x++) {
for (var y = 0; y < GRID_SIZE_Y; 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 = BOARD_OFFSET_Y - CELL_SIZE * 2; // Start from above the top line of the flipped grid
gem.zIndex = 4;
gameBoard[x][y] = gem;
game.addChild(gem);
gem.animateToPosition(worldPos.x, worldPos.y, 150 + y * 30); // Faster staggered animation timing for flipped board
}
}
}
}
// 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;
};
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_X - 1, draggedGem.gridX + 1);
} else {
targetGridX = Math.max(0, draggedGem.gridX - 1);
}
} else {
// Vertical drag (flipped coordinate system)
if (dragDeltaY > 0) {
targetGridY = Math.max(0, draggedGem.gridY - 1);
} else {
targetGridY = Math.min(GRID_SIZE_Y - 1, 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;
draggedGem = null;
dragStartPos = null;
isDragging = false;
};
// Create grid lines around gems
function createGridLines() {
// Create vertical lines
for (var x = 0; x <= GRID_SIZE_X; x++) {
for (var lineY = 0; lineY < GRID_SIZE_Y * CELL_SIZE; lineY += 20) {
var verticalLine = LK.getAsset('particle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.05,
scaleY: 0.5
});
verticalLine.tint = 0x8B4513;
verticalLine.x = BOARD_OFFSET_X + x * CELL_SIZE;
verticalLine.y = BOARD_OFFSET_Y + lineY + 10;
verticalLine.zIndex = 3;
game.addChild(verticalLine);
}
}
// Create horizontal lines
for (var y = 0; y <= GRID_SIZE_Y; y++) {
for (var lineX = 0; lineX < GRID_SIZE_X * CELL_SIZE; lineX += 20) {
var horizontalLine = LK.getAsset('particle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.05
});
horizontalLine.tint = 0x8B4513;
horizontalLine.x = BOARD_OFFSET_X + lineX + 10;
horizontalLine.y = BOARD_OFFSET_Y + y * CELL_SIZE;
horizontalLine.zIndex = 3;
game.addChild(horizontalLine);
}
}
}
// Initialize the game
initializeBoard();
fillBoard();
createGridLines();
// Add game update loop for continuous animations
game.update = function () {
// Update scrolling backgrounds
updateBackgrounds();
};
// Start background music
LK.playMusic('background');
// Initial match clearing
LK.setTimeout(function () {
var matches = findAllMatches();
if (matches.length > 0) {
clearMatches(matches);
}
}, 100);
;
// Update scrolling backgrounds
updateBackgrounds(); ===================================================================
--- original.js
+++ change.js
@@ -629,8 +629,38 @@
var particle = new Particle(x, y, color);
game.addChild(particle);
}
}
+// Create enhanced explosion effect for 4x4 groups
+function createEnhancedExplosion(x, y, gemColor) {
+ var particleCount = 35; // More particles for enhanced effect
+ var gemColors = [0xff2222, 0x2222ff, 0x22ff22, 0xffff22, 0xff22ff, 0xff6622];
+ var color = gemColors[gemColor] || 0xffffff;
+ // Create main explosion with larger particles
+ for (var i = 0; i < particleCount; i++) {
+ var particle = new Particle(x, y, color);
+ // Make particles larger and faster for enhanced effect
+ particle.velocityX *= 2;
+ particle.velocityY *= 2;
+ particle.scaleX = 2.0;
+ particle.scaleY = 2.0;
+ particle.life = 2.0; // Longer lasting
+ game.addChild(particle);
+ }
+ // Add secondary ring explosion
+ for (var i = 0; i < 20; i++) {
+ var angle = i / 20 * Math.PI * 2;
+ var ringParticle = new Particle(x, y, color);
+ ringParticle.velocityX = Math.cos(angle) * 400;
+ ringParticle.velocityY = Math.sin(angle) * 400;
+ ringParticle.scaleX = 1.5;
+ ringParticle.scaleY = 1.5;
+ ringParticle.life = 1.8;
+ game.addChild(ringParticle);
+ }
+ // Flash screen effect for dramatic impact
+ LK.effects.flashScreen(color, 300);
+}
// Create board frame
var C1 = game.attachAsset('boardFrame', {
anchorX: 0.5,
anchorY: 0.5,
@@ -761,12 +791,63 @@
}
}
return uniqueMatches;
}
+// Check for 4x4 groups of same gem type
+function check4x4Groups() {
+ var groups = [];
+ var processedGems = [];
+ for (var x = 0; x <= GRID_SIZE_X - 4; x++) {
+ for (var y = 0; y <= GRID_SIZE_Y - 4; y++) {
+ var centerGem = gameBoard[x + 1][y + 1]; // Use center gem for type checking
+ if (!centerGem) continue;
+ var gemType = centerGem.gemType;
+ var is4x4 = true;
+ var groupGems = [];
+ // Check all 16 positions in the 4x4 grid
+ for (var dx = 0; dx < 4; dx++) {
+ for (var dy = 0; dy < 4; dy++) {
+ var checkGem = gameBoard[x + dx][y + dy];
+ if (!checkGem || checkGem.gemType !== gemType) {
+ is4x4 = false;
+ break;
+ }
+ groupGems.push(checkGem);
+ }
+ if (!is4x4) break;
+ }
+ // If we found a valid 4x4 group, add all gems to groups
+ if (is4x4) {
+ for (var i = 0; i < groupGems.length; i++) {
+ var gem = groupGems[i];
+ var found = false;
+ for (var j = 0; j < processedGems.length; j++) {
+ if (processedGems[j] === gem) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ groups.push(gem);
+ processedGems.push(gem);
+ }
+ }
+ }
+ }
+ }
+ return groups;
+}
// Find all matches on the board
function findAllMatches() {
var allMatches = [];
var processedGems = [];
+ // First check for 4x4 groups (these take priority)
+ var groups4x4 = check4x4Groups();
+ for (var i = 0; i < groups4x4.length; i++) {
+ allMatches.push(groups4x4[i]);
+ processedGems.push(groups4x4[i]);
+ }
+ // Then check for regular 3+ matches
for (var x = 0; x < GRID_SIZE_X; x++) {
for (var y = 0; y < GRID_SIZE_Y; y++) {
if (gameBoard[x][y]) {
var matches = checkMatches(x, y);
@@ -792,15 +873,40 @@
// Clear matched gems
function clearMatches(matches) {
if (matches.length === 0) return;
LK.getSound('match').play();
- var points = matches.length * 10 * comboMultiplier;
+ // Check if we have a 4x4 group (16 gems of same type)
+ var is4x4Group = false;
+ if (matches.length >= 16) {
+ // Group gems by type and check if any type has exactly 16 gems
+ var gemTypeCounts = {};
+ for (var i = 0; i < matches.length; i++) {
+ var gemType = matches[i].gemType;
+ gemTypeCounts[gemType] = (gemTypeCounts[gemType] || 0) + 1;
+ }
+ for (var type in gemTypeCounts) {
+ if (gemTypeCounts[type] >= 16) {
+ is4x4Group = true;
+ break;
+ }
+ }
+ }
+ // Calculate points with bonus for 4x4 groups
+ var basePoints = matches.length * 10;
+ if (is4x4Group) {
+ basePoints = matches.length * 50; // 5x bonus for 4x4 groups
+ }
+ var points = basePoints * comboMultiplier;
score += points;
scoreTxt.setText('SCORE: ' + score);
for (var i = 0; i < matches.length; i++) {
var gem = matches[i];
- // Create explosion effect at gem position
- createExplosion(gem.x, gem.y, gem.gemType);
+ // Create enhanced explosion effect for 4x4 groups
+ if (is4x4Group) {
+ createEnhancedExplosion(gem.x, gem.y, gem.gemType);
+ } else {
+ createExplosion(gem.x, gem.y, gem.gemType);
+ }
gameBoard[gem.gridX][gem.gridY] = null;
gem.destroy();
}
// After clearing gems, apply gravity and fill empty spaces
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