User prompt
Süre 10 saniyeden az kaldıysa tüm yazı renklerini oyun bitene kadar kırmızıya çevir. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Memory Match yazısının üstüne de biraz boşluk ekleyelim.
User prompt
Seviye seçimi butonlarına yaptığımız animasyonların aynısını restart ve menu butonlarına da yapalım lütfen. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Restart ve menü butonu aralarında boşluk olsun. Ve iki buton aynı boyutta dursun. Yazısı biraz daha büyüsün.
User prompt
Şimdi restart butonu ve menu butonunu biraz daha büyültelim.
User prompt
Memory Match yazısının altına biraz boşluk koy. Diğer yazılar çok yapışık durmasın. Son değiştirdiğimiz yazıları 50px yapalım lütfen.
User prompt
Son yazıları 40px'e küçültelim lütfen.
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'fill')' in or related to this line: 'if (timerText.style.fill !== 0xFF0000) {' Line Number: 482
User prompt
Zaman sayacı kırmızı olmadı ve giderek büyümedi. Düzelt. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Zaman sayacı 10 saniye kaldığında zamanı gösteren yazı kırmızı olsun ve giderek büyüsün. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Zaman sayacı 10 saniye kaldığında yazı kırmızı olsun ve titreşmeye başlasın. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ana menüye dönme butonunun arka planı mavi olsun.
User prompt
Please fix the bug: 'Timeout.tick error: LK.showYouLost is not a function' in or related to this line: 'LK.showYouLost();' Line Number: 482
User prompt
"Do you have a problem with your memory?" yazısını "Are you OK?" olarak güncelle.
User prompt
Doğru eşleşme sağlanınca yanlış sayacı kaybolmuyor. Bunu düzelt. Doğru eşleşmede sıfırlanması lazım.
User prompt
Alzheimer counter yazısı bir daha gözükmesin. Ama arka planda saymaya devam etsin. "Do you have a problem with your memory?" yazısı counter 5 olana kadar dursun. Diğer yazı 10'a kadar dursun. Son yazı ise oyuncu doğru eşleşme yapana kadar durabilir.
User prompt
Yanlış sayacı devreye girdiyse yanlış sayısını göstermek yerine seviyeye bağlı yazılar yazsın. Örneğin alzheimer counter 1 olduğunde "alzheimer counter: 1" yerine "do you have a problem with your memory?" yazsın. Alzheimer counter 5 olduysa "I am getting worried about you" yazsın. 10'u geçtiyse de "You are an alzheimer" yazsın.
User prompt
Süre bitince "game over" yerine "you lost" yazsın.
User prompt
Şimdi oyuna süre ekleyelim. Kolay seviyede 1 dakika, orta seviyede 2 dakika, zor seviyede 3 dakika süre olsun. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Seviye seçme butonlarını biraz daha geniş yap.
User prompt
Yanlış sayacı zor seviyede 12. yanlış eşleşmeden itibaren saymaya başlasın.
User prompt
Yanlış sayacı tekrardan ortaya çıkmışsa 0'dan başlasın. Kaldığı yerden devam etmesin.
User prompt
"What A Luck" ve "Play The Lotto" yazısı 3. tahminden itibaren bir daha hiç çıkmasın. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
"Play The Loto" yazısını "Play The Lotto" olarak güncelle.
User prompt
Eğer herhangi bir seviyede oyuncu ilk iki hamlesinde de eşleşme sağlarsa bu sefer "What A Luck" yerine "Play The Loto" yazsın. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Card = Container.expand(function (cardType) {
var self = Container.call(this);
self.cardType = cardType;
self.isFlipped = false;
self.isMatched = false;
self.isAnimating = false;
var cardBackAsset = 'cardBack';
var cardFrontAsset = 'cardFront' + cardType;
self.backGraphics = self.attachAsset(cardBackAsset, {
anchorX: 0.5,
anchorY: 0.5
});
self.frontGraphics = self.attachAsset(cardFrontAsset, {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
});
self.flip = function (showFront) {
if (self.isAnimating) return;
self.isAnimating = true;
LK.getSound('cardFlip').play();
// First half of flip animation - scale to 0 on X axis
tween(self, {
scaleX: 0
}, {
duration: 150,
easing: tween.easeIn,
onFinish: function onFinish() {
// Switch visibility
if (showFront) {
self.backGraphics.alpha = 0;
self.frontGraphics.alpha = 1;
self.isFlipped = true;
} else {
self.backGraphics.alpha = 1;
self.frontGraphics.alpha = 0;
self.isFlipped = false;
}
// Second half of flip animation - scale back to 1
tween(self, {
scaleX: 1
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isAnimating = false;
}
});
}
});
};
self.setMatched = function () {
self.isMatched = true;
// Slightly fade matched cards
tween(self, {
alpha: 0.7
}, {
duration: 300
});
};
self.throwAway = function () {
if (self.isAnimating) return;
self.isAnimating = true;
// Random direction for throwing
var randomDirection = Math.random() > 0.5 ? 1 : -1;
var throwDistance = 500 + Math.random() * 300;
var targetX = self.x + randomDirection * throwDistance;
var targetY = self.y - 200 - Math.random() * 200;
// Throw animation with rotation and scaling
tween(self, {
x: targetX,
y: targetY,
rotation: randomDirection * (Math.PI + Math.random() * Math.PI),
scaleX: 0.3,
scaleY: 0.3,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
};
self.down = function (x, y, obj) {
if (!gameStarted) return;
if (self.isAnimating || self.isFlipped || self.isMatched) return;
if (flippedCards.length >= 2) return;
self.flip(true);
flippedCards.push(self);
if (flippedCards.length === 2) {
moves++;
movesText.setText('Moves: ' + moves);
LK.setTimeout(function () {
checkMatch();
}, 1000);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2d3436
});
/****
* Game Code
****/
var gridRows = 3;
var gridCols = 4;
var totalPairs = gridRows * gridCols / 2;
var cards = [];
var flippedCards = [];
var matchedPairs = 0;
var moves = 0;
var wrongMatches = 0;
var wrongMatchCount = 0; // Track consecutive wrong matches
var gameStarted = false;
var selectedLevel = null;
var isFirstAttempt = true; // Track if this is the first matching attempt
var consecutiveSuccessfulMatches = 0; // Track consecutive successful matches
var totalMoveAttempts = 0; // Track total move attempts to limit special text after 3rd attempt
var gameTimer = 0; // Game timer in seconds
var maxGameTime = 0; // Maximum time allowed for current level
var timerInterval = null; // Timer interval reference
// Create UI elements
var titleText = new Text2('Memory Match', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 100;
var movesText = new Text2('Moves: 0', {
size: 50,
fill: 0xFFFFFF
});
movesText.anchor.set(0.5, 0);
LK.gui.top.addChild(movesText);
movesText.y = 280;
var pairsText = new Text2('Pairs: 0/' + totalPairs, {
size: 50,
fill: 0xFFFFFF
});
pairsText.anchor.set(0.5, 0);
LK.gui.top.addChild(pairsText);
pairsText.y = 380;
var wrongMatchesText = new Text2('Alzheimer counter: 0', {
size: 50,
fill: 0xFF6B6B
});
wrongMatchesText.anchor.set(0.5, 0);
LK.gui.top.addChild(wrongMatchesText);
wrongMatchesText.y = 480;
var timerText = new Text2('Time: 0:00', {
size: 50,
fill: 0xFFFFFF
});
timerText.anchor.set(0.5, 0);
LK.gui.top.addChild(timerText);
timerText.y = 580;
// Create "What A Luck" text for first match success
var whatALuckText = new Text2('What A Luck!', {
size: 120,
fill: 0xFFD700
});
whatALuckText.anchor.set(0.5, 0.5);
whatALuckText.alpha = 0;
whatALuckText.scaleX = 0;
whatALuckText.scaleY = 0;
LK.gui.center.addChild(whatALuckText);
// Create "Play The Lotto" text for two consecutive successful matches
var playTheLotoText = new Text2('Play The Lotto!', {
size: 120,
fill: 0x00FF00
});
playTheLotoText.anchor.set(0.5, 0.5);
playTheLotoText.alpha = 0;
playTheLotoText.scaleX = 0;
playTheLotoText.scaleY = 0;
LK.gui.center.addChild(playTheLotoText);
// Hide game UI initially
movesText.alpha = 0;
pairsText.alpha = 0;
wrongMatchesText.alpha = 0;
timerText.alpha = 0; // Hidden initially
// Create pause/menu button
var menuButton = LK.getAsset('cardFront3', {
anchorX: 0.5,
anchorY: 0.5
});
menuButton.x = 2048 - 150;
menuButton.y = 150;
menuButton.scaleX = 0.8;
menuButton.scaleY = 0.35;
menuButton.alpha = 0; // Hidden initially
game.addChild(menuButton);
var menuButtonText = new Text2('MENU', {
size: 35,
fill: 0xFFFFFF
});
menuButtonText.anchor.set(0.5, 0.5);
menuButtonText.x = menuButton.x;
menuButtonText.y = menuButton.y;
menuButtonText.alpha = 0; // Hidden initially
game.addChild(menuButtonText);
// Menu button hover handlers
menuButton.move = function () {
if (!gameStarted) return;
};
menuButton.up = function () {
if (!gameStarted) return;
};
// Menu button click handler
menuButton.down = function () {
if (!gameStarted) return;
returnToLevelSelect();
};
// Create restart button
var restartButton = LK.getAsset('cardFront4', {
anchorX: 0.5,
anchorY: 0.5
});
restartButton.x = 2048 - 350;
restartButton.y = 150;
restartButton.scaleX = 0.8;
restartButton.scaleY = 0.35;
restartButton.alpha = 0; // Hidden initially
game.addChild(restartButton);
var restartButtonText = new Text2('RESTART', {
size: 35,
fill: 0xFFFFFF
});
restartButtonText.anchor.set(0.5, 0.5);
restartButtonText.x = restartButton.x;
restartButtonText.y = restartButton.y;
restartButtonText.alpha = 0; // Hidden initially
game.addChild(restartButtonText);
// Restart button hover handlers
restartButton.move = function () {
if (!gameStarted) return;
};
restartButton.up = function () {
if (!gameStarted) return;
};
// Restart button click handler
restartButton.down = function () {
if (!gameStarted) return;
restartCurrentGame();
};
// Create level selection screen
var levelSelectText = new Text2('Select Difficulty', {
size: 100,
fill: 0xFFFFFF
});
levelSelectText.anchor.set(0.5, 0.5);
levelSelectText.x = 2048 / 2;
levelSelectText.y = 1000;
game.addChild(levelSelectText);
// Create level buttons
var easyButton = LK.getAsset('cardFront2', {
anchorX: 0.5,
anchorY: 0.5
});
easyButton.scaleX = 2.0;
easyButton.scaleY = 0.8;
easyButton.x = 2048 / 2;
easyButton.y = 1300;
game.addChild(easyButton);
var easyButtonText = new Text2('EASY', {
size: 70,
fill: 0xFFFFFF,
fontWeight: 'bolder'
});
var easyCardText = new Text2('12 Cards', {
size: 40,
fill: 0xFFFFFF
});
easyButtonText.anchor.set(0.5, 0.5);
easyButtonText.x = easyButton.x;
easyButtonText.y = easyButton.y - 40;
game.addChild(easyButtonText);
easyCardText.anchor.set(0.5, 0.5);
easyCardText.x = easyButton.x;
easyCardText.y = easyButton.y + 45;
game.addChild(easyCardText);
var mediumButton = LK.getAsset('cardFront4', {
anchorX: 0.5,
anchorY: 0.5
});
mediumButton.scaleX = 2.0;
mediumButton.scaleY = 0.8;
mediumButton.x = 2048 / 2;
mediumButton.y = 1650;
game.addChild(mediumButton);
var mediumButtonText = new Text2('MEDIUM', {
size: 70,
fill: 0xFFFFFF,
fontWeight: 'bolder'
});
var mediumCardText = new Text2('20 Cards', {
size: 40,
fill: 0xFFFFFF
});
mediumButtonText.anchor.set(0.5, 0.5);
mediumButtonText.x = mediumButton.x;
mediumButtonText.y = mediumButton.y - 40;
game.addChild(mediumButtonText);
mediumCardText.anchor.set(0.5, 0.5);
mediumCardText.x = mediumButton.x;
mediumCardText.y = mediumButton.y + 45;
game.addChild(mediumCardText);
var hardButton = LK.getAsset('cardFront6', {
anchorX: 0.5,
anchorY: 0.5
});
hardButton.scaleX = 2.0;
hardButton.scaleY = 0.8;
hardButton.x = 2048 / 2;
hardButton.y = 2000;
game.addChild(hardButton);
var hardButtonText = new Text2('HARD', {
size: 70,
fill: 0xFFFFFF,
fontWeight: 'bolder'
});
var hardCardText = new Text2('28 Cards', {
size: 40,
fill: 0xFFFFFF
});
hardButtonText.anchor.set(0.5, 0.5);
hardButtonText.x = hardButton.x;
hardButtonText.y = hardButton.y - 40;
game.addChild(hardButtonText);
hardCardText.anchor.set(0.5, 0.5);
hardCardText.x = hardButton.x;
hardCardText.y = hardButton.y + 45;
game.addChild(hardCardText);
// Button hover handlers
var easyButtonHovered = false;
var mediumButtonHovered = false;
var hardButtonHovered = false;
easyButton.move = function () {
// Remove hover detection from individual button handler
};
easyButton.up = function () {
if (gameStarted) return;
};
// Button click handlers
easyButton.down = function () {
if (gameStarted) return;
startGame('easy');
};
mediumButton.move = function () {
// Remove hover detection from individual button handler
};
mediumButton.up = function () {
if (gameStarted) return;
};
mediumButton.down = function () {
if (gameStarted) return;
startGame('medium');
};
hardButton.move = function () {
// Remove hover detection from individual button handler
};
hardButton.up = function () {
if (gameStarted) return;
};
hardButton.down = function () {
if (gameStarted) return;
startGame('hard');
};
function startGame(level) {
gameStarted = true;
selectedLevel = level;
// Set grid dimensions based on level
if (level === 'easy') {
gridRows = 3;
gridCols = 4;
} else if (level === 'medium') {
gridRows = 4;
gridCols = 5;
} else if (level === 'hard') {
gridRows = 4;
gridCols = 7;
}
totalPairs = gridRows * gridCols / 2;
// Remove level selection UI from game scene
game.removeChild(levelSelectText);
game.removeChild(easyButton);
game.removeChild(easyButtonText);
game.removeChild(easyCardText);
game.removeChild(mediumButton);
game.removeChild(mediumButtonText);
game.removeChild(mediumCardText);
game.removeChild(hardButton);
game.removeChild(hardButtonText);
game.removeChild(hardCardText);
// Show game UI
movesText.alpha = 1;
pairsText.alpha = 1;
pairsText.setText('Pairs: 0/' + totalPairs);
wrongMatchesText.alpha = 0; // Hide initially, will show after 5th move
wrongMatchesText.setText('Alzheimer counter: 0');
timerText.alpha = 1;
updateTimerDisplay();
// Start game timer
timerInterval = LK.setInterval(function () {
gameTimer--;
updateTimerDisplay();
if (gameTimer <= 0) {
// Time's up - show you lost
LK.clearInterval(timerInterval);
LK.showGameOver();
}
}, 1000);
// Reset first attempt flag
isFirstAttempt = true;
consecutiveSuccessfulMatches = 0;
totalMoveAttempts = 0; // Reset total move attempts
// Set timer based on difficulty level
if (level === 'easy') {
maxGameTime = 60; // 1 minute
} else if (level === 'medium') {
maxGameTime = 120; // 2 minutes
} else if (level === 'hard') {
maxGameTime = 180; // 3 minutes
}
gameTimer = maxGameTime;
// Show menu and restart buttons
menuButton.alpha = 1;
menuButtonText.alpha = 1;
restartButton.alpha = 1;
restartButtonText.alpha = 1;
// Generate card types for pairs
var cardTypes = [];
for (var i = 1; i <= totalPairs; i++) {
cardTypes.push(i);
cardTypes.push(i); // Add each type twice for pairs
}
// Shuffle the card types
cardTypes = shuffleArray(cardTypes);
// Calculate grid positioning
var originalCardWidth = 220;
var originalCardHeight = 280;
var cardWidth = 220;
var cardHeight = 280;
var cardSpacing = 50;
var scaleX = 1;
var scaleY = 1;
// Adjust card size for different levels
if (level === 'hard') {
cardWidth = 180;
cardHeight = 230;
cardSpacing = 60;
scaleX = cardWidth / originalCardWidth;
scaleY = cardHeight / originalCardHeight;
} else if (level === 'medium') {
cardWidth = 200;
cardHeight = 255;
cardSpacing = 45;
scaleX = cardWidth / originalCardWidth;
scaleY = cardHeight / originalCardHeight;
}
var gridWidth = cardWidth * gridCols + cardSpacing * (gridCols - 1);
var gridHeight = cardHeight * gridRows + cardSpacing * (gridRows - 1);
var startX = (2048 - gridWidth) / 2 + cardWidth / 2;
var startY = (2732 - gridHeight) / 2 + cardHeight / 2 + 200; // Offset for UI
// Create and position cards
var cardIndex = 0;
for (var row = 0; row < gridRows; row++) {
for (var col = 0; col < gridCols; col++) {
var card = new Card(cardTypes[cardIndex]);
card.scaleX = scaleX;
card.scaleY = scaleY;
var cardX = startX + col * (cardWidth + cardSpacing);
var cardY = startY + row * (cardHeight + cardSpacing);
card.x = cardX;
card.y = cardY;
// Set initial state for entrance animation
card.alpha = 0;
card.scaleX = 0;
card.scaleY = 0;
cards.push(card);
game.addChild(card);
// Animate card entrance with staggered timing using IIFE to capture card reference
var animationDelay = cardIndex * 80; // 80ms delay between each card
(function (currentCard, targetScaleX, targetScaleY) {
LK.setTimeout(function () {
// Animate alpha to 1 and scale to target size
tween(currentCard, {
alpha: 1,
scaleX: targetScaleX,
scaleY: targetScaleY
}, {
duration: 400,
easing: tween.easeOut
});
}, animationDelay);
})(card, scaleX, scaleY);
cardIndex++;
}
}
}
// Shuffle function
function updateTimerDisplay() {
var minutes = Math.floor(gameTimer / 60);
var seconds = gameTimer % 60;
var secondsStr = seconds < 10 ? '0' + seconds : seconds.toString();
timerText.setText('Time: ' + minutes + ':' + secondsStr);
}
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
function returnToLevelSelect() {
// Reset game state
gameStarted = false;
selectedLevel = null;
moves = 0;
wrongMatches = 0;
wrongMatchCount = 0; // Reset consecutive wrong match counter
matchedPairs = 0;
flippedCards = [];
isFirstAttempt = true;
consecutiveSuccessfulMatches = 0;
totalMoveAttempts = 0; // Reset total move attempts
// Clear timer
if (timerInterval) {
LK.clearInterval(timerInterval);
timerInterval = null;
}
gameTimer = 0;
// Clear all cards
for (var i = cards.length - 1; i >= 0; i--) {
cards[i].destroy();
}
cards = [];
// Hide game UI
movesText.alpha = 0;
pairsText.alpha = 0;
wrongMatchesText.alpha = 0;
timerText.alpha = 0;
menuButton.alpha = 0;
menuButtonText.alpha = 0;
restartButton.alpha = 0;
restartButtonText.alpha = 0;
// Re-add and show level selection UI
game.addChild(levelSelectText);
game.addChild(easyButton);
game.addChild(easyButtonText);
game.addChild(easyCardText);
game.addChild(mediumButton);
game.addChild(mediumButtonText);
game.addChild(mediumCardText);
game.addChild(hardButton);
game.addChild(hardButtonText);
game.addChild(hardCardText);
levelSelectText.alpha = 1;
easyButton.alpha = 1;
easyButtonText.alpha = 1;
easyCardText.alpha = 1;
mediumButton.alpha = 1;
mediumButtonText.alpha = 1;
mediumCardText.alpha = 1;
hardButton.alpha = 1;
hardButtonText.alpha = 1;
hardCardText.alpha = 1;
}
function restartCurrentGame() {
if (!selectedLevel) return;
// Clear current game
for (var i = cards.length - 1; i >= 0; i--) {
cards[i].destroy();
}
cards = [];
// Reset game variables
moves = 0;
wrongMatches = 0;
wrongMatchCount = 0; // Reset consecutive wrong match counter
matchedPairs = 0;
flippedCards = [];
isFirstAttempt = true;
consecutiveSuccessfulMatches = 0;
totalMoveAttempts = 0; // Reset total move attempts
// Clear existing timer
if (timerInterval) {
LK.clearInterval(timerInterval);
timerInterval = null;
}
gameTimer = 0;
movesText.setText('Moves: 0');
// Restart with same level
var levelToRestart = selectedLevel;
gameStarted = false; // Temporarily set to false for startGame function
startGame(levelToRestart);
}
function checkMatch() {
if (flippedCards.length !== 2) return;
var card1 = flippedCards[0];
var card2 = flippedCards[1];
totalMoveAttempts++; // Increment total move attempts
if (card1.cardType === card2.cardType) {
// Match found - reset consecutive wrong match counter and hide message
wrongMatchCount = 0;
wrongMatches = 0;
wrongMatchesText.alpha = 0;
consecutiveSuccessfulMatches++;
// Show special text based on consecutive successful matches (only for first 2 attempts)
if (consecutiveSuccessfulMatches === 2 && totalMoveAttempts <= 2) {
// Show "Play The Lotto" for two consecutive successful matches
// Dim all cards when Play The Loto appears
for (var i = 0; i < cards.length; i++) {
if (!cards[i].isMatched) {
tween(cards[i], {
alpha: 0.3
}, {
duration: 300,
easing: tween.easeOut
});
}
}
// Animate the "Play The Lotto" text
tween(playTheLotoText, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 600,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Hold for a moment then fade out
LK.setTimeout(function () {
tween(playTheLotoText, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
// Restore card alpha when Play The Lotto animation finishes
for (var i = 0; i < cards.length; i++) {
if (!cards[i].isMatched) {
tween(cards[i], {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut
});
}
}
}
});
}, 1000);
}
});
} else if (isFirstAttempt && totalMoveAttempts <= 2) {
// Show "What A Luck" if this is the first attempt
// Dim all cards when What A Luck appears
for (var i = 0; i < cards.length; i++) {
if (!cards[i].isMatched) {
tween(cards[i], {
alpha: 0.3
}, {
duration: 300,
easing: tween.easeOut
});
}
}
// Animate the "What A Luck" text
tween(whatALuckText, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 600,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Hold for a moment then fade out
LK.setTimeout(function () {
tween(whatALuckText, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
// Restore card alpha when What A Luck animation finishes
for (var i = 0; i < cards.length; i++) {
if (!cards[i].isMatched) {
tween(cards[i], {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut
});
}
}
}
});
}, 1000);
}
});
}
LK.getSound('match').play();
// Throw away matched cards with animation
LK.setTimeout(function () {
card1.throwAway();
card2.throwAway();
}, 300);
matchedPairs++;
pairsText.setText('Pairs: ' + matchedPairs + '/' + totalPairs);
// Check for win condition
if (matchedPairs === totalPairs) {
// Clear timer when game is won
if (timerInterval) {
LK.clearInterval(timerInterval);
timerInterval = null;
}
LK.setTimeout(function () {
LK.showYouWin();
}, 1500);
}
} else {
// No match - reset consecutive successful matches
consecutiveSuccessfulMatches = 0;
LK.getSound('noMatch').play();
// Increment consecutive wrong matches
wrongMatchCount++;
// Show counter based on consecutive wrong matches threshold per difficulty
var wrongThreshold = 3; // Default for easy
if (selectedLevel === 'medium') {
wrongThreshold = 5;
} else if (selectedLevel === 'hard') {
wrongThreshold = 12;
}
if (wrongMatchCount >= wrongThreshold) {
// Show counter if it's hidden and reset wrong matches to start from 0
if (wrongMatchesText.alpha === 0) {
wrongMatchesText.alpha = 1;
wrongMatches = 0; // Reset counter to 0 when it reappears
}
wrongMatches++;
// Set level-based message instead of counter number
var counterMessage;
if (wrongMatches >= 1 && wrongMatches < 5) {
counterMessage = 'Are you OK?';
} else if (wrongMatches >= 5 && wrongMatches <= 10) {
counterMessage = 'I am getting worried about you';
} else if (wrongMatches > 10) {
counterMessage = 'You are an alzheimer';
}
wrongMatchesText.setText(counterMessage);
}
card1.flip(false);
card2.flip(false);
}
flippedCards = [];
// After any match attempt (successful or not), it's no longer the first attempt
isFirstAttempt = false;
}
// Global move handler to detect cursor over buttons
game.move = function (x, y, obj) {
if (gameStarted) return;
// Check if cursor is over easy button
var isOverEasyButton = x >= easyButton.x - easyButton.width * easyButton.scaleX / 2 && x <= easyButton.x + easyButton.width * easyButton.scaleX / 2 && y >= easyButton.y - easyButton.height * easyButton.scaleY / 2 && y <= easyButton.y + easyButton.height * easyButton.scaleY / 2;
// Handle easy button hover enter
if (!easyButtonHovered && isOverEasyButton) {
easyButtonHovered = true;
// Animate opacity to 0.5 when hovering
tween(easyButton, {
alpha: 0.5
}, {
duration: 200,
easing: tween.easeOut
});
}
// Handle easy button hover leave
if (easyButtonHovered && !isOverEasyButton) {
easyButtonHovered = false;
// Animate opacity back to 1 when leaving hover
tween(easyButton, {
alpha: 1
}, {
duration: 200,
easing: tween.easeOut
});
}
// Check if cursor is over medium button
var isOverMediumButton = x >= mediumButton.x - mediumButton.width * mediumButton.scaleX / 2 && x <= mediumButton.x + mediumButton.width * mediumButton.scaleX / 2 && y >= mediumButton.y - mediumButton.height * mediumButton.scaleY / 2 && y <= mediumButton.y + mediumButton.height * mediumButton.scaleY / 2;
// Handle medium button hover enter
if (!mediumButtonHovered && isOverMediumButton) {
mediumButtonHovered = true;
// Animate opacity to 0.5 when hovering
tween(mediumButton, {
alpha: 0.5
}, {
duration: 200,
easing: tween.easeOut
});
}
// Handle medium button hover leave
if (mediumButtonHovered && !isOverMediumButton) {
mediumButtonHovered = false;
// Animate opacity back to 1 when leaving hover
tween(mediumButton, {
alpha: 1
}, {
duration: 200,
easing: tween.easeOut
});
}
// Check if cursor is over hard button
var isOverHardButton = x >= hardButton.x - hardButton.width * hardButton.scaleX / 2 && x <= hardButton.x + hardButton.width * hardButton.scaleX / 2 && y >= hardButton.y - hardButton.height * hardButton.scaleY / 2 && y <= hardButton.y + hardButton.height * hardButton.scaleY / 2;
// Handle hard button hover enter
if (!hardButtonHovered && isOverHardButton) {
hardButtonHovered = true;
// Animate opacity to 0.5 when hovering
tween(hardButton, {
alpha: 0.5
}, {
duration: 200,
easing: tween.easeOut
});
}
// Handle hard button hover leave
if (hardButtonHovered && !isOverHardButton) {
hardButtonHovered = false;
// Animate opacity back to 1 when leaving hover
tween(hardButton, {
alpha: 1
}, {
duration: 200,
easing: tween.easeOut
});
}
};
game.update = function () {
// Game logic is handled by card interactions and timeouts
}; ===================================================================
--- original.js
+++ change.js
@@ -206,9 +206,9 @@
menuButton.scaleY = 0.35;
menuButton.alpha = 0; // Hidden initially
game.addChild(menuButton);
var menuButtonText = new Text2('MENU', {
- size: 28,
+ size: 35,
fill: 0xFFFFFF
});
menuButtonText.anchor.set(0.5, 0.5);
menuButtonText.x = menuButton.x;
@@ -231,16 +231,16 @@
var restartButton = LK.getAsset('cardFront4', {
anchorX: 0.5,
anchorY: 0.5
});
-restartButton.x = 2048 - 300;
+restartButton.x = 2048 - 350;
restartButton.y = 150;
restartButton.scaleX = 0.8;
restartButton.scaleY = 0.35;
restartButton.alpha = 0; // Hidden initially
game.addChild(restartButton);
var restartButtonText = new Text2('RESTART', {
- size: 24,
+ size: 35,
fill: 0xFFFFFF
});
restartButtonText.anchor.set(0.5, 0.5);
restartButtonText.x = restartButton.x;
Modern App Store icon, high definition, square with rounded corners, for a game titled "Memory Match Cards" and with the description "A classic memory card game where players flip cards to find matching pairs. Tap cards to reveal them and match identical pairs to clear the board.". No text on icon!
Cute elephant. In-Game asset. 2d. High contrast. No shadows
Cute tiger. In-Game asset. 2d. High contrast. No shadows
Cute dog. In-Game asset. 2d. High contrast. No shadows
Cute cat. In-Game asset. 2d. High contrast. No shadows
Cute snake. In-Game asset. 2d. High contrast. No shadows
Cute giraffe. In-Game asset. 2d. High contrast. No shadows
Cute zebra. In-Game asset. 2d. High contrast. No shadows
cute monkey. In-Game asset. 2d. High contrast. No shadows
cute honey badger. In-Game asset. 2d. High contrast. No shadows
cute koala. In-Game asset. 2d. High contrast. No shadows
cute bear. In-Game asset. 2d. High contrast. No shadows
cute panda. In-Game asset. 2d. High contrast. No shadows
cute eagle. In-Game asset. 2d. High contrast. No shadows
cute lion. In-Game asset. 2d. High contrast. No shadows