User prompt
You Win ekraninda menu yada next butonu olsun bunun sayesinde kullanici bir sonraki levele gecebilsin eger 2. levelde gecildiyse 3. levelin kilidi acilsin. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Challenge'in 2. levelinde bolum gecme sarti 2x kombo yapmak 45 saniye icerisinde yapamazsan kazanamazsin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Ana menudeki Challenge butonu griden normale cevrilsin
User prompt
blocklar birbirine biraz daha yakin gozuksunler
User prompt
Bloklarin arasindaki bosluk biraz azaltilsin birbirlerine yakin gozuksunler
User prompt
You Win yazisinin altinda 2 buton gozuksun Level 2 and Main Menu
User prompt
Challenge butonu aktiflestirilsin ve icerisindeki Level 1 butonundaki oyunun amaci 1000 puan toplamak olsun ve ardindan level 2 butonunun kilidi acilsin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Kombo baslangicta 0 olsun ve ekranda gozukmesin, kombo timer'i olmasin
User prompt
Herhangi bir butona basildignda daha onceki ekran temizlensin yazilar veya ekranlar ust uste binmesin
User prompt
Challenge butonuna basinca kullaniciyi levellerin yazdigi bir ekran karsilasin Level 1 den Level 10 a dogru giden butonlar olsun
User prompt
Oyunun ana menusune 2 buton ekleyelim birisi oyunun suanki halini calistiran buton ismi Arcade olsun diger butonun adi Challenge olsun onu suanlik islevsiz birakalim
User prompt
Ayni anda birden fazla sutun yada satirdaki taslar patlarsa combo toplam patlayan satir ve sutun sayisi kadar artar
User prompt
Sag uste pause butonu dugmesi eklensin durdurma menusu icin
User prompt
Sol ustten oyun durdurulmadikca oyun durdurma menusu acilmasin
User prompt
Pause menusune oyunu bitir ve ana menuye don menusu eklensin
User prompt
Ayni bloklari kullaniciya verme sikligini azalt, play butonuna bastiktan sonra play yazisi ekranda kaliyor oda duzeltilsin
User prompt
Kullanicinin high skoru tutulsun, ana menu tasarlansin simdilik sadece oyna butonu ve daha once yaptigi high score gozuksun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Combo kaldigi yerden x2 x3 seklinde devam etsin pespese 3-4 blok koyarak yapilirsa kombo devam etsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Taslar satiri veya sutunu doldurmadan once patlarken taslarin gorunumu degissin tek renk olsunlar her seferinde farkli bir asset kullanalim ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Combo yazisi ekranin ortasinda 1-2 saniyeligine gozuksun ve pesi sira bloklar patladikca kombo artsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
10x10 grid i 8x8 yapalım ancak zoom in yapalım
User prompt
Gri alanı büyüt
User prompt
Gri alanı biraz daha ekrana sığdır
User prompt
Gri alanı büyük ekrana sığdır
User prompt
Gri alanı ekrana sığdıralım ama kare sayısı aynı kalsın
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BlockPiece = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('blockPiece', { anchorX: 0.5, anchorY: 0.5 }); self.gridX = 0; self.gridY = 0; self.color = 0xff6b6b; self.setColor = function (color) { self.color = color; graphics.tint = color; }; return self; }); var GamePiece = Container.expand(function () { var self = Container.call(this); self.blocks = []; self.shape = []; self.isDragging = false; self.canPlace = false; self.createShape = function (shapeData) { self.shape = shapeData; for (var i = 0; i < shapeData.length; i++) { for (var j = 0; j < shapeData[i].length; j++) { if (shapeData[i][j] === 1) { var block = new BlockPiece(); block.x = j * 120; block.y = i * 120; block.setColor(pieceColors[Math.floor(Math.random() * pieceColors.length)]); self.blocks.push(block); self.addChild(block); } } } }; self.down = function (x, y, obj) { if (!self.isDragging) { self.isDragging = true; draggedPiece = self; self.originalX = self.x; self.originalY = self.y; self.alpha = 0.7; } }; return self; }); var Particle = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.lifetime = 1000; self.maxLifetime = 1000; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += 0.5; // gravity self.lifetime -= 16.67; // 60fps var alpha = self.lifetime / self.maxLifetime; graphics.alpha = alpha; if (self.lifetime <= 0) { self.destroy(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0a0a0a }); /**** * Game Code ****/ var GRID_SIZE = 8; var CELL_SIZE = 120; var GRID_OFFSET_X = 464; var GRID_OFFSET_Y = 450; var grid = []; var gameGrid = []; var pieceShapes = [[[1]], // Single block [[1, 1]], // Line 2 [[1, 1, 1]], // Line 3 [[1], [1]], // Vertical 2 [[1], [1], [1]], // Vertical 3 [[1, 1], [1, 1]], // Square 2x2 [[1, 1, 1], [1, 0, 0]], // L shape [[1, 1, 1], [0, 0, 1]], // Reverse L [[1, 1, 0], [0, 1, 1]] // Z shape ]; var pieceColors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0xf7dc6f, 0xbb8fce, 0x58d68d, 0xf39c12]; var currentPieces = []; var draggedPiece = null; var previewBlocks = []; var particles = []; var comboCounter = 0; var lastClearTime = 0; var comboMultiplier = 1; // Initialize grid for (var i = 0; i < GRID_SIZE; i++) { grid[i] = []; gameGrid[i] = []; for (var j = 0; j < GRID_SIZE; j++) { var cell = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, x: GRID_OFFSET_X + j * CELL_SIZE + CELL_SIZE / 2, y: GRID_OFFSET_Y + i * CELL_SIZE + CELL_SIZE / 2 }); grid[i][j] = cell; gameGrid[i][j] = null; game.addChild(cell); } } // Initialize UI var scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var comboTxt = new Text2('', { size: 60, fill: 0xFFFF00 }); comboTxt.anchor.set(1, 0); LK.gui.topRight.addChild(comboTxt); // Piece panel var piecePanel = LK.getAsset('piecePanel', { anchorX: 0.5, anchorY: 1, x: 1024, y: 2732 }); game.addChild(piecePanel); function createNewPieces() { // Clear existing pieces for (var i = 0; i < currentPieces.length; i++) { currentPieces[i].destroy(); } currentPieces = []; // Create 3 new pieces for (var i = 0; i < 3; i++) { var piece = new GamePiece(); var shapeIndex = Math.floor(Math.random() * pieceShapes.length); piece.createShape(pieceShapes[shapeIndex]); piece.x = 350 + i * 500; piece.y = 2550; currentPieces.push(piece); game.addChild(piece); } } function getGridPosition(x, y) { var gridX = Math.floor((x - GRID_OFFSET_X) / CELL_SIZE); var gridY = Math.floor((y - GRID_OFFSET_Y) / CELL_SIZE); return { x: gridX, y: gridY }; } function canPlacePiece(piece, gridX, gridY) { for (var i = 0; i < piece.shape.length; i++) { for (var j = 0; j < piece.shape[i].length; j++) { if (piece.shape[i][j] === 1) { var checkX = gridX + j; var checkY = gridY + i; if (checkX < 0 || checkX >= GRID_SIZE || checkY < 0 || checkY >= GRID_SIZE) { return false; } if (gameGrid[checkY][checkX] !== null) { return false; } } } } return true; } function placePiece(piece, gridX, gridY) { for (var i = 0; i < piece.shape.length; i++) { for (var j = 0; j < piece.shape[i].length; j++) { if (piece.shape[i][j] === 1) { var placeX = gridX + j; var placeY = gridY + i; var block = new BlockPiece(); block.x = GRID_OFFSET_X + placeX * CELL_SIZE + CELL_SIZE / 2; block.y = GRID_OFFSET_Y + placeY * CELL_SIZE + CELL_SIZE / 2; block.setColor(piece.blocks[0].color); block.gridX = placeX; block.gridY = placeY; gameGrid[placeY][placeX] = block; game.addChild(block); } } } LK.getSound('blockPlace').play(); } function clearPreview() { for (var i = 0; i < previewBlocks.length; i++) { previewBlocks[i].destroy(); } previewBlocks = []; } function showPreview(piece, gridX, gridY) { clearPreview(); if (canPlacePiece(piece, gridX, gridY)) { for (var i = 0; i < piece.shape.length; i++) { for (var j = 0; j < piece.shape[i].length; j++) { if (piece.shape[i][j] === 1) { var previewX = gridX + j; var previewY = gridY + i; var preview = LK.getAsset('previewBlock', { anchorX: 0.5, anchorY: 0.5, x: GRID_OFFSET_X + previewX * CELL_SIZE + CELL_SIZE / 2, y: GRID_OFFSET_Y + previewY * CELL_SIZE + CELL_SIZE / 2, alpha: 0.5 }); previewBlocks.push(preview); game.addChild(preview); } } } } } function checkLines() { var clearedBlocks = []; // Check for complete rows for (var i = 0; i < GRID_SIZE; i++) { var rowComplete = true; for (var j = 0; j < GRID_SIZE; j++) { if (gameGrid[i][j] === null) { rowComplete = false; break; } } if (rowComplete) { for (var j = 0; j < GRID_SIZE; j++) { clearedBlocks.push({ x: j, y: i }); } } } // Check for complete columns for (var j = 0; j < GRID_SIZE; j++) { var colComplete = true; for (var i = 0; i < GRID_SIZE; i++) { if (gameGrid[i][j] === null) { colComplete = false; break; } } if (colComplete) { for (var i = 0; i < GRID_SIZE; i++) { clearedBlocks.push({ x: j, y: i }); } } } if (clearedBlocks.length > 0) { clearBlocks(clearedBlocks); return true; } return false; } function clearBlocks(blockPositions) { var currentTime = Date.now(); // Check if this clear is within 3 blocks of the last clear var timeSinceLastClear = currentTime - lastClearTime; if (timeSinceLastClear < 3000) { // 3 seconds window for combo comboCounter++; } else { comboCounter = 1; } lastClearTime = currentTime; // Calculate multiplier based on combo comboMultiplier = comboCounter; var uniqueBlocks = []; var seen = {}; for (var i = 0; i < blockPositions.length; i++) { var pos = blockPositions[i]; var key = pos.x + "," + pos.y; if (!seen[key] && gameGrid[pos.y][pos.x] !== null) { seen[key] = true; uniqueBlocks.push(pos); } } // Create explosion effects for (var i = 0; i < uniqueBlocks.length; i++) { var pos = uniqueBlocks[i]; var block = gameGrid[pos.y][pos.x]; if (block) { createExplosion(block.x, block.y, block.color); block.destroy(); gameGrid[pos.y][pos.x] = null; } } // Screen effects var flashColor = comboCounter > 3 ? 0xff0000 : 0xffffff; var flashDuration = Math.min(comboCounter * 100 + 200, 800); LK.effects.flashScreen(flashColor, flashDuration); // Update score with combo multiplier var basePoints = uniqueBlocks.length * 10; var finalPoints = basePoints * comboMultiplier; LK.setScore(LK.getScore() + Math.floor(finalPoints)); scoreTxt.setText(LK.getScore()); // Update combo display if (comboCounter > 1) { comboTxt.setText("COMBO x" + comboCounter); // Animate combo text tween(comboTxt, { scaleX: 1.5, scaleY: 1.5 }, { duration: 200, easing: tween.easeOut }); tween(comboTxt, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.easeInOut }); // Add color flash to combo text tween(comboTxt, { tint: 0xFFFF00 }, { duration: 100, onFinish: function onFinish() { tween(comboTxt, { tint: 0xFFFFFF }, { duration: 200 }); } }); } else { comboTxt.setText("COMBO x1"); // Reset combo text color comboTxt.tint = 0xFFFFFF; } // Play sound if (comboCounter > 2) { LK.getSound('comboClear').play(); } else { LK.getSound('lineClear').play(); } } function createExplosion(x, y, color) { var particleCount = Math.min(comboCounter * 2 + 5, 20); for (var i = 0; i < particleCount; i++) { var particle = new Particle(); particle.x = x; particle.y = y; particle.velocityX = (Math.random() - 0.5) * 10; particle.velocityY = (Math.random() - 0.5) * 10 - 5; particle.lifetime = 500 + Math.random() * 500; particle.maxLifetime = particle.lifetime; var particleGraphics = particle.children[0]; particleGraphics.tint = color; particles.push(particle); game.addChild(particle); } } function checkGameOver() { for (var i = 0; i < currentPieces.length; i++) { var piece = currentPieces[i]; var canPlace = false; for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE; col++) { if (canPlacePiece(piece, col, row)) { canPlace = true; break; } } if (canPlace) break; } if (canPlace) return false; } return true; } game.move = function (x, y, obj) { if (draggedPiece) { draggedPiece.x = x; draggedPiece.y = y; var gridPos = getGridPosition(x, y); showPreview(draggedPiece, gridPos.x, gridPos.y); } }; game.up = function (x, y, obj) { if (draggedPiece) { var gridPos = getGridPosition(x, y); if (canPlacePiece(draggedPiece, gridPos.x, gridPos.y)) { placePiece(draggedPiece, gridPos.x, gridPos.y); // Remove piece from current pieces var index = currentPieces.indexOf(draggedPiece); if (index > -1) { currentPieces.splice(index, 1); } draggedPiece.destroy(); // Check for clears checkLines(); // Create new pieces if all are used if (currentPieces.length === 0) { createNewPieces(); } } else { // Return piece to original position tween(draggedPiece, { x: draggedPiece.originalX, y: draggedPiece.originalY, alpha: 1 }, { duration: 300 }); draggedPiece.isDragging = false; } clearPreview(); draggedPiece = null; } }; game.update = function () { // Clean up particles for (var i = particles.length - 1; i >= 0; i--) { var particle = particles[i]; if (particle.lifetime <= 0) { particles.splice(i, 1); } } // Reset combo if enough time passed (3 seconds) if (Date.now() - lastClearTime > 3000 && comboCounter > 0) { comboCounter = 0; comboTxt.setText(""); } // Check game over if (currentPieces.length > 0 && checkGameOver()) { LK.showGameOver(); } }; // Initialize game createNewPieces(); comboTxt.setText("COMBO x1"); LK.playMusic('bgmusic'); ;
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BlockPiece = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('blockPiece', {
anchorX: 0.5,
anchorY: 0.5
});
self.gridX = 0;
self.gridY = 0;
self.color = 0xff6b6b;
self.setColor = function (color) {
self.color = color;
graphics.tint = color;
};
return self;
});
var GamePiece = Container.expand(function () {
var self = Container.call(this);
self.blocks = [];
self.shape = [];
self.isDragging = false;
self.canPlace = false;
self.createShape = function (shapeData) {
self.shape = shapeData;
for (var i = 0; i < shapeData.length; i++) {
for (var j = 0; j < shapeData[i].length; j++) {
if (shapeData[i][j] === 1) {
var block = new BlockPiece();
block.x = j * 120;
block.y = i * 120;
block.setColor(pieceColors[Math.floor(Math.random() * pieceColors.length)]);
self.blocks.push(block);
self.addChild(block);
}
}
}
};
self.down = function (x, y, obj) {
if (!self.isDragging) {
self.isDragging = true;
draggedPiece = self;
self.originalX = self.x;
self.originalY = self.y;
self.alpha = 0.7;
}
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.lifetime = 1000;
self.maxLifetime = 1000;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += 0.5; // gravity
self.lifetime -= 16.67; // 60fps
var alpha = self.lifetime / self.maxLifetime;
graphics.alpha = alpha;
if (self.lifetime <= 0) {
self.destroy();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0a0a0a
});
/****
* Game Code
****/
var GRID_SIZE = 8;
var CELL_SIZE = 120;
var GRID_OFFSET_X = 464;
var GRID_OFFSET_Y = 450;
var grid = [];
var gameGrid = [];
var pieceShapes = [[[1]],
// Single block
[[1, 1]],
// Line 2
[[1, 1, 1]],
// Line 3
[[1], [1]],
// Vertical 2
[[1], [1], [1]],
// Vertical 3
[[1, 1], [1, 1]],
// Square 2x2
[[1, 1, 1], [1, 0, 0]],
// L shape
[[1, 1, 1], [0, 0, 1]],
// Reverse L
[[1, 1, 0], [0, 1, 1]] // Z shape
];
var pieceColors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0xf7dc6f, 0xbb8fce, 0x58d68d, 0xf39c12];
var currentPieces = [];
var draggedPiece = null;
var previewBlocks = [];
var particles = [];
var comboCounter = 0;
var lastClearTime = 0;
var comboMultiplier = 1;
// Initialize grid
for (var i = 0; i < GRID_SIZE; i++) {
grid[i] = [];
gameGrid[i] = [];
for (var j = 0; j < GRID_SIZE; j++) {
var cell = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5,
x: GRID_OFFSET_X + j * CELL_SIZE + CELL_SIZE / 2,
y: GRID_OFFSET_Y + i * CELL_SIZE + CELL_SIZE / 2
});
grid[i][j] = cell;
gameGrid[i][j] = null;
game.addChild(cell);
}
}
// Initialize UI
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var comboTxt = new Text2('', {
size: 60,
fill: 0xFFFF00
});
comboTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(comboTxt);
// Piece panel
var piecePanel = LK.getAsset('piecePanel', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: 2732
});
game.addChild(piecePanel);
function createNewPieces() {
// Clear existing pieces
for (var i = 0; i < currentPieces.length; i++) {
currentPieces[i].destroy();
}
currentPieces = [];
// Create 3 new pieces
for (var i = 0; i < 3; i++) {
var piece = new GamePiece();
var shapeIndex = Math.floor(Math.random() * pieceShapes.length);
piece.createShape(pieceShapes[shapeIndex]);
piece.x = 350 + i * 500;
piece.y = 2550;
currentPieces.push(piece);
game.addChild(piece);
}
}
function getGridPosition(x, y) {
var gridX = Math.floor((x - GRID_OFFSET_X) / CELL_SIZE);
var gridY = Math.floor((y - GRID_OFFSET_Y) / CELL_SIZE);
return {
x: gridX,
y: gridY
};
}
function canPlacePiece(piece, gridX, gridY) {
for (var i = 0; i < piece.shape.length; i++) {
for (var j = 0; j < piece.shape[i].length; j++) {
if (piece.shape[i][j] === 1) {
var checkX = gridX + j;
var checkY = gridY + i;
if (checkX < 0 || checkX >= GRID_SIZE || checkY < 0 || checkY >= GRID_SIZE) {
return false;
}
if (gameGrid[checkY][checkX] !== null) {
return false;
}
}
}
}
return true;
}
function placePiece(piece, gridX, gridY) {
for (var i = 0; i < piece.shape.length; i++) {
for (var j = 0; j < piece.shape[i].length; j++) {
if (piece.shape[i][j] === 1) {
var placeX = gridX + j;
var placeY = gridY + i;
var block = new BlockPiece();
block.x = GRID_OFFSET_X + placeX * CELL_SIZE + CELL_SIZE / 2;
block.y = GRID_OFFSET_Y + placeY * CELL_SIZE + CELL_SIZE / 2;
block.setColor(piece.blocks[0].color);
block.gridX = placeX;
block.gridY = placeY;
gameGrid[placeY][placeX] = block;
game.addChild(block);
}
}
}
LK.getSound('blockPlace').play();
}
function clearPreview() {
for (var i = 0; i < previewBlocks.length; i++) {
previewBlocks[i].destroy();
}
previewBlocks = [];
}
function showPreview(piece, gridX, gridY) {
clearPreview();
if (canPlacePiece(piece, gridX, gridY)) {
for (var i = 0; i < piece.shape.length; i++) {
for (var j = 0; j < piece.shape[i].length; j++) {
if (piece.shape[i][j] === 1) {
var previewX = gridX + j;
var previewY = gridY + i;
var preview = LK.getAsset('previewBlock', {
anchorX: 0.5,
anchorY: 0.5,
x: GRID_OFFSET_X + previewX * CELL_SIZE + CELL_SIZE / 2,
y: GRID_OFFSET_Y + previewY * CELL_SIZE + CELL_SIZE / 2,
alpha: 0.5
});
previewBlocks.push(preview);
game.addChild(preview);
}
}
}
}
}
function checkLines() {
var clearedBlocks = [];
// Check for complete rows
for (var i = 0; i < GRID_SIZE; i++) {
var rowComplete = true;
for (var j = 0; j < GRID_SIZE; j++) {
if (gameGrid[i][j] === null) {
rowComplete = false;
break;
}
}
if (rowComplete) {
for (var j = 0; j < GRID_SIZE; j++) {
clearedBlocks.push({
x: j,
y: i
});
}
}
}
// Check for complete columns
for (var j = 0; j < GRID_SIZE; j++) {
var colComplete = true;
for (var i = 0; i < GRID_SIZE; i++) {
if (gameGrid[i][j] === null) {
colComplete = false;
break;
}
}
if (colComplete) {
for (var i = 0; i < GRID_SIZE; i++) {
clearedBlocks.push({
x: j,
y: i
});
}
}
}
if (clearedBlocks.length > 0) {
clearBlocks(clearedBlocks);
return true;
}
return false;
}
function clearBlocks(blockPositions) {
var currentTime = Date.now();
// Check if this clear is within 3 blocks of the last clear
var timeSinceLastClear = currentTime - lastClearTime;
if (timeSinceLastClear < 3000) {
// 3 seconds window for combo
comboCounter++;
} else {
comboCounter = 1;
}
lastClearTime = currentTime;
// Calculate multiplier based on combo
comboMultiplier = comboCounter;
var uniqueBlocks = [];
var seen = {};
for (var i = 0; i < blockPositions.length; i++) {
var pos = blockPositions[i];
var key = pos.x + "," + pos.y;
if (!seen[key] && gameGrid[pos.y][pos.x] !== null) {
seen[key] = true;
uniqueBlocks.push(pos);
}
}
// Create explosion effects
for (var i = 0; i < uniqueBlocks.length; i++) {
var pos = uniqueBlocks[i];
var block = gameGrid[pos.y][pos.x];
if (block) {
createExplosion(block.x, block.y, block.color);
block.destroy();
gameGrid[pos.y][pos.x] = null;
}
}
// Screen effects
var flashColor = comboCounter > 3 ? 0xff0000 : 0xffffff;
var flashDuration = Math.min(comboCounter * 100 + 200, 800);
LK.effects.flashScreen(flashColor, flashDuration);
// Update score with combo multiplier
var basePoints = uniqueBlocks.length * 10;
var finalPoints = basePoints * comboMultiplier;
LK.setScore(LK.getScore() + Math.floor(finalPoints));
scoreTxt.setText(LK.getScore());
// Update combo display
if (comboCounter > 1) {
comboTxt.setText("COMBO x" + comboCounter);
// Animate combo text
tween(comboTxt, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
easing: tween.easeOut
});
tween(comboTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeInOut
});
// Add color flash to combo text
tween(comboTxt, {
tint: 0xFFFF00
}, {
duration: 100,
onFinish: function onFinish() {
tween(comboTxt, {
tint: 0xFFFFFF
}, {
duration: 200
});
}
});
} else {
comboTxt.setText("COMBO x1");
// Reset combo text color
comboTxt.tint = 0xFFFFFF;
}
// Play sound
if (comboCounter > 2) {
LK.getSound('comboClear').play();
} else {
LK.getSound('lineClear').play();
}
}
function createExplosion(x, y, color) {
var particleCount = Math.min(comboCounter * 2 + 5, 20);
for (var i = 0; i < particleCount; i++) {
var particle = new Particle();
particle.x = x;
particle.y = y;
particle.velocityX = (Math.random() - 0.5) * 10;
particle.velocityY = (Math.random() - 0.5) * 10 - 5;
particle.lifetime = 500 + Math.random() * 500;
particle.maxLifetime = particle.lifetime;
var particleGraphics = particle.children[0];
particleGraphics.tint = color;
particles.push(particle);
game.addChild(particle);
}
}
function checkGameOver() {
for (var i = 0; i < currentPieces.length; i++) {
var piece = currentPieces[i];
var canPlace = false;
for (var row = 0; row < GRID_SIZE; row++) {
for (var col = 0; col < GRID_SIZE; col++) {
if (canPlacePiece(piece, col, row)) {
canPlace = true;
break;
}
}
if (canPlace) break;
}
if (canPlace) return false;
}
return true;
}
game.move = function (x, y, obj) {
if (draggedPiece) {
draggedPiece.x = x;
draggedPiece.y = y;
var gridPos = getGridPosition(x, y);
showPreview(draggedPiece, gridPos.x, gridPos.y);
}
};
game.up = function (x, y, obj) {
if (draggedPiece) {
var gridPos = getGridPosition(x, y);
if (canPlacePiece(draggedPiece, gridPos.x, gridPos.y)) {
placePiece(draggedPiece, gridPos.x, gridPos.y);
// Remove piece from current pieces
var index = currentPieces.indexOf(draggedPiece);
if (index > -1) {
currentPieces.splice(index, 1);
}
draggedPiece.destroy();
// Check for clears
checkLines();
// Create new pieces if all are used
if (currentPieces.length === 0) {
createNewPieces();
}
} else {
// Return piece to original position
tween(draggedPiece, {
x: draggedPiece.originalX,
y: draggedPiece.originalY,
alpha: 1
}, {
duration: 300
});
draggedPiece.isDragging = false;
}
clearPreview();
draggedPiece = null;
}
};
game.update = function () {
// Clean up particles
for (var i = particles.length - 1; i >= 0; i--) {
var particle = particles[i];
if (particle.lifetime <= 0) {
particles.splice(i, 1);
}
}
// Reset combo if enough time passed (3 seconds)
if (Date.now() - lastClearTime > 3000 && comboCounter > 0) {
comboCounter = 0;
comboTxt.setText("");
}
// Check game over
if (currentPieces.length > 0 && checkGameOver()) {
LK.showGameOver();
}
};
// Initialize game
createNewPieces();
comboTxt.setText("COMBO x1");
LK.playMusic('bgmusic');
;