User prompt
Herhangi oyuncu 5 gol attığı an oyun dursun
User prompt
Herhangi oyuncu 5 gol attıktan sonra oyun dursun ve bitsin
User prompt
5 gol atıldıktan sonra oyun bitsin
User prompt
Topu 2.5 kat hızlandır
User prompt
Topu 1.3 kat hızlı yap
User prompt
Topu 1.5 kat hızlandr
User prompt
Paddle i kontrol edmiyorum kontrol edilebilir yap
User prompt
Kaledeki şeyleri kontrol edemiyom düzelt
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(winnerText, 500, {' Line Number: 158 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyun sonunda kazanan oyuncunun kazandığını yazsın
User prompt
Kale görünüşünü sil
User prompt
Önceki gibi yap
User prompt
Futbol kalesini üstten görünüş yap 2d gibi
User prompt
Topu 2 kat yavaşlat
User prompt
Topu 3 kat hızlandır
User prompt
Kale çizgisi arkada olsun
User prompt
Kalede olan kontrol ede bildiğimiz çizgi daha önde olsun kale çizgisi arkada olsun
User prompt
Kaledeki çizgiler biraz daha önde olsun çok değil
User prompt
Topun hızını 2 kat artır
User prompt
2 kişilik futbol oyununa benzer oyun yap top duvarlardan falan seksin kalede kontrol edebildiğimiz dörtgen şey olsun top ondanda seksin 5 gol atan kazansın
User prompt
Patlama efektleri yok ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Sweet Match Quest
Initial prompt
Candy crush benzeri oyun yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Candy = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
self.gridX = 0;
self.gridY = 0;
self.isAnimating = false;
var candyGraphics = self.attachAsset('candy' + type, {
anchorX: 0.5,
anchorY: 0.5
});
self.setGridPosition = function (gridX, gridY) {
self.gridX = gridX;
self.gridY = gridY;
self.x = GRID_START_X + gridX * CELL_SIZE;
self.y = GRID_START_Y + gridY * CELL_SIZE;
};
self.animateToPosition = function (newX, newY, callback) {
self.isAnimating = true;
tween(self, {
x: newX,
y: newY
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isAnimating = false;
if (callback) callback();
}
});
};
self.down = function (x, y, obj) {
if (self.isAnimating) return;
handleCandySelection(self);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var GRID_SIZE = 8;
var CELL_SIZE = 200;
var GRID_START_X = (2048 - GRID_SIZE * CELL_SIZE) / 2;
var GRID_START_Y = 400;
var CANDY_TYPES = 6;
var grid = [];
var selectedCandy = null;
var isProcessing = false;
var movesLeft = 30;
var targetScore = 5000;
var isGameActive = true;
// Initialize UI
var scoreText = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var movesText = new Text2('Moves: ' + movesLeft, {
size: 60,
fill: 0xFFFFFF
});
movesText.anchor.set(1, 0);
movesText.x = -20;
movesText.y = 20;
LK.gui.topRight.addChild(movesText);
var targetText = new Text2('Target: ' + targetScore, {
size: 60,
fill: 0xFFFF00
});
targetText.anchor.set(0, 0);
targetText.x = 20;
targetText.y = 20;
LK.gui.topLeft.addChild(targetText);
// Create grid background
for (var i = 0; i < GRID_SIZE; i++) {
for (var j = 0; j < GRID_SIZE; j++) {
var bg = game.addChild(LK.getAsset('gridBg', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3
}));
bg.x = GRID_START_X + i * CELL_SIZE;
bg.y = GRID_START_Y + j * CELL_SIZE;
}
}
function initializeGrid() {
grid = [];
for (var i = 0; i < GRID_SIZE; i++) {
grid[i] = [];
for (var j = 0; j < GRID_SIZE; j++) {
var candyType = Math.floor(Math.random() * CANDY_TYPES) + 1;
var candy = new Candy(candyType);
candy.setGridPosition(i, j);
grid[i][j] = candy;
game.addChild(candy);
}
}
// Remove initial matches
removeInitialMatches();
}
function removeInitialMatches() {
var hasMatches = true;
var attempts = 0;
while (hasMatches && attempts < 50) {
hasMatches = false;
attempts++;
for (var i = 0; i < GRID_SIZE; i++) {
for (var j = 0; j < GRID_SIZE; j++) {
if (grid[i][j]) {
// Check horizontal matches
if (i < GRID_SIZE - 2 && grid[i][j].type === grid[i + 1][j].type && grid[i][j].type === grid[i + 2][j].type) {
grid[i][j].type = Math.floor(Math.random() * CANDY_TYPES) + 1;
hasMatches = true;
}
// Check vertical matches
if (j < GRID_SIZE - 2 && grid[i][j].type === grid[i][j + 1].type && grid[i][j].type === grid[i][j + 2].type) {
grid[i][j].type = Math.floor(Math.random() * CANDY_TYPES) + 1;
hasMatches = true;
}
}
}
}
}
}
function handleCandySelection(candy) {
if (!isGameActive || isProcessing) return;
if (!selectedCandy) {
selectedCandy = candy;
tween(candy, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100
});
} else {
if (selectedCandy === candy) {
// Deselect
tween(selectedCandy, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
selectedCandy = null;
} else if (areAdjacent(selectedCandy, candy)) {
// Attempt swap
attemptSwap(selectedCandy, candy);
} else {
// Select new candy
tween(selectedCandy, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
selectedCandy = candy;
tween(candy, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100
});
}
}
}
function areAdjacent(candy1, candy2) {
var dx = Math.abs(candy1.gridX - candy2.gridX);
var dy = Math.abs(candy1.gridY - candy2.gridY);
return dx === 1 && dy === 0 || dx === 0 && dy === 1;
}
function attemptSwap(candy1, candy2) {
isProcessing = true;
// Swap positions in grid
var tempX = candy1.gridX;
var tempY = candy1.gridY;
grid[candy1.gridX][candy1.gridY] = candy2;
grid[candy2.gridX][candy2.gridY] = candy1;
candy1.gridX = candy2.gridX;
candy1.gridY = candy2.gridY;
candy2.gridX = tempX;
candy2.gridY = tempY;
// Animate swap
var newX1 = GRID_START_X + candy1.gridX * CELL_SIZE;
var newY1 = GRID_START_Y + candy1.gridY * CELL_SIZE;
var newX2 = GRID_START_X + candy2.gridX * CELL_SIZE;
var newY2 = GRID_START_Y + candy2.gridY * CELL_SIZE;
var animationsCompleted = 0;
candy1.animateToPosition(newX1, newY1, function () {
animationsCompleted++;
if (animationsCompleted === 2) {
checkSwapResult(candy1, candy2);
}
});
candy2.animateToPosition(newX2, newY2, function () {
animationsCompleted++;
if (animationsCompleted === 2) {
checkSwapResult(candy1, candy2);
}
});
LK.getSound('swap').play();
}
function checkSwapResult(candy1, candy2) {
var matches = findMatches();
if (matches.length > 0) {
// Valid move
movesLeft--;
updateUI();
tween(selectedCandy, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
selectedCandy = null;
processMatches(matches);
} else {
// Invalid move - swap back
var tempX = candy1.gridX;
var tempY = candy1.gridY;
grid[candy1.gridX][candy1.gridY] = candy2;
grid[candy2.gridX][candy2.gridY] = candy1;
candy1.gridX = candy2.gridX;
candy1.gridY = candy2.gridY;
candy2.gridX = tempX;
candy2.gridY = tempY;
var newX1 = GRID_START_X + candy1.gridX * CELL_SIZE;
var newY1 = GRID_START_Y + candy1.gridY * CELL_SIZE;
var newX2 = GRID_START_X + candy2.gridX * CELL_SIZE;
var newY2 = GRID_START_Y + candy2.gridY * CELL_SIZE;
var revertAnimations = 0;
candy1.animateToPosition(newX1, newY1, function () {
revertAnimations++;
if (revertAnimations === 2) {
tween(selectedCandy, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
selectedCandy = null;
isProcessing = false;
}
});
candy2.animateToPosition(newX2, newY2, function () {
revertAnimations++;
if (revertAnimations === 2) {
tween(selectedCandy, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
selectedCandy = null;
isProcessing = false;
}
});
}
}
function findMatches() {
var matches = [];
var processed = [];
// Initialize processed array
for (var i = 0; i < GRID_SIZE; i++) {
processed[i] = [];
for (var j = 0; j < GRID_SIZE; j++) {
processed[i][j] = false;
}
}
// Find horizontal matches
for (var j = 0; j < GRID_SIZE; j++) {
for (var i = 0; i < GRID_SIZE - 2; i++) {
if (grid[i][j] && grid[i + 1][j] && grid[i + 2][j] && grid[i][j].type === grid[i + 1][j].type && grid[i][j].type === grid[i + 2][j].type) {
var matchGroup = [];
var type = grid[i][j].type;
var k = i;
while (k < GRID_SIZE && grid[k][j] && grid[k][j].type === type) {
if (!processed[k][j]) {
matchGroup.push({
x: k,
y: j
});
processed[k][j] = true;
}
k++;
}
if (matchGroup.length >= 3) {
matches.push(matchGroup);
}
}
}
}
// Find vertical matches
for (var i = 0; i < GRID_SIZE; i++) {
for (var j = 0; j < GRID_SIZE - 2; j++) {
if (grid[i][j] && grid[i][j + 1] && grid[i][j + 2] && grid[i][j].type === grid[i][j + 1].type && grid[i][j].type === grid[i][j + 2].type) {
var matchGroup = [];
var type = grid[i][j].type;
var k = j;
while (k < GRID_SIZE && grid[i][k] && grid[i][k].type === type) {
if (!processed[i][k]) {
matchGroup.push({
x: i,
y: k
});
processed[i][k] = true;
}
k++;
}
if (matchGroup.length >= 3) {
matches.push(matchGroup);
}
}
}
}
return matches;
}
function processMatches(matches) {
if (matches.length === 0) {
isProcessing = false;
checkGameState();
return;
}
var totalMatched = 0;
var candiesToExplode = [];
// Collect candies to explode
for (var i = 0; i < matches.length; i++) {
var matchGroup = matches[i];
for (var j = 0; j < matchGroup.length; j++) {
var pos = matchGroup[j];
if (grid[pos.x][pos.y]) {
candiesToExplode.push(grid[pos.x][pos.y]);
totalMatched++;
}
}
}
// Start explosion animations
var explosionsCompleted = 0;
for (var k = 0; k < candiesToExplode.length; k++) {
var candy = candiesToExplode[k];
// Explosion effect: scale up and fade out
tween(candy, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 250,
easing: tween.easeOut,
onFinish: function onFinish() {
explosionsCompleted++;
if (explosionsCompleted === candiesToExplode.length) {
// All explosions complete, now remove candies
for (var m = 0; m < candiesToExplode.length; m++) {
var explodedCandy = candiesToExplode[m];
for (var x = 0; x < GRID_SIZE; x++) {
for (var y = 0; y < GRID_SIZE; y++) {
if (grid[x][y] === explodedCandy) {
grid[x][y].destroy();
grid[x][y] = null;
}
}
}
}
// Calculate score
var baseScore = totalMatched * 100;
var bonus = Math.max(0, (totalMatched - 3) * 50);
var scoreGained = baseScore + bonus;
LK.setScore(LK.getScore() + scoreGained);
updateUI();
// Drop candies and fill gaps
LK.setTimeout(function () {
dropCandies();
}, 50);
}
}
});
}
LK.getSound('match').play();
}
function dropCandies() {
var hasDropped = false;
// Drop existing candies
for (var i = 0; i < GRID_SIZE; i++) {
var writePos = GRID_SIZE - 1;
for (var j = GRID_SIZE - 1; j >= 0; j--) {
if (grid[i][j]) {
if (j !== writePos) {
grid[i][writePos] = grid[i][j];
grid[i][j] = null;
grid[i][writePos].gridY = writePos;
hasDropped = true;
}
writePos--;
}
}
}
// Animate drops
if (hasDropped) {
for (var i = 0; i < GRID_SIZE; i++) {
for (var j = 0; j < GRID_SIZE; j++) {
if (grid[i][j]) {
var newY = GRID_START_Y + j * CELL_SIZE;
if (grid[i][j].y !== newY) {
grid[i][j].animateToPosition(grid[i][j].x, newY);
}
}
}
}
}
// Fill empty spaces
LK.setTimeout(function () {
fillEmptySpaces();
}, 250);
}
function fillEmptySpaces() {
for (var i = 0; i < GRID_SIZE; i++) {
for (var j = 0; j < GRID_SIZE; j++) {
if (!grid[i][j]) {
var candyType = Math.floor(Math.random() * CANDY_TYPES) + 1;
var candy = new Candy(candyType);
candy.setGridPosition(i, j);
candy.y = GRID_START_Y - CELL_SIZE;
grid[i][j] = candy;
game.addChild(candy);
candy.animateToPosition(candy.x, GRID_START_Y + j * CELL_SIZE);
}
}
}
// Check for new matches after fill
LK.setTimeout(function () {
var newMatches = findMatches();
if (newMatches.length > 0) {
processMatches(newMatches);
} else {
isProcessing = false;
checkGameState();
}
}, 300);
}
function updateUI() {
scoreText.setText('Score: ' + LK.getScore());
movesText.setText('Moves: ' + movesLeft);
}
function checkGameState() {
if (!isGameActive) return;
if (LK.getScore() >= targetScore) {
isGameActive = false;
LK.showYouWin();
return;
}
if (movesLeft <= 0) {
isGameActive = false;
LK.showGameOver();
return;
}
// Check if there are valid moves available
if (!hasValidMoves()) {
isGameActive = false;
LK.showGameOver();
}
}
function hasValidMoves() {
for (var i = 0; i < GRID_SIZE; i++) {
for (var j = 0; j < GRID_SIZE; j++) {
if (grid[i][j]) {
// Check horizontal swap
if (i < GRID_SIZE - 1 && grid[i + 1][j]) {
if (wouldCreateMatch(i, j, i + 1, j)) {
return true;
}
}
// Check vertical swap
if (j < GRID_SIZE - 1 && grid[i][j + 1]) {
if (wouldCreateMatch(i, j, i, j + 1)) {
return true;
}
}
}
}
}
return false;
}
function wouldCreateMatch(x1, y1, x2, y2) {
// Temporarily swap
var temp = grid[x1][y1].type;
grid[x1][y1].type = grid[x2][y2].type;
grid[x2][y2].type = temp;
var hasMatch = checkPositionForMatch(x1, y1) || checkPositionForMatch(x2, y2);
// Swap back
temp = grid[x1][y1].type;
grid[x1][y1].type = grid[x2][y2].type;
grid[x2][y2].type = temp;
return hasMatch;
}
function checkPositionForMatch(x, y) {
var type = grid[x][y].type;
// Check horizontal
var count = 1;
var i = x - 1;
while (i >= 0 && grid[i][y] && grid[i][y].type === type) {
count++;
i--;
}
i = x + 1;
while (i < GRID_SIZE && grid[i][y] && grid[i][y].type === type) {
count++;
i++;
}
if (count >= 3) return true;
// Check vertical
count = 1;
var j = y - 1;
while (j >= 0 && grid[x][j] && grid[x][j].type === type) {
count++;
j--;
}
j = y + 1;
while (j < GRID_SIZE && grid[x][j] && grid[x][j].type === type) {
count++;
j++;
}
if (count >= 3) return true;
return false;
}
// Initialize the game
initializeGrid();
updateUI(); ===================================================================
--- original.js
+++ change.js
@@ -336,31 +336,62 @@
checkGameState();
return;
}
var totalMatched = 0;
- // Remove matched candies
+ var candiesToExplode = [];
+ // Collect candies to explode
for (var i = 0; i < matches.length; i++) {
var matchGroup = matches[i];
for (var j = 0; j < matchGroup.length; j++) {
var pos = matchGroup[j];
if (grid[pos.x][pos.y]) {
- grid[pos.x][pos.y].destroy();
- grid[pos.x][pos.y] = null;
+ candiesToExplode.push(grid[pos.x][pos.y]);
totalMatched++;
}
}
}
- // Calculate score
- var baseScore = totalMatched * 100;
- var bonus = Math.max(0, (totalMatched - 3) * 50);
- var scoreGained = baseScore + bonus;
- LK.setScore(LK.getScore() + scoreGained);
- updateUI();
+ // Start explosion animations
+ var explosionsCompleted = 0;
+ for (var k = 0; k < candiesToExplode.length; k++) {
+ var candy = candiesToExplode[k];
+ // Explosion effect: scale up and fade out
+ tween(candy, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0
+ }, {
+ duration: 250,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ explosionsCompleted++;
+ if (explosionsCompleted === candiesToExplode.length) {
+ // All explosions complete, now remove candies
+ for (var m = 0; m < candiesToExplode.length; m++) {
+ var explodedCandy = candiesToExplode[m];
+ for (var x = 0; x < GRID_SIZE; x++) {
+ for (var y = 0; y < GRID_SIZE; y++) {
+ if (grid[x][y] === explodedCandy) {
+ grid[x][y].destroy();
+ grid[x][y] = null;
+ }
+ }
+ }
+ }
+ // Calculate score
+ var baseScore = totalMatched * 100;
+ var bonus = Math.max(0, (totalMatched - 3) * 50);
+ var scoreGained = baseScore + bonus;
+ LK.setScore(LK.getScore() + scoreGained);
+ updateUI();
+ // Drop candies and fill gaps
+ LK.setTimeout(function () {
+ dropCandies();
+ }, 50);
+ }
+ }
+ });
+ }
LK.getSound('match').play();
- // Drop candies and fill gaps
- LK.setTimeout(function () {
- dropCandies();
- }, 300);
}
function dropCandies() {
var hasDropped = false;
// Drop existing candies