/****
* 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.down = function (x, y, obj) {
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;
// Create UI
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: 80,
fill: 0xFFFFFF
});
movesText.anchor.set(0.5, 0);
LK.gui.top.addChild(movesText);
movesText.y = 250;
var pairsText = new Text2('Pairs: 0/' + totalPairs, {
size: 80,
fill: 0xFFFFFF
});
pairsText.anchor.set(0.5, 0);
LK.gui.top.addChild(pairsText);
pairsText.y = 350;
// 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
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;
}
cardTypes = shuffleArray(cardTypes);
// Calculate grid positioning
var cardWidth = 220;
var cardHeight = 280;
var cardSpacing = 20;
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;
// 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]);
var cardX = startX + col * (cardWidth + cardSpacing);
var cardY = startY + row * (cardHeight + cardSpacing);
card.x = cardX;
card.y = cardY;
cards.push(card);
game.addChild(card);
cardIndex++;
}
}
function checkMatch() {
if (flippedCards.length !== 2) return;
var card1 = flippedCards[0];
var card2 = flippedCards[1];
if (card1.cardType === card2.cardType) {
// Match found
LK.getSound('match').play();
card1.setMatched();
card2.setMatched();
matchedPairs++;
pairsText.setText('Pairs: ' + matchedPairs + '/' + totalPairs);
// Check for win condition
if (matchedPairs === totalPairs) {
LK.setTimeout(function () {
LK.showYouWin();
}, 500);
}
} else {
// No match
LK.getSound('noMatch').play();
card1.flip(false);
card2.flip(false);
}
flippedCards = [];
}
game.update = function () {
// Game logic is handled by card interactions and timeouts
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,190 @@
-/****
+/****
+* 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.down = function (x, y, obj) {
+ 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: 0x000000
-});
\ No newline at end of file
+ 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;
+// Create UI
+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: 80,
+ fill: 0xFFFFFF
+});
+movesText.anchor.set(0.5, 0);
+LK.gui.top.addChild(movesText);
+movesText.y = 250;
+var pairsText = new Text2('Pairs: 0/' + totalPairs, {
+ size: 80,
+ fill: 0xFFFFFF
+});
+pairsText.anchor.set(0.5, 0);
+LK.gui.top.addChild(pairsText);
+pairsText.y = 350;
+// 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
+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;
+}
+cardTypes = shuffleArray(cardTypes);
+// Calculate grid positioning
+var cardWidth = 220;
+var cardHeight = 280;
+var cardSpacing = 20;
+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;
+// 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]);
+ var cardX = startX + col * (cardWidth + cardSpacing);
+ var cardY = startY + row * (cardHeight + cardSpacing);
+ card.x = cardX;
+ card.y = cardY;
+ cards.push(card);
+ game.addChild(card);
+ cardIndex++;
+ }
+}
+function checkMatch() {
+ if (flippedCards.length !== 2) return;
+ var card1 = flippedCards[0];
+ var card2 = flippedCards[1];
+ if (card1.cardType === card2.cardType) {
+ // Match found
+ LK.getSound('match').play();
+ card1.setMatched();
+ card2.setMatched();
+ matchedPairs++;
+ pairsText.setText('Pairs: ' + matchedPairs + '/' + totalPairs);
+ // Check for win condition
+ if (matchedPairs === totalPairs) {
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 500);
+ }
+ } else {
+ // No match
+ LK.getSound('noMatch').play();
+ card1.flip(false);
+ card2.flip(false);
+ }
+ flippedCards = [];
+}
+game.update = function () {
+ // Game logic is handled by card interactions and timeouts
+};
\ No newline at end of file
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