User prompt
Zaman Baskısı
User prompt
son isteğimi kaldır
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < powerUpData.length; i++) {' Line Number: 140
User prompt
alta seçilebilir özellikler olsun
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of null (reading 'gridX')' in or related to this line: 'explodeBomb(bombGem.gridX, bombGem.gridY);' Line Number: 542
User prompt
oklar ekle ve patlatınca bulunduğu sıranın hepsini patlatsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
eski bölüm arka plaanda kalmasın
User prompt
skor 500 olunca bölüm bitsin ve yeni bölüm başlasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bomba patlaşasındada elşas başına 5 puan
User prompt
elşas başına 5 puan gelsin
User prompt
boşbayı patlatmak için yanındaki elmas ile yer değiştirmesi lazım ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bombayı patlatmak için başka bir mekanik ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bomba ekle ve patladığında 3x3 bir alanı patlatsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
toplara patlama efekti ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Gem Match Blitz
Initial prompt
candy crush tarzı bir oyun yapalım
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Gem = Container.expand(function (type) {
var self = Container.call(this);
self.gemType = type;
self.gridX = 0;
self.gridY = 0;
self.falling = false;
var gemAssets = ['redGem', 'blueGem', 'greenGem', 'yellowGem', 'purpleGem', 'orangeGem'];
var gemGraphics = self.attachAsset(gemAssets[type], {
anchorX: 0.5,
anchorY: 0.5
});
self.setGridPosition = function (gridX, gridY) {
self.gridX = gridX;
self.gridY = gridY;
self.x = BOARD_OFFSET_X + gridX * CELL_SIZE + CELL_SIZE / 2;
self.y = BOARD_OFFSET_Y + gridY * CELL_SIZE + CELL_SIZE / 2;
};
self.animateToPosition = function (targetX, targetY, duration, onComplete) {
tween(self, {
x: targetX,
y: targetY
}, {
duration: duration || 300,
easing: tween.easeOut,
onFinish: onComplete
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var GRID_SIZE = 8;
var CELL_SIZE = 200;
var BOARD_SIZE = GRID_SIZE * CELL_SIZE;
var BOARD_OFFSET_X = (2048 - BOARD_SIZE) / 2;
var BOARD_OFFSET_Y = (2732 - BOARD_SIZE) / 2 - 200;
var grid = [];
var selectedGem = null;
var swapping = false;
var processingMatches = false;
var score = 0;
var cascadeMultiplier = 1;
// Initialize grid array
for (var x = 0; x < GRID_SIZE; x++) {
grid[x] = [];
for (var y = 0; y < GRID_SIZE; y++) {
grid[x][y] = null;
}
}
// Create board background
var boardBg = game.attachAsset('board', {
anchorX: 0.5,
anchorY: 0.5,
x: BOARD_OFFSET_X + BOARD_SIZE / 2,
y: BOARD_OFFSET_Y + BOARD_SIZE / 2
});
// Create score display
var scoreTxt = new Text2('Score: 0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 150;
function createRandomGem(x, y) {
var gemType = Math.floor(Math.random() * 6);
var gem = new Gem(gemType);
gem.setGridPosition(x, y);
game.addChild(gem);
grid[x][y] = gem;
return gem;
}
function initializeBoard() {
for (var x = 0; x < GRID_SIZE; x++) {
for (var y = 0; y < GRID_SIZE; y++) {
createRandomGem(x, y);
}
}
// Remove initial matches to ensure valid starting board
while (findMatches().length > 0) {
var matches = findMatches();
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
var newGem = createRandomGem(match.x, match.y);
match.gem.destroy();
grid[match.x][match.y] = newGem;
}
}
}
function findMatches() {
var matches = [];
// Check horizontal matches
for (var y = 0; y < GRID_SIZE; y++) {
var count = 1;
var currentType = grid[0][y] ? grid[0][y].gemType : -1;
for (var x = 1; x < GRID_SIZE; x++) {
var gem = grid[x][y];
if (gem && gem.gemType === currentType) {
count++;
} else {
if (count >= 3) {
for (var i = x - count; i < x; i++) {
matches.push({
x: i,
y: y,
gem: grid[i][y]
});
}
}
count = 1;
currentType = gem ? gem.gemType : -1;
}
}
if (count >= 3) {
for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) {
matches.push({
x: i,
y: y,
gem: grid[i][y]
});
}
}
}
// Check vertical matches
for (var x = 0; x < GRID_SIZE; x++) {
var count = 1;
var currentType = grid[x][0] ? grid[x][0].gemType : -1;
for (var y = 1; y < GRID_SIZE; y++) {
var gem = grid[x][y];
if (gem && gem.gemType === currentType) {
count++;
} else {
if (count >= 3) {
for (var i = y - count; i < y; i++) {
matches.push({
x: x,
y: i,
gem: grid[x][i]
});
}
}
count = 1;
currentType = gem ? gem.gemType : -1;
}
}
if (count >= 3) {
for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) {
matches.push({
x: x,
y: i,
gem: grid[x][i]
});
}
}
}
return matches;
}
function removeMatches() {
var matches = findMatches();
if (matches.length === 0) {
cascadeMultiplier = 1;
processingMatches = false;
return false;
}
// Add score
var baseScore = matches.length * 10;
score += baseScore * cascadeMultiplier;
scoreTxt.setText('Score: ' + score);
// Remove matched gems with explosion effect
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
if (match.gem) {
// Create explosion effect
tween(match.gem, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
if (match.gem) {
match.gem.destroy();
}
}
});
LK.effects.flashObject(match.gem, 0xffffff, 200);
grid[match.x][match.y] = null;
}
}
LK.getSound('match').play();
cascadeMultiplier++;
return true;
}
function dropGems() {
var gemsDropped = false;
for (var x = 0; x < GRID_SIZE; x++) {
// Collect existing gems from bottom to top
var gems = [];
for (var y = GRID_SIZE - 1; y >= 0; y--) {
if (grid[x][y]) {
gems.push(grid[x][y]);
grid[x][y] = null;
}
}
// Place gems at bottom
for (var i = 0; i < gems.length; i++) {
var newY = GRID_SIZE - 1 - i;
grid[x][newY] = gems[i];
gems[i].gridY = newY;
var targetY = BOARD_OFFSET_Y + newY * CELL_SIZE + CELL_SIZE / 2;
if (gems[i].y !== targetY) {
gems[i].animateToPosition(gems[i].x, targetY, 300);
gemsDropped = true;
}
}
// Fill empty spaces with new gems
for (var y = 0; y < GRID_SIZE - gems.length; y++) {
var newGem = createRandomGem(x, y);
newGem.y = BOARD_OFFSET_Y - (GRID_SIZE - gems.length - y) * CELL_SIZE + CELL_SIZE / 2;
newGem.animateToPosition(newGem.x, BOARD_OFFSET_Y + y * CELL_SIZE + CELL_SIZE / 2, 300 + y * 50);
gemsDropped = true;
}
}
if (gemsDropped) {
LK.getSound('cascade').play();
}
return gemsDropped;
}
function isValidSwap(gem1, gem2) {
var dx = Math.abs(gem1.gridX - gem2.gridX);
var dy = Math.abs(gem1.gridY - gem2.gridY);
return dx === 1 && dy === 0 || dx === 0 && dy === 1;
}
function swapGems(gem1, gem2) {
if (swapping || !isValidSwap(gem1, gem2)) return;
swapping = true;
// Store original positions
var x1 = gem1.gridX,
y1 = gem1.gridY;
var x2 = gem2.gridX,
y2 = gem2.gridY;
// Update grid
grid[x1][y1] = gem2;
grid[x2][y2] = gem1;
// Update gem positions
gem1.gridX = x2;
gem1.gridY = y2;
gem2.gridX = x1;
gem2.gridY = y1;
// Animate swap
var targetX1 = BOARD_OFFSET_X + x2 * CELL_SIZE + CELL_SIZE / 2;
var targetY1 = BOARD_OFFSET_Y + y2 * CELL_SIZE + CELL_SIZE / 2;
var targetX2 = BOARD_OFFSET_X + x1 * CELL_SIZE + CELL_SIZE / 2;
var targetY2 = BOARD_OFFSET_Y + y1 * CELL_SIZE + CELL_SIZE / 2;
var swapsCompleted = 0;
function onSwapComplete() {
swapsCompleted++;
if (swapsCompleted === 2) {
// Check if swap created matches
if (findMatches().length > 0) {
LK.getSound('swap').play();
processingMatches = true;
cascadeMultiplier = 1;
} else {
// Swap back if no matches
grid[x1][y1] = gem1;
grid[x2][y2] = gem2;
gem1.gridX = x1;
gem1.gridY = y1;
gem2.gridX = x2;
gem2.gridY = y2;
gem1.animateToPosition(BOARD_OFFSET_X + x1 * CELL_SIZE + CELL_SIZE / 2, BOARD_OFFSET_Y + y1 * CELL_SIZE + CELL_SIZE / 2, 200);
gem2.animateToPosition(BOARD_OFFSET_X + x2 * CELL_SIZE + CELL_SIZE / 2, BOARD_OFFSET_Y + y2 * CELL_SIZE + CELL_SIZE / 2, 200);
}
swapping = false;
}
}
gem1.animateToPosition(targetX1, targetY1, 300, onSwapComplete);
gem2.animateToPosition(targetX2, targetY2, 300, onSwapComplete);
}
function getGemAt(x, y) {
var gridX = Math.floor((x - BOARD_OFFSET_X) / CELL_SIZE);
var gridY = Math.floor((y - BOARD_OFFSET_Y) / CELL_SIZE);
if (gridX >= 0 && gridX < GRID_SIZE && gridY >= 0 && gridY < GRID_SIZE) {
return grid[gridX][gridY];
}
return null;
}
game.down = function (x, y, obj) {
if (swapping || processingMatches) return;
var gem = getGemAt(x, y);
if (gem) {
if (selectedGem) {
if (selectedGem === gem) {
// Deselect
tween.stop(selectedGem, {
scaleX: true,
scaleY: true
});
tween(selectedGem, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
selectedGem = null;
} else {
// Try to swap
swapGems(selectedGem, gem);
tween.stop(selectedGem, {
scaleX: true,
scaleY: true
});
tween(selectedGem, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
selectedGem = null;
}
} else {
// Select gem
selectedGem = gem;
tween(gem, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
}
}
};
game.update = function () {
if (processingMatches && !swapping) {
if (removeMatches()) {
LK.setTimeout(function () {
if (dropGems()) {
LK.setTimeout(function () {
processingMatches = true;
}, 400);
} else {
processingMatches = false;
cascadeMultiplier = 1;
}
}, 300);
} else {
dropGems();
}
}
};
// Initialize the game
initializeBoard(); ===================================================================
--- original.js
+++ change.js
@@ -182,14 +182,27 @@
// Add score
var baseScore = matches.length * 10;
score += baseScore * cascadeMultiplier;
scoreTxt.setText('Score: ' + score);
- // Remove matched gems
+ // Remove matched gems with explosion effect
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
if (match.gem) {
+ // Create explosion effect
+ tween(match.gem, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ if (match.gem) {
+ match.gem.destroy();
+ }
+ }
+ });
LK.effects.flashObject(match.gem, 0xffffff, 200);
- match.gem.destroy();
grid[match.x][match.y] = null;
}
}
LK.getSound('match').play();
mavi bir elmas. In-Game asset. 2d. High contrast. No shadows
yeşil elmas. In-Game asset. 2d. High contrast. No shadows
turuncu elmas. In-Game asset. 2d. High contrast. No shadows
mor elmas. In-Game asset. 2d. High contrast. No shadows
kırmızı elmas. In-Game asset. 2d. High contrast. No shadows
sarı elmas. In-Game asset. 2d. High contrast. No shadows
bomba. In-Game asset. 2d. High contrast. No shadows
çift tarafl ok. In-Game asset. 2d. High contrast. No shadows