User prompt
Şekerler patlayınca ses çıksın
User prompt
Patlayan şekeri komple kaldır
User prompt
Patlayan şeker kare bir şekilde denk geldiğinde oluşsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Her seviyede şekerlerin yerleride farklı olsun
User prompt
4 şeker patlayınca patlama özellikli şeker olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Şeker patlayınca ses efekti ekle
User prompt
Şekerleri kaydırarak yer değiştirsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Şekerler patlayınca efekt olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Biraz daha büyüt az daha aşşa
User prompt
Biraz daha büyüt aşşa indir azda
User prompt
Oyunu büyült
User prompt
Üst üste girmiş düzeltirmisin
User prompt
Aynı şeyi diğer yazılardada yap
User prompt
Skor yazan yerde güzel bi textrue olsun buton gibi
User prompt
Oyunu skordan aşşada dursun
User prompt
Arka planı güzelleştir
User prompt
Please fix the bug: 'storage.get is not a function. (In 'storage.get('currentLevel')', 'storage.get' is undefined)' in or related to this line: 'var savedLevel = storage.get('currentLevel');' Line Number: 202 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Seviye geçmeli olsun
User prompt
Renklere şeker resmi koy
Code edit (1 edits merged)
Please save this source code
User prompt
Candy Match Saga
Initial prompt
Candy crush saga tarzında oyun yaparmısın
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Candy = Container.expand(function (type, gridX, gridY) {
var self = Container.call(this);
self.candyType = type;
self.gridX = gridX;
self.gridY = gridY;
self.isMoving = false;
self.isMarkedForDestroy = false;
var candyGraphics = self.attachAsset('candy_' + type, {
anchorX: 0.5,
anchorY: 0.5
});
self.moveTo = function (newGridX, newGridY, duration) {
self.gridX = newGridX;
self.gridY = newGridY;
self.isMoving = true;
var targetX = GRID_START_X + newGridX * CELL_SIZE + CELL_SIZE / 2;
var targetY = GRID_START_Y + newGridY * CELL_SIZE + CELL_SIZE / 2;
tween(self, {
x: targetX,
y: targetY
}, {
duration: duration || 300,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isMoving = false;
}
});
};
self.destroy = function () {
self.isMarkedForDestroy = true;
tween(self, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
if (self.parent) {
self.parent.removeChild(self);
}
}
});
};
return self;
});
var GridCell = Container.expand(function (gridX, gridY) {
var self = Container.call(this);
self.gridX = gridX;
self.gridY = gridY;
var cellGraphics = self.attachAsset('grid_cell', {
anchorX: 0.5,
anchorY: 0.5
});
cellGraphics.alpha = 0.3;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2a1810
});
/****
* Game Code
****/
var GRID_WIDTH = 8;
var GRID_HEIGHT = 8;
var CELL_SIZE = 90;
var GRID_START_X = (2048 - GRID_WIDTH * CELL_SIZE) / 2;
var GRID_START_Y = 400;
var CANDY_TYPES = ['red', 'blue', 'green', 'yellow', 'purple', 'orange'];
var grid = [];
var candies = [];
var selectedCandy = null;
var movesLeft = 20;
var currentScore = 0;
var targetScore = 1000;
var isProcessing = false;
var currentLevel = 1;
var maxLevel = 1;
// Level configurations
var levelConfigs = [{
level: 1,
targetScore: 1000,
moves: 20,
gridSize: 8
}, {
level: 2,
targetScore: 1500,
moves: 18,
gridSize: 8
}, {
level: 3,
targetScore: 2000,
moves: 16,
gridSize: 8
}, {
level: 4,
targetScore: 2500,
moves: 15,
gridSize: 8
}, {
level: 5,
targetScore: 3000,
moves: 14,
gridSize: 8
}, {
level: 6,
targetScore: 3500,
moves: 13,
gridSize: 8
}, {
level: 7,
targetScore: 4000,
moves: 12,
gridSize: 8
}, {
level: 8,
targetScore: 4500,
moves: 11,
gridSize: 8
}, {
level: 9,
targetScore: 5000,
moves: 10,
gridSize: 8
}, {
level: 10,
targetScore: 6000,
moves: 10,
gridSize: 8
}];
// Initialize grid cells
for (var y = 0; y < GRID_HEIGHT; y++) {
grid[y] = [];
for (var x = 0; x < GRID_WIDTH; x++) {
var cell = new GridCell(x, y);
cell.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2;
cell.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2;
game.addChild(cell);
grid[y][x] = null;
}
}
// UI Elements
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreText.y = 100;
var movesText = new Text2('Moves: ' + movesLeft, {
size: 50,
fill: 0xFFFFFF
});
movesText.anchor.set(0.5, 0);
LK.gui.top.addChild(movesText);
movesText.y = 180;
var targetText = new Text2('Target: ' + targetScore, {
size: 40,
fill: 0xFFDD44
});
targetText.anchor.set(0.5, 0);
LK.gui.top.addChild(targetText);
targetText.y = 240;
var levelText = new Text2('Level: ' + currentLevel, {
size: 50,
fill: 0x00FF00
});
levelText.anchor.set(0.5, 0);
LK.gui.top.addChild(levelText);
levelText.y = 300;
function getRandomCandyType() {
return CANDY_TYPES[Math.floor(Math.random() * CANDY_TYPES.length)];
}
function loadProgress() {
var savedLevel = storage.get('currentLevel');
var savedMaxLevel = storage.get('maxLevel');
if (savedLevel) {
currentLevel = parseInt(savedLevel);
}
if (savedMaxLevel) {
maxLevel = parseInt(savedMaxLevel);
}
}
function saveProgress() {
storage.set('currentLevel', currentLevel.toString());
storage.set('maxLevel', maxLevel.toString());
}
function getCurrentLevelConfig() {
if (currentLevel <= levelConfigs.length) {
return levelConfigs[currentLevel - 1];
}
// For levels beyond predefined configs, generate dynamic difficulty
return {
level: currentLevel,
targetScore: 1000 + (currentLevel - 1) * 750,
moves: Math.max(8, 20 - Math.floor(currentLevel / 2)),
gridSize: 8
};
}
function initializeLevel() {
var config = getCurrentLevelConfig();
targetScore = config.targetScore;
movesLeft = config.moves;
currentScore = 0;
// Update UI
levelText.setText('Level: ' + currentLevel);
scoreText.setText('Score: 0');
movesText.setText('Moves: ' + movesLeft);
targetText.setText('Target: ' + targetScore);
// Clear existing candies
for (var i = candies.length - 1; i >= 0; i--) {
var candy = candies[i];
if (candy.parent) {
candy.parent.removeChild(candy);
}
}
candies = [];
// Reset grid
for (var y = 0; y < GRID_HEIGHT; y++) {
for (var x = 0; x < GRID_WIDTH; x++) {
grid[y][x] = null;
}
}
// Initialize new grid
initializeGrid();
}
function completeLevel() {
if (currentLevel >= maxLevel) {
maxLevel = currentLevel + 1;
}
currentLevel++;
saveProgress();
// Show level complete message briefly before starting next level
var levelCompleteText = new Text2('Level Complete!', {
size: 80,
fill: 0x00FF00
});
levelCompleteText.anchor.set(0.5, 0.5);
levelCompleteText.x = 2048 / 2;
levelCompleteText.y = 2732 / 2;
game.addChild(levelCompleteText);
// Animate text
levelCompleteText.scaleX = 0;
levelCompleteText.scaleY = 0;
tween(levelCompleteText, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(levelCompleteText, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 500,
delay: 1000,
easing: tween.easeIn,
onFinish: function onFinish() {
if (levelCompleteText.parent) {
levelCompleteText.parent.removeChild(levelCompleteText);
}
initializeLevel();
}
});
}
});
}
function createCandy(x, y, type) {
type = type || getRandomCandyType();
var candy = new Candy(type, x, y);
candy.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2;
candy.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2;
game.addChild(candy);
candies.push(candy);
grid[y][x] = candy;
return candy;
}
function initializeGrid() {
for (var y = 0; y < GRID_HEIGHT; y++) {
for (var x = 0; x < GRID_WIDTH; x++) {
var type;
var attempts = 0;
do {
type = getRandomCandyType();
attempts++;
if (attempts > 10) break;
} while (wouldCreateMatch(x, y, type));
createCandy(x, y, type);
}
}
}
function wouldCreateMatch(x, y, type) {
var horizontalCount = 1;
var verticalCount = 1;
// Check horizontal
var i = x - 1;
while (i >= 0 && grid[y][i] && grid[y][i].candyType === type) {
horizontalCount++;
i--;
}
i = x + 1;
while (i < GRID_WIDTH && grid[y][i] && grid[y][i].candyType === type) {
horizontalCount++;
i++;
}
// Check vertical
i = y - 1;
while (i >= 0 && grid[i][x] && grid[i][x].candyType === type) {
verticalCount++;
i--;
}
i = y + 1;
while (i < GRID_HEIGHT && grid[i][x] && grid[i][x].candyType === type) {
verticalCount++;
i++;
}
return horizontalCount >= 3 || verticalCount >= 3;
}
function findMatches() {
var matches = [];
var processed = [];
for (var y = 0; y < GRID_HEIGHT; y++) {
processed[y] = [];
for (var x = 0; x < GRID_WIDTH; x++) {
processed[y][x] = false;
}
}
// Find horizontal matches
for (var y = 0; y < GRID_HEIGHT; y++) {
for (var x = 0; x < GRID_WIDTH - 2; x++) {
if (!grid[y][x] || processed[y][x]) continue;
var type = grid[y][x].candyType;
var matchLength = 1;
var startX = x;
while (x + matchLength < GRID_WIDTH && grid[y][x + matchLength] && grid[y][x + matchLength].candyType === type) {
matchLength++;
}
if (matchLength >= 3) {
for (var i = 0; i < matchLength; i++) {
if (!processed[y][startX + i]) {
matches.push(grid[y][startX + i]);
processed[y][startX + i] = true;
}
}
}
}
}
// Find vertical matches
for (var x = 0; x < GRID_WIDTH; x++) {
for (var y = 0; y < GRID_HEIGHT - 2; y++) {
if (!grid[y][x] || processed[y][x]) continue;
var type = grid[y][x].candyType;
var matchLength = 1;
var startY = y;
while (y + matchLength < GRID_HEIGHT && grid[y + matchLength][x] && grid[y + matchLength][x].candyType === type) {
matchLength++;
}
if (matchLength >= 3) {
for (var i = 0; i < matchLength; i++) {
if (!processed[startY + i][x]) {
matches.push(grid[startY + i][x]);
processed[startY + i][x] = true;
}
}
}
}
}
return matches;
}
function clearMatches(matches) {
if (matches.length === 0) return;
LK.getSound('match').play();
currentScore += matches.length * 50;
scoreText.setText('Score: ' + currentScore);
for (var i = 0; i < matches.length; i++) {
var candy = matches[i];
grid[candy.gridY][candy.gridX] = null;
candy.destroy();
// Remove from candies array
var index = candies.indexOf(candy);
if (index > -1) {
candies.splice(index, 1);
}
}
}
function applyGravity() {
var moved = false;
for (var x = 0; x < GRID_WIDTH; x++) {
var writeY = GRID_HEIGHT - 1;
for (var y = GRID_HEIGHT - 1; y >= 0; y--) {
if (grid[y][x] && !grid[y][x].isMarkedForDestroy) {
if (y !== writeY) {
grid[writeY][x] = grid[y][x];
grid[y][x] = null;
grid[writeY][x].moveTo(x, writeY, 200);
moved = true;
}
writeY--;
}
}
// Fill empty spaces at top
for (var emptyY = writeY; emptyY >= 0; emptyY--) {
var newCandy = createCandy(x, emptyY, getRandomCandyType());
newCandy.y = GRID_START_Y - (writeY - emptyY + 1) * CELL_SIZE + CELL_SIZE / 2;
newCandy.moveTo(x, emptyY, 300);
moved = true;
}
}
return moved;
}
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 swapCandies(candy1, candy2) {
// Swap in grid
grid[candy1.gridY][candy1.gridX] = candy2;
grid[candy2.gridY][candy2.gridX] = candy1;
// Swap positions
var tempX = candy1.gridX;
var tempY = candy1.gridY;
candy1.moveTo(candy2.gridX, candy2.gridY, 200);
candy2.moveTo(tempX, tempY, 200);
}
function processMatches() {
if (isProcessing) return;
isProcessing = true;
LK.setTimeout(function () {
var matches = findMatches();
if (matches.length > 0) {
clearMatches(matches);
LK.setTimeout(function () {
if (applyGravity()) {
LK.setTimeout(function () {
isProcessing = false;
processMatches(); // Check for cascading matches
}, 400);
} else {
isProcessing = false;
checkGameState();
}
}, 300);
} else {
isProcessing = false;
checkGameState();
}
}, 100);
}
function checkGameState() {
if (currentScore >= targetScore) {
completeLevel();
return;
}
if (movesLeft <= 0) {
LK.showGameOver();
return;
}
}
game.down = function (x, y, obj) {
if (isProcessing) return;
var gridX = Math.floor((x - GRID_START_X) / CELL_SIZE);
var gridY = Math.floor((y - GRID_START_Y) / CELL_SIZE);
if (gridX < 0 || gridX >= GRID_WIDTH || gridY < 0 || gridY >= GRID_HEIGHT) {
selectedCandy = null;
return;
}
var clickedCandy = grid[gridY][gridX];
if (!clickedCandy || clickedCandy.isMoving) {
selectedCandy = null;
return;
}
if (selectedCandy === null) {
selectedCandy = clickedCandy;
selectedCandy.scaleX = 1.1;
selectedCandy.scaleY = 1.1;
} else if (selectedCandy === clickedCandy) {
selectedCandy.scaleX = 1.0;
selectedCandy.scaleY = 1.0;
selectedCandy = null;
} else if (areAdjacent(selectedCandy, clickedCandy)) {
selectedCandy.scaleX = 1.0;
selectedCandy.scaleY = 1.0;
// Try swap
swapCandies(selectedCandy, clickedCandy);
LK.getSound('swap').play();
LK.setTimeout(function () {
var matches = findMatches();
if (matches.length > 0) {
movesLeft--;
movesText.setText('Moves: ' + movesLeft);
processMatches();
} else {
// Swap back if no matches
swapCandies(selectedCandy, clickedCandy);
}
selectedCandy = null;
}, 250);
} else {
selectedCandy.scaleX = 1.0;
selectedCandy.scaleY = 1.0;
selectedCandy = clickedCandy;
selectedCandy.scaleX = 1.1;
selectedCandy.scaleY = 1.1;
}
};
// Initialize the game
loadProgress();
initializeLevel(); ===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
@@ -86,8 +87,62 @@
var movesLeft = 20;
var currentScore = 0;
var targetScore = 1000;
var isProcessing = false;
+var currentLevel = 1;
+var maxLevel = 1;
+// Level configurations
+var levelConfigs = [{
+ level: 1,
+ targetScore: 1000,
+ moves: 20,
+ gridSize: 8
+}, {
+ level: 2,
+ targetScore: 1500,
+ moves: 18,
+ gridSize: 8
+}, {
+ level: 3,
+ targetScore: 2000,
+ moves: 16,
+ gridSize: 8
+}, {
+ level: 4,
+ targetScore: 2500,
+ moves: 15,
+ gridSize: 8
+}, {
+ level: 5,
+ targetScore: 3000,
+ moves: 14,
+ gridSize: 8
+}, {
+ level: 6,
+ targetScore: 3500,
+ moves: 13,
+ gridSize: 8
+}, {
+ level: 7,
+ targetScore: 4000,
+ moves: 12,
+ gridSize: 8
+}, {
+ level: 8,
+ targetScore: 4500,
+ moves: 11,
+ gridSize: 8
+}, {
+ level: 9,
+ targetScore: 5000,
+ moves: 10,
+ gridSize: 8
+}, {
+ level: 10,
+ targetScore: 6000,
+ moves: 10,
+ gridSize: 8
+}];
// Initialize grid cells
for (var y = 0; y < GRID_HEIGHT; y++) {
grid[y] = [];
for (var x = 0; x < GRID_WIDTH; x++) {
@@ -119,11 +174,115 @@
});
targetText.anchor.set(0.5, 0);
LK.gui.top.addChild(targetText);
targetText.y = 240;
+var levelText = new Text2('Level: ' + currentLevel, {
+ size: 50,
+ fill: 0x00FF00
+});
+levelText.anchor.set(0.5, 0);
+LK.gui.top.addChild(levelText);
+levelText.y = 300;
function getRandomCandyType() {
return CANDY_TYPES[Math.floor(Math.random() * CANDY_TYPES.length)];
}
+function loadProgress() {
+ var savedLevel = storage.get('currentLevel');
+ var savedMaxLevel = storage.get('maxLevel');
+ if (savedLevel) {
+ currentLevel = parseInt(savedLevel);
+ }
+ if (savedMaxLevel) {
+ maxLevel = parseInt(savedMaxLevel);
+ }
+}
+function saveProgress() {
+ storage.set('currentLevel', currentLevel.toString());
+ storage.set('maxLevel', maxLevel.toString());
+}
+function getCurrentLevelConfig() {
+ if (currentLevel <= levelConfigs.length) {
+ return levelConfigs[currentLevel - 1];
+ }
+ // For levels beyond predefined configs, generate dynamic difficulty
+ return {
+ level: currentLevel,
+ targetScore: 1000 + (currentLevel - 1) * 750,
+ moves: Math.max(8, 20 - Math.floor(currentLevel / 2)),
+ gridSize: 8
+ };
+}
+function initializeLevel() {
+ var config = getCurrentLevelConfig();
+ targetScore = config.targetScore;
+ movesLeft = config.moves;
+ currentScore = 0;
+ // Update UI
+ levelText.setText('Level: ' + currentLevel);
+ scoreText.setText('Score: 0');
+ movesText.setText('Moves: ' + movesLeft);
+ targetText.setText('Target: ' + targetScore);
+ // Clear existing candies
+ for (var i = candies.length - 1; i >= 0; i--) {
+ var candy = candies[i];
+ if (candy.parent) {
+ candy.parent.removeChild(candy);
+ }
+ }
+ candies = [];
+ // Reset grid
+ for (var y = 0; y < GRID_HEIGHT; y++) {
+ for (var x = 0; x < GRID_WIDTH; x++) {
+ grid[y][x] = null;
+ }
+ }
+ // Initialize new grid
+ initializeGrid();
+}
+function completeLevel() {
+ if (currentLevel >= maxLevel) {
+ maxLevel = currentLevel + 1;
+ }
+ currentLevel++;
+ saveProgress();
+ // Show level complete message briefly before starting next level
+ var levelCompleteText = new Text2('Level Complete!', {
+ size: 80,
+ fill: 0x00FF00
+ });
+ levelCompleteText.anchor.set(0.5, 0.5);
+ levelCompleteText.x = 2048 / 2;
+ levelCompleteText.y = 2732 / 2;
+ game.addChild(levelCompleteText);
+ // Animate text
+ levelCompleteText.scaleX = 0;
+ levelCompleteText.scaleY = 0;
+ tween(levelCompleteText, {
+ scaleX: 1,
+ scaleY: 1,
+ alpha: 1
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(levelCompleteText, {
+ scaleX: 0,
+ scaleY: 0,
+ alpha: 0
+ }, {
+ duration: 500,
+ delay: 1000,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ if (levelCompleteText.parent) {
+ levelCompleteText.parent.removeChild(levelCompleteText);
+ }
+ initializeLevel();
+ }
+ });
+ }
+ });
+}
function createCandy(x, y, type) {
type = type || getRandomCandyType();
var candy = new Candy(type, x, y);
candy.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2;
@@ -306,9 +465,9 @@
}, 100);
}
function checkGameState() {
if (currentScore >= targetScore) {
- LK.showYouWin();
+ completeLevel();
return;
}
if (movesLeft <= 0) {
LK.showGameOver();
@@ -362,5 +521,6 @@
selectedCandy.scaleY = 1.1;
}
};
// Initialize the game
-initializeGrid();
\ No newline at end of file
+loadProgress();
+initializeLevel();
\ No newline at end of file
Modern App Store icon, high definition, square with rounded corners, for a game titled "Candy Match Saga" and with the description "A match-3 puzzle game where players swap candies to create matching lines, clear objectives, and progress through challenging levels.". No text on icon!
Mavi şeker resmi. In-Game asset. 2d. High contrast. No shadows
Sarı şeker. In-Game asset. 2d. High contrast. No shadows
Kırmızı şeker. In-Game asset. 2d. High contrast. No shadows
Yeşil şeker. In-Game asset. 2d. High contrast. No shadows
Turuncu şeker. In-Game asset. 2d. High contrast. No shadows