User prompt
ana menüdeki dil değiştirdiğimiz butonu kaldır çabuk
User prompt
ana menüdeki how to playin altına bide dil butonu ekliyelim türkçe dil olsun ingilizce olsun ispanyolca olsun arapça olsun ve japonca olsun bu dillerin yazıları yine ing olsun
User prompt
oyun değiştiya nasıl oynanır kısmını da değiştir
User prompt
bence birbirine değen ne kadar top varsa hepsi patlasın (min 3 olması lazım yine) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
butona tıklandığında şekerler gitmiyor
User prompt
butonu ekranın aynı hizada sağ tarafına alsak
User prompt
bir buton eklesek tekrar ana menüye dönmek içi üç çizgili bir şekilde şeker temalı aynı ana menüdeki gibi ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yine aynısı oldu
User prompt
oyuna girdiğimde nasıl oynanır butonunun olduğu konuma tıkladığımda iç içe giriyor
User prompt
ana menü ile şekerler iç içe girdi buglandı sorunu düzelt
User prompt
Please fix the bug: 'self.insertChildAt is not a function' in or related to this line: 'self.insertChildAt(titleShadow, self.getChildIndex(titleText));' Line Number: 288
User prompt
ana menüyü biraz daha havalı yap ve geliştir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
ana menü yap başlatma butonu oyunun adı animasyonlu bir şekilde çıksın ve başlatma butonunun yanına birde nasıl oynanır butonu ekle ve nasıl oynandığını yaz ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
ana menü yap başlatma butonu oyunun adı animasyonlu bir şekilde çıksın ve başlatma butonunun yanına birde nasıl oynanır butonu ekle ve nasıl oynandığını yaz ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
ingilizce yap tüm yazıları ve ana menü yap seviyeyi kaldır hamleyi kaldır sonsuz olsun oyun
User prompt
- **Taş Efekti**: Güçlü kombinasyonlarda ekranın sallanması ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
- **Skor Animasyonu**: Puan artışı sırasında sayıların yükselmesi ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
- **Combo Yazıları**: "Great!", "Awesome!", "Fantastic!" gibi yazılar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
- **Partikül Efektleri**: Şekerler patlarken renkli partikül saçılması ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
images daki backgroundu arka plan yap
User prompt
arka plandaki o morluğu değiştirsek nasıl olur onun yerine candy crush oyunundaki arka plan olsun
User prompt
neyse sonuncu yaptığımızı kaldır
User prompt
belli bir hamle olsun o hamleye kadar patlatamazsak bitsin
User prompt
bomba ile ilgili herşeyi sil
User prompt
bomba ekle aynı candy crushtaki gibi ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Candy = Container.expand(function (type) {
var self = Container.call(this);
self.candyType = type || 1;
self.gridX = 0;
self.gridY = 0;
self.isAnimating = false;
self.isMatched = false;
var candyGraphics = self.attachAsset('candy' + self.candyType, {
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 + CELL_SIZE / 2;
self.y = GRID_START_Y + gridY * CELL_SIZE + CELL_SIZE / 2;
};
self.animateToPosition = function (targetX, targetY, callback) {
self.isAnimating = true;
tween(self, {
x: targetX,
y: targetY
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isAnimating = false;
if (callback) callback();
}
});
};
self.animateFall = function (newGridY, callback) {
var targetY = GRID_START_Y + newGridY * CELL_SIZE + CELL_SIZE / 2;
self.gridY = newGridY;
self.animateToPosition(self.x, targetY, callback);
};
self.markForRemoval = function () {
self.isMatched = true;
tween(self, {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 200,
easing: tween.easeIn
});
};
return self;
});
var ComboText = Container.expand(function (message, x, y, color) {
var self = Container.call(this);
self.x = x;
self.y = y;
var comboTextDisplay = new Text2(message, {
size: 120,
fill: color || 0xFFFFFF
});
comboTextDisplay.anchor.set(0.5, 0.5);
self.addChild(comboTextDisplay);
// Initial state
self.alpha = 0;
self.scaleX = 0.5;
self.scaleY = 0.5;
// Animate in
tween(self, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
// Hold for a moment
LK.setTimeout(function () {
// Animate out
tween(self, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5,
y: self.y - 100
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
self.destroy();
var index = comboTexts.indexOf(self);
if (index > -1) {
comboTexts.splice(index, 1);
}
}
});
}, 800);
}
});
return self;
});
var FloatingParticle = Container.expand(function (color, size) {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
particleGraphics.tint = color;
particleGraphics.scaleX = size;
particleGraphics.scaleY = size;
self.speed = Math.random() * 2 + 1;
self.direction = Math.random() * Math.PI * 2;
self.bobOffset = Math.random() * Math.PI * 2;
self.bobSpeed = Math.random() * 0.02 + 0.01;
self.update = function () {
self.x += Math.cos(self.direction) * self.speed;
self.y += Math.sin(self.direction) * self.speed + Math.sin(LK.ticks * self.bobSpeed + self.bobOffset) * 0.5;
// Wrap around screen
if (self.x < -50) self.x = 2098;
if (self.x > 2098) self.x = -50;
if (self.y < -50) self.y = 2782;
if (self.y > 2782) self.y = -50;
// Gentle rotation
self.rotation += 0.01;
};
return self;
});
var HowToPlayScreen = Container.expand(function () {
var self = Container.call(this);
// Background
var background = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
background.x = 2048 / 2;
background.y = 2732 / 2;
background.scaleX = 12;
background.scaleY = 16;
background.alpha = 0.9;
background.tint = 0x000000;
self.addChild(background);
// Title
var titleText = new Text2('HOW TO PLAY', {
size: 120,
fill: 0xFF69B4
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 400;
self.addChild(titleText);
// Instructions
var instructions = ['1. Swap adjacent candies to create matches', '2. Match 3 or more candies of the same type', '3. Longer matches give more points', '4. Create combos for bonus points', '5. Game is endless - keep matching!'];
for (var i = 0; i < instructions.length; i++) {
var instructionText = new Text2(instructions[i], {
size: 80,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 2048 / 2;
instructionText.y = 700 + i * 150;
self.addChild(instructionText);
}
// Back button
var backButton = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 2048 / 2;
backButton.y = 2200;
backButton.scaleX = 1.5;
backButton.scaleY = 0.6;
backButton.tint = 0xEB4D4B;
self.addChild(backButton);
var backButtonText = new Text2('BACK', {
size: 80,
fill: 0xFFFFFF
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = backButton.x;
backButtonText.y = backButton.y;
self.addChild(backButtonText);
backButton.down = function (x, y, obj) {
// Button press animation
tween(backButton, {
scaleX: 1.3,
scaleY: 0.5
}, {
duration: 100,
onFinish: function onFinish() {
tween(backButton, {
scaleX: 1.5,
scaleY: 0.6
}, {
duration: 100
});
}
});
// Go back to main menu
if (typeof showMainMenu === 'function') {
showMainMenu();
}
};
return self;
});
var MainMenu = Container.expand(function () {
var self = Container.call(this);
// Create gradient background overlay
var gradientOverlay = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
gradientOverlay.x = 2048 / 2;
gradientOverlay.y = 2732 / 2;
gradientOverlay.scaleX = 12;
gradientOverlay.scaleY = 16;
gradientOverlay.alpha = 0.1;
gradientOverlay.tint = 0x000000;
self.addChild(gradientOverlay);
// Add menu decorations
var decorations = new MenuDecoration();
self.addChild(decorations);
// Create floating background particles
var particles = [];
for (var i = 0; i < 20; i++) {
var colors = [0xFF69B4, 0x4ECDC4, 0xF9CA24, 0xEB4D4B, 0x45B7D1, 0xF0932B];
var color = colors[Math.floor(Math.random() * colors.length)];
var size = Math.random() * 0.8 + 0.3;
var particle = new FloatingParticle(color, size);
particle.x = Math.random() * 2048;
particle.y = Math.random() * 2732;
particle.alpha = 0.6;
particles.push(particle);
self.addChild(particle);
}
// Game title with enhanced styling
var titleText = new Text2('🍭 CANDY MATCH 🍭', {
size: 200,
fill: 0xFF69B4
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 500;
self.addChild(titleText);
// Add title shadow effect
var titleShadow = new Text2('🍭 CANDY MATCH 🍭', {
size: 200,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 5;
titleShadow.y = 505;
titleShadow.alpha = 0.3;
self.addChildAt(titleShadow, self.getChildIndex(titleText));
// Subtitle
var subtitleText = new Text2('✨ Match candies and create sweet combos! ✨', {
size: 60,
fill: 0xFFFFFF
});
subtitleText.anchor.set(0.5, 0.5);
subtitleText.x = 2048 / 2;
subtitleText.y = 650;
subtitleText.alpha = 0.8;
self.addChild(subtitleText);
// Enhanced start button with glow effect
var startButtonGlow = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
startButtonGlow.x = 2048 / 2;
startButtonGlow.y = 1200;
startButtonGlow.scaleX = 2.2;
startButtonGlow.scaleY = 0.9;
startButtonGlow.tint = 0x4ECDC4;
startButtonGlow.alpha = 0.3;
self.addChild(startButtonGlow);
var startButton = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
startButton.x = 2048 / 2;
startButton.y = 1200;
startButton.scaleX = 2;
startButton.scaleY = 0.8;
startButton.tint = 0x4ECDC4;
self.addChild(startButton);
var startButtonText = new Text2('🚀 START GAME', {
size: 90,
fill: 0xFFFFFF
});
startButtonText.anchor.set(0.5, 0.5);
startButtonText.x = startButton.x;
startButtonText.y = startButton.y;
self.addChild(startButtonText);
// Enhanced how to play button with glow effect
var howToPlayButtonGlow = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
howToPlayButtonGlow.x = 2048 / 2;
howToPlayButtonGlow.y = 1500;
howToPlayButtonGlow.scaleX = 2.2;
howToPlayButtonGlow.scaleY = 0.9;
howToPlayButtonGlow.tint = 0xF9CA24;
howToPlayButtonGlow.alpha = 0.3;
self.addChild(howToPlayButtonGlow);
var howToPlayButton = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
howToPlayButton.x = 2048 / 2;
howToPlayButton.y = 1500;
howToPlayButton.scaleX = 2;
howToPlayButton.scaleY = 0.8;
howToPlayButton.tint = 0xF9CA24;
self.addChild(howToPlayButton);
var howToPlayButtonText = new Text2('❓ HOW TO PLAY', {
size: 90,
fill: 0xFFFFFF
});
howToPlayButtonText.anchor.set(0.5, 0.5);
howToPlayButtonText.x = howToPlayButton.x;
howToPlayButtonText.y = howToPlayButton.y;
self.addChild(howToPlayButtonText);
// Animate title with rainbow effect
self.animateTitle = function () {
// Scale animation
tween(titleText, {
scaleX: 1.15,
scaleY: 1.15
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(titleText, {
scaleX: 1,
scaleY: 1
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.animateTitle();
}
});
}
});
// Color cycle animation
var colors = [0xFF69B4, 0x4ECDC4, 0xF9CA24, 0xEB4D4B, 0x45B7D1];
var currentColorIndex = 0;
function cycleColors() {
currentColorIndex = (currentColorIndex + 1) % colors.length;
tween(titleText, {
tint: colors[currentColorIndex]
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
LK.setTimeout(cycleColors, 500);
}
});
}
cycleColors();
};
// Animate subtitle
function animateSubtitle() {
tween(subtitleText, {
alpha: 1,
y: subtitleText.y - 10
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(subtitleText, {
alpha: 0.6,
y: 650
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: animateSubtitle
});
}
});
}
animateSubtitle();
// Animate button glows
function animateGlows() {
tween(startButtonGlow, {
alpha: 0.6,
scaleX: 2.4,
scaleY: 1.0
}, {
duration: 1200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(startButtonGlow, {
alpha: 0.3,
scaleX: 2.2,
scaleY: 0.9
}, {
duration: 1200,
easing: tween.easeInOut
});
}
});
tween(howToPlayButtonGlow, {
alpha: 0.6,
scaleX: 2.4,
scaleY: 1.0
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(howToPlayButtonGlow, {
alpha: 0.3,
scaleX: 2.2,
scaleY: 0.9
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: animateGlows
});
}
});
}
animateGlows();
// Update particles
self.update = function () {
for (var i = 0; i < particles.length; i++) {
particles[i].update();
}
};
// Enhanced button click handlers
startButton.down = function (x, y, obj) {
// Button press animation with enhanced effects
tween(startButton, {
scaleX: 1.7,
scaleY: 0.6
}, {
duration: 80,
onFinish: function onFinish() {
tween(startButton, {
scaleX: 2.1,
scaleY: 0.9
}, {
duration: 80,
onFinish: function onFinish() {
tween(startButton, {
scaleX: 2,
scaleY: 0.8
}, {
duration: 80
});
}
});
}
});
// Animate button glow on press
tween(startButtonGlow, {
alpha: 0.8,
scaleX: 2.6,
scaleY: 1.2
}, {
duration: 150,
onFinish: function onFinish() {
tween(startButtonGlow, {
alpha: 0.3,
scaleX: 2.2,
scaleY: 0.9
}, {
duration: 200
});
}
});
// Start the game
if (typeof startGame === 'function') {
startGame();
}
};
howToPlayButton.down = function (x, y, obj) {
// Button press animation with enhanced effects
tween(howToPlayButton, {
scaleX: 1.7,
scaleY: 0.6
}, {
duration: 80,
onFinish: function onFinish() {
tween(howToPlayButton, {
scaleX: 2.1,
scaleY: 0.9
}, {
duration: 80,
onFinish: function onFinish() {
tween(howToPlayButton, {
scaleX: 2,
scaleY: 0.8
}, {
duration: 80
});
}
});
}
});
// Animate button glow on press
tween(howToPlayButtonGlow, {
alpha: 0.8,
scaleX: 2.6,
scaleY: 1.2
}, {
duration: 150,
onFinish: function onFinish() {
tween(howToPlayButtonGlow, {
alpha: 0.3,
scaleX: 2.2,
scaleY: 0.9
}, {
duration: 200
});
}
});
// Show how to play
if (typeof showHowToPlay === 'function') {
showHowToPlay();
}
};
return self;
});
var MenuDecoration = Container.expand(function () {
var self = Container.call(this);
// Create candy decorations around the screen
var decorationCount = 12;
var _loop = function _loop() {
candyType = Math.floor(Math.random() * 6) + 1;
decoration = LK.getAsset('candy' + candyType, {
anchorX: 0.5,
anchorY: 0.5
});
angle = i / decorationCount * Math.PI * 2;
radius = 800 + Math.random() * 200;
decoration.x = 2048 / 2 + Math.cos(angle) * radius;
decoration.y = 2732 / 2 + Math.sin(angle) * radius;
decoration.alpha = 0.3;
decoration.scaleX = 0.8 + Math.random() * 0.4;
decoration.scaleY = decoration.scaleX;
self.addChild(decoration);
// Animate decorations
animDuration = 3000 + Math.random() * 2000;
targetScale = decoration.scaleX + 0.2;
function animateDecoration(dec) {
tween(dec, {
rotation: dec.rotation + Math.PI * 2,
scaleX: targetScale,
scaleY: targetScale
}, {
duration: animDuration,
easing: tween.easeInOut,
onFinish: function onFinish() {
targetScale = 0.8 + Math.random() * 0.4;
animDuration = 3000 + Math.random() * 2000;
animateDecoration(dec);
}
});
}
animateDecoration(decoration);
},
candyType,
decoration,
angle,
radius,
animDuration,
targetScale;
for (var i = 0; i < decorationCount; i++) {
_loop();
}
return self;
});
var Particle = Container.expand(function (color, startX, startY) {
var self = Container.call(this);
self.x = startX;
self.y = startY;
self.velocityX = (Math.random() - 0.5) * 400;
self.velocityY = (Math.random() - 0.5) * 400;
self.gravity = 300;
self.life = 1.0;
self.maxLife = 1.0;
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
particleGraphics.tint = color;
particleGraphics.scaleX = Math.random() * 0.8 + 0.4;
particleGraphics.scaleY = particleGraphics.scaleX;
self.update = function () {
self.x += self.velocityX * (1 / 60);
self.y += self.velocityY * (1 / 60);
self.velocityY += self.gravity * (1 / 60);
self.life -= 1 / 60 * 2;
var alpha = self.life / self.maxLife;
self.alpha = alpha;
self.scaleX = alpha * particleGraphics.scaleX;
self.scaleY = alpha * particleGraphics.scaleY;
if (self.life <= 0) {
self.destroy();
var index = particles.indexOf(self);
if (index > -1) {
particles.splice(index, 1);
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xff69b4
});
/****
* 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 gameGrid = [];
var candyTypes = [1, 2, 3, 4, 5, 6];
var selectedCandy = null;
var isProcessing = false;
var movesLeft = 999999;
var score = 0;
var animatingCandies = 0;
var particles = [];
var comboTexts = [];
var currentCombo = 0;
// Game state variables
var gameState = 'menu'; // 'menu', 'game', 'howtoplay'
var mainMenu = null;
var howToPlayScreen = null;
var gameElements = [];
// Initialize grid array
for (var x = 0; x < GRID_SIZE; x++) {
gameGrid[x] = [];
for (var y = 0; y < GRID_SIZE; y++) {
gameGrid[x][y] = null;
}
}
// Menu control functions
function showMainMenu() {
gameState = 'menu';
hideAllScreens();
if (!mainMenu) {
mainMenu = new MainMenu();
game.addChild(mainMenu);
} else {
mainMenu.alpha = 1;
}
mainMenu.animateTitle();
}
function showHowToPlay() {
gameState = 'howtoplay';
hideAllScreens();
if (!howToPlayScreen) {
howToPlayScreen = new HowToPlayScreen();
game.addChild(howToPlayScreen);
} else {
howToPlayScreen.alpha = 1;
}
}
function startGame() {
gameState = 'game';
hideAllScreens();
initializeGameElements();
}
function hideAllScreens() {
if (mainMenu) {
mainMenu.alpha = 0;
}
if (howToPlayScreen) {
howToPlayScreen.alpha = 0;
}
// Hide game elements
for (var i = 0; i < gameElements.length; i++) {
gameElements[i].alpha = 0;
}
}
function initializeGameElements() {
// Clear existing game elements first
for (var i = gameElements.length - 1; i >= 0; i--) {
if (gameElements[i] !== scoreText && gameElements[i] !== backgroundImage) {
gameElements[i].destroy();
gameElements.splice(i, 1);
}
}
// Show persistent game elements
for (var i = 0; i < gameElements.length; i++) {
gameElements[i].alpha = 1;
}
// Draw grid background
for (var x = 0; x < GRID_SIZE; x++) {
for (var y = 0; y < GRID_SIZE; y++) {
var cell = LK.getAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5
});
cell.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2;
cell.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2;
cell.alpha = 0.4;
cell.tint = 0xffffff;
game.addChild(cell);
gameElements.push(cell);
}
}
// Create coffee cup below the grid
var coffee = LK.getAsset('coffee', {
anchorX: 0.5,
anchorY: 0.5
});
coffee.x = 2048 / 2;
coffee.y = GRID_START_Y + GRID_SIZE * CELL_SIZE + 150;
game.addChild(coffee);
gameElements.push(coffee);
// Coffee click handler
coffee.down = function (x, y, obj) {
// Play coffee sound
LK.getSound('coffee').play();
// Shake animation
tween(coffee, {
x: coffee.x + 10
}, {
duration: 50,
onFinish: function onFinish() {
tween(coffee, {
x: coffee.x - 20
}, {
duration: 50,
onFinish: function onFinish() {
tween(coffee, {
x: coffee.x + 10
}, {
duration: 50
});
}
});
}
});
};
// Reset game state
score = 0;
currentCombo = 0;
selectedCandy = null;
isProcessing = false;
scoreText.setText('Score: 0');
// Clear existing candies and initialize fresh grid
for (var x = 0; x < GRID_SIZE; x++) {
for (var y = 0; y < GRID_SIZE; y++) {
if (gameGrid[x][y]) {
gameGrid[x][y].destroy();
gameGrid[x][y] = null;
}
}
}
// Initialize the game grid
initializeGrid();
}
// UI Elements
var scoreText = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
gameElements.push(scoreText);
// Create background image
var backgroundImage = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
backgroundImage.x = 2048 / 2;
backgroundImage.y = 2732 / 2;
backgroundImage.scaleX = 2048 / backgroundImage.width;
backgroundImage.scaleY = 2732 / backgroundImage.height;
game.addChild(backgroundImage);
gameElements.push(backgroundImage);
// Grid cells will be created when game starts
function getRandomCandyType() {
return candyTypes[Math.floor(Math.random() * candyTypes.length)];
}
function createCandy(x, y, type) {
if (!type) type = getRandomCandyType();
var candy = new Candy(type);
candy.setGridPosition(x, y);
gameGrid[x][y] = candy;
game.addChild(candy);
return candy;
}
function initializeGrid() {
for (var x = 0; x < GRID_SIZE; x++) {
for (var y = 0; y < GRID_SIZE; y++) {
var type;
var attempts = 0;
do {
type = getRandomCandyType();
attempts++;
} while (attempts < 10 && wouldCreateMatch(x, y, type));
createCandy(x, y, type);
}
}
}
function wouldCreateMatch(x, y, type) {
var horizontalCount = 1;
var verticalCount = 1;
// Check horizontal
for (var i = x - 1; i >= 0 && gameGrid[i][y] && gameGrid[i][y].candyType === type; i--) {
horizontalCount++;
}
for (var i = x + 1; i < GRID_SIZE && gameGrid[i][y] && gameGrid[i][y].candyType === type; i++) {
horizontalCount++;
}
// Check vertical
for (var i = y - 1; i >= 0 && gameGrid[x][i] && gameGrid[x][i].candyType === type; i--) {
verticalCount++;
}
for (var i = y + 1; i < GRID_SIZE && gameGrid[x][i] && gameGrid[x][i].candyType === type; i++) {
verticalCount++;
}
return horizontalCount >= 3 || verticalCount >= 3;
}
function getCandyAt(worldX, worldY) {
var gridX = Math.floor((worldX - GRID_START_X) / CELL_SIZE);
var gridY = Math.floor((worldY - GRID_START_Y) / CELL_SIZE);
if (gridX >= 0 && gridX < GRID_SIZE && gridY >= 0 && gridY < GRID_SIZE) {
return gameGrid[gridX][gridY];
}
return null;
}
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) {
var tempX = candy1.gridX;
var tempY = candy1.gridY;
var tempPosX = candy1.x;
var tempPosY = candy1.y;
gameGrid[candy1.gridX][candy1.gridY] = candy2;
gameGrid[candy2.gridX][candy2.gridY] = candy1;
candy1.gridX = candy2.gridX;
candy1.gridY = candy2.gridY;
candy2.gridX = tempX;
candy2.gridY = tempY;
animatingCandies += 2;
// Play boing sound when candies are swapped
LK.getSound('boing').play();
candy1.animateToPosition(candy2.x, candy2.y, function () {
animatingCandies--;
});
candy2.animateToPosition(tempPosX, tempPosY, function () {
animatingCandies--;
});
}
function findMatches() {
var matches = [];
var marked = [];
for (var x = 0; x < GRID_SIZE; x++) {
marked[x] = [];
for (var y = 0; y < GRID_SIZE; y++) {
marked[x][y] = false;
}
}
// Check horizontal matches
for (var y = 0; y < GRID_SIZE; y++) {
var count = 1;
var currentType = gameGrid[0][y] ? gameGrid[0][y].candyType : null;
for (var x = 1; x < GRID_SIZE; x++) {
var candy = gameGrid[x][y];
if (candy && candy.candyType === currentType) {
count++;
} else {
if (count >= 3) {
for (var i = x - count; i < x; i++) {
if (!marked[i][y]) {
matches.push(gameGrid[i][y]);
marked[i][y] = true;
}
}
}
count = 1;
currentType = candy ? candy.candyType : null;
}
}
if (count >= 3) {
for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) {
if (!marked[i][y]) {
matches.push(gameGrid[i][y]);
marked[i][y] = true;
}
}
}
}
// Check vertical matches
for (var x = 0; x < GRID_SIZE; x++) {
var count = 1;
var currentType = gameGrid[x][0] ? gameGrid[x][0].candyType : null;
for (var y = 1; y < GRID_SIZE; y++) {
var candy = gameGrid[x][y];
if (candy && candy.candyType === currentType) {
count++;
} else {
if (count >= 3) {
for (var i = y - count; i < y; i++) {
if (!marked[x][i]) {
matches.push(gameGrid[x][i]);
marked[x][i] = true;
}
}
}
count = 1;
currentType = candy ? candy.candyType : null;
}
}
if (count >= 3) {
for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) {
if (!marked[x][i]) {
matches.push(gameGrid[x][i]);
marked[x][i] = true;
}
}
}
}
return matches;
}
function removeMatches(matches) {
if (matches.length === 0) return;
LK.getSound('match').play();
for (var i = 0; i < matches.length; i++) {
var candy = matches[i];
// Create particle explosion for each candy
var candyColors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0xf9ca24, 0xf0932b, 0xeb4d4b];
var particleColor = candyColors[candy.candyType - 1] || 0xffffff;
// Create 8-12 particles per candy
var particleCount = Math.floor(Math.random() * 5) + 8;
for (var p = 0; p < particleCount; p++) {
var particle = new Particle(particleColor, candy.x, candy.y);
particles.push(particle);
game.addChild(particle);
}
candy.markForRemoval();
gameGrid[candy.gridX][candy.gridY] = null;
// Update score with animation
var oldScore = score;
score += 100;
if (matches.length > 3) {
score += (matches.length - 3) * 50;
}
// Animate score increase
var scoreIncrease = score - oldScore;
var tempScore = oldScore;
tween({
score: tempScore
}, {
score: score
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
scoreText.setText('Score: ' + score);
}
});
// Update score display during animation
var scoreAnimationTimer = LK.setInterval(function () {
tempScore += scoreIncrease / 30; // 30 steps over 500ms
if (tempScore >= score) {
tempScore = score;
LK.clearInterval(scoreAnimationTimer);
}
scoreText.setText('Score: ' + Math.floor(tempScore));
}, 16); // ~60fps
// Increment combo counter
currentCombo++;
// Show combo text based on match size and combo count
var comboMessage = "";
var comboColor = 0xFFFFFF;
if (matches.length >= 5) {
comboMessage = "Fantastic!";
comboColor = 0xFF6B6B;
// Screen shake for 5+ matches
var shakeIntensity = 15;
var originalX = game.x;
var originalY = game.y;
tween(game, {
x: originalX + shakeIntensity,
y: originalY + shakeIntensity * 0.5
}, {
duration: 50,
onFinish: function onFinish() {
tween(game, {
x: originalX - shakeIntensity,
y: originalY - shakeIntensity * 0.5
}, {
duration: 50,
onFinish: function onFinish() {
tween(game, {
x: originalX + shakeIntensity * 0.5,
y: originalY + shakeIntensity
}, {
duration: 50,
onFinish: function onFinish() {
tween(game, {
x: originalX,
y: originalY
}, {
duration: 50
});
}
});
}
});
}
});
} else if (matches.length >= 4) {
comboMessage = "Awesome!";
comboColor = 0x4ECDC4;
// Screen shake for 4+ matches
var shakeIntensity = 10;
var originalX = game.x;
var originalY = game.y;
tween(game, {
x: originalX + shakeIntensity,
y: originalY
}, {
duration: 75,
onFinish: function onFinish() {
tween(game, {
x: originalX - shakeIntensity,
y: originalY
}, {
duration: 75,
onFinish: function onFinish() {
tween(game, {
x: originalX,
y: originalY
}, {
duration: 75
});
}
});
}
});
} else if (currentCombo >= 3) {
comboMessage = "Great Combo!";
comboColor = 0xF9CA24;
// Light screen shake for combo
var shakeIntensity = 5;
var originalX = game.x;
var originalY = game.y;
tween(game, {
x: originalX + shakeIntensity
}, {
duration: 100,
onFinish: function onFinish() {
tween(game, {
x: originalX - shakeIntensity
}, {
duration: 100,
onFinish: function onFinish() {
tween(game, {
x: originalX
}, {
duration: 100
});
}
});
}
});
} else if (currentCombo >= 2) {
comboMessage = "Great!";
comboColor = 0x45B7D1;
}
if (comboMessage !== "") {
var comboX = 2048 / 2;
var comboY = GRID_START_Y + GRID_SIZE * CELL_SIZE / 2;
var comboText = new ComboText(comboMessage, comboX, comboY, comboColor);
comboTexts.push(comboText);
game.addChild(comboText);
}
}
// Remove candies after animation
LK.setTimeout(function () {
for (var i = 0; i < matches.length; i++) {
matches[i].destroy();
}
applyGravity();
}, 250);
}
function applyGravity() {
var needsGravity = false;
// Apply gravity physics - make candies fall to fill empty spaces
for (var x = 0; x < GRID_SIZE; x++) {
// Collect all candies in this column that are not null
var candiesInColumn = [];
for (var y = 0; y < GRID_SIZE; y++) {
if (gameGrid[x][y] !== null) {
candiesInColumn.push({
candy: gameGrid[x][y],
originalY: y
});
}
gameGrid[x][y] = null; // Clear the column
}
// Place candies back starting from bottom
var newY = GRID_SIZE - 1;
for (var i = candiesInColumn.length - 1; i >= 0; i--) {
var candyData = candiesInColumn[i];
var candy = candyData.candy;
var originalY = candyData.originalY;
gameGrid[x][newY] = candy;
// Immediately update grid position to prevent overlaps
candy.gridX = x;
candy.gridY = newY;
// Check if candy needs to fall
if (newY !== originalY) {
var targetY = GRID_START_Y + newY * CELL_SIZE + CELL_SIZE / 2;
candy.isAnimating = true;
animatingCandies++;
tween(candy, {
y: targetY
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
candy.isAnimating = false;
animatingCandies--;
}
});
needsGravity = true;
} else {
// Ensure position is correct even if not animating
candy.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2;
candy.y = GRID_START_Y + newY * CELL_SIZE + CELL_SIZE / 2;
}
newY--;
}
// Fill remaining empty spaces at top with new candies
for (var y = 0; y < GRID_SIZE; y++) {
if (gameGrid[x][y] === null) {
var newCandy = createCandy(x, y, getRandomCandyType());
newCandy.y = GRID_START_Y - CELL_SIZE + CELL_SIZE / 2;
newCandy.isAnimating = true;
animatingCandies++;
var targetY = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2;
tween(newCandy, {
y: targetY
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
newCandy.isAnimating = false;
animatingCandies--;
}
});
needsGravity = true;
}
}
}
if (needsGravity) {
LK.getSound('cascade').play();
LK.setTimeout(function () {
checkForNewMatches();
}, 400);
}
}
function checkForNewMatches() {
if (animatingCandies > 0) {
LK.setTimeout(checkForNewMatches, 100);
return;
}
var matches = findMatches();
if (matches.length > 0) {
removeMatches(matches);
} else {
isProcessing = false;
currentCombo = 0; // Reset combo counter when no more matches
}
}
function checkGameState() {
// Endless game - no win/lose conditions
}
function processMove(candy1, candy2) {
if (isProcessing || !candy1 || !candy2 || candy1 === candy2) return false;
if (!areAdjacent(candy1, candy2)) return false;
isProcessing = true;
// Endless game - no move limit
// Temporarily swap to check for matches
var tempX1 = candy1.gridX,
tempY1 = candy1.gridY;
var tempX2 = candy2.gridX,
tempY2 = candy2.gridY;
gameGrid[tempX1][tempY1] = candy2;
gameGrid[tempX2][tempY2] = candy1;
candy1.gridX = tempX2;
candy1.gridY = tempY2;
candy2.gridX = tempX1;
candy2.gridY = tempY1;
var matches = findMatches();
if (matches.length > 0) {
// Valid move - perform the swap animation
swapCandies(candy2, candy1); // Swap back positions for animation
LK.setTimeout(function () {
removeMatches(matches);
}, 350);
} else {
// Invalid move - revert
gameGrid[tempX1][tempY1] = candy1;
gameGrid[tempX2][tempY2] = candy2;
candy1.gridX = tempX1;
candy1.gridY = tempY1;
candy2.gridX = tempX2;
candy2.gridY = tempY2;
// Animate back to original positions
swapCandies(candy1, candy2);
LK.setTimeout(function () {
isProcessing = false;
}, 350);
// Endless game - no move limit
}
return true;
}
game.down = function (x, y, obj) {
if (gameState !== 'game') return;
if (isProcessing) return;
var candy = getCandyAt(x, y);
if (!candy) return;
if (selectedCandy) {
if (selectedCandy === candy) {
// Deselect
tween(selectedCandy, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
selectedCandy = null;
} else {
// Try to make move
var success = processMove(selectedCandy, candy);
if (success) {
tween(selectedCandy, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
selectedCandy = null;
}
}
} else {
// Select candy
selectedCandy = candy;
tween(candy, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150
});
}
};
// Coffee cup will be created when game starts
// Start background music
LK.playMusic('rahat');
// Show main menu instead of initializing game immediately
showMainMenu();
game.update = function () {
// Update menu elements when in menu state
if (gameState === 'menu' && mainMenu) {
mainMenu.update();
}
// Update particles during game
for (var i = particles.length - 1; i >= 0; i--) {
particles[i].update();
}
// Combo texts are automatically managed by their own animations
// No manual update needed as they self-destruct
// Background is now static image - no animation needed
// Only run game physics during game state
if (gameState === 'game') {
// Continuously check for physics updates when not processing moves
if (!isProcessing && animatingCandies === 0) {
// Check if any candies need to fall due to physics
var needsPhysicsUpdate = false;
for (var x = 0; x < GRID_SIZE && !needsPhysicsUpdate; x++) {
// Check entire column from bottom to top for any candy that should fall
for (var y = GRID_SIZE - 1; y >= 0; y--) {
if (gameGrid[x][y] === null) {
// Found empty space, check if there's a candy above it
for (var checkY = y - 1; checkY >= 0; checkY--) {
if (gameGrid[x][checkY] !== null) {
needsPhysicsUpdate = true;
break;
}
}
if (needsPhysicsUpdate) break;
}
}
}
if (needsPhysicsUpdate) {
applyGravity();
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -687,12 +687,68 @@
gameElements[i].alpha = 0;
}
}
function initializeGameElements() {
- // Show all game elements
+ // Clear existing game elements first
+ for (var i = gameElements.length - 1; i >= 0; i--) {
+ if (gameElements[i] !== scoreText && gameElements[i] !== backgroundImage) {
+ gameElements[i].destroy();
+ gameElements.splice(i, 1);
+ }
+ }
+ // Show persistent game elements
for (var i = 0; i < gameElements.length; i++) {
gameElements[i].alpha = 1;
}
+ // Draw grid background
+ for (var x = 0; x < GRID_SIZE; x++) {
+ for (var y = 0; y < GRID_SIZE; y++) {
+ var cell = LK.getAsset('gridCell', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ cell.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2;
+ cell.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2;
+ cell.alpha = 0.4;
+ cell.tint = 0xffffff;
+ game.addChild(cell);
+ gameElements.push(cell);
+ }
+ }
+ // Create coffee cup below the grid
+ var coffee = LK.getAsset('coffee', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ coffee.x = 2048 / 2;
+ coffee.y = GRID_START_Y + GRID_SIZE * CELL_SIZE + 150;
+ game.addChild(coffee);
+ gameElements.push(coffee);
+ // Coffee click handler
+ coffee.down = function (x, y, obj) {
+ // Play coffee sound
+ LK.getSound('coffee').play();
+ // Shake animation
+ tween(coffee, {
+ x: coffee.x + 10
+ }, {
+ duration: 50,
+ onFinish: function onFinish() {
+ tween(coffee, {
+ x: coffee.x - 20
+ }, {
+ duration: 50,
+ onFinish: function onFinish() {
+ tween(coffee, {
+ x: coffee.x + 10
+ }, {
+ duration: 50
+ });
+ }
+ });
+ }
+ });
+ };
// Reset game state
score = 0;
currentCombo = 0;
selectedCandy = null;
@@ -728,23 +784,9 @@
backgroundImage.scaleX = 2048 / backgroundImage.width;
backgroundImage.scaleY = 2732 / backgroundImage.height;
game.addChild(backgroundImage);
gameElements.push(backgroundImage);
-// Draw grid background
-for (var x = 0; x < GRID_SIZE; x++) {
- for (var y = 0; y < GRID_SIZE; y++) {
- var cell = LK.getAsset('gridCell', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- cell.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2;
- cell.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2;
- cell.alpha = 0.4;
- cell.tint = 0xffffff;
- game.addChild(cell);
- gameElements.push(cell);
- }
-}
+// Grid cells will be created when game starts
function getRandomCandyType() {
return candyTypes[Math.floor(Math.random() * candyTypes.length)];
}
function createCandy(x, y, type) {
@@ -1226,42 +1268,9 @@
duration: 150
});
}
};
-// Create coffee cup below the grid
-var coffee = LK.getAsset('coffee', {
- anchorX: 0.5,
- anchorY: 0.5
-});
-coffee.x = 2048 / 2;
-coffee.y = GRID_START_Y + GRID_SIZE * CELL_SIZE + 150;
-game.addChild(coffee);
-gameElements.push(coffee);
-// Coffee click handler
-coffee.down = function (x, y, obj) {
- // Play coffee sound
- LK.getSound('coffee').play();
- // Shake animation
- tween(coffee, {
- x: coffee.x + 10
- }, {
- duration: 50,
- onFinish: function onFinish() {
- tween(coffee, {
- x: coffee.x - 20
- }, {
- duration: 50,
- onFinish: function onFinish() {
- tween(coffee, {
- x: coffee.x + 10
- }, {
- duration: 50
- });
- }
- });
- }
- });
-};
+// Coffee cup will be created when game starts
// Start background music
LK.playMusic('rahat');
// Show main menu instead of initializing game immediately
showMainMenu();
gerçekçi bir şeker. yuvarlak bir şeker ve kırmızı renk. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve pembe renk.. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve koyu mavi renk. aynı candy2 deki gibi In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve sarı renk. aynı candy2 deki gibi olsun. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve kahverengi renk. aynı candy2 deki gibi olsun. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve yeşil renk. aynı candy2 deki gibi olsun. In-Game asset. 2d. High contrast. No shadows
a coffee. In-Game asset. 2d. High contrast. No shadows
Bir satırda oyundaki tüm şekerler yan yana dizilsin. In-Game asset. 2d. High contrast. No shadows
Yuvarlak bir şeker ve üstünde ona ucu değen sağ üstte bir kalem. In-Game asset. 2d. High contrast. No shadows