User prompt
Süre bitip kartlar eşleştirilmediğinde fotoğraf ile birlikte C sesi kullan
User prompt
Süre 2 dakika 20 saniye olsun
User prompt
Süre 2 dakika 30 saniye olsun
User prompt
Süre 2 dakika 30 saniye olsun
User prompt
Süre 2 dakika olsun
User prompt
Süre bitene kadar tüm kartlar açılıp ekrana fotoğraf geldiğinde B sesini kullan
User prompt
Süre 1 dakika 50 saniye olsun
User prompt
2 dakika içinde tüm kartlar eşlenmez ise ekranda başka bir fotoğraf olsun
User prompt
2 dakika içinde tüm kartlar bulunursa ekranda bir fotoğraf çıksın
User prompt
Süre 2 dakika olsun
User prompt
Süre 3 dakika olsun
User prompt
Sonda hiç video olmasın
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'video')' in or related to this line: 'LK.init.video('success_video', {' Line Number: 157
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'video')' in or related to this line: 'LK.init.video('success_video');' Line Number: 157
User prompt
1 dakika geri sayacı olsun yukarıda ortada ve eğer 1 dakika içinde bitirilemez ise ekranda bir video çıksın eğer 1 dakika içinde bitirilirse başka bir video çıksın
User prompt
Arka plan rengi daha açık olsun
User prompt
Eşleşme olduğunda E sesini kullan
User prompt
Fotoğraflar kartların tamamını kaplanın
User prompt
Biraz daha yakın olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Zemin ekrana sığacak şekilde yakın olsun
User prompt
Kart üstünde sayılar yerine fotoğraf olsun
User prompt
8×8 değil 6×6olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Memory Match Challenge
Initial prompt
8×8 kartlardan oluşan düz bir zemin her bir kart başka bir kart ile eşleşicek ancak iki kart seçtiğiniz eklenmesiyle kartlar geri kapanacak
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Card = Container.expand(function (cardValue) { var self = Container.call(this); self.cardValue = cardValue; self.isFlipped = false; self.isMatched = false; // Create card back (visible when card is face down) var back = self.back = self.attachAsset('cardBack', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); // Create card front (visible when card is face up) var front = self.front = self.attachAsset('cardFront', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, visible: false }); // Create text to display card value var valueText = self.valueText = new Text2(cardValue.toString(), { size: 75, fill: 0x333333 }); valueText.anchor.set(0.5, 0.5); front.addChild(valueText); // Method to flip card face up self.flipUp = function () { if (self.isFlipped || self.isMatched) { return; } self.isFlipped = true; back.visible = false; front.visible = true; LK.getSound('flip').play(); }; // Method to flip card face down self.flipDown = function () { if (!self.isFlipped || self.isMatched) { return; } self.isFlipped = false; back.visible = true; front.visible = false; }; // Method to mark card as matched self.markAsMatched = function () { self.isMatched = true; // Change the card appearance to indicate it's matched tween(front, { tint: 0x2ecc71 }, { duration: 300, easing: tween.easeOut }); }; // Event handlers self.down = function (x, y, obj) { if (!gameActive || isProcessingMatch || self.isMatched) { return; } if (!self.isFlipped) { self.flipUp(); checkForMatch(self); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c3e50 }); /**** * Game Code ****/ // Game configuration var rows = 8; var cols = 8; var cardWidth = 200; var cardHeight = 200; var cardPadding = 10; var boardWidth = cols * (cardWidth + cardPadding) - cardPadding; var boardHeight = rows * (cardHeight + cardPadding) - cardPadding; // Game state variables var cards = []; var firstCard = null; var secondCard = null; var isProcessingMatch = false; var gameActive = false; var moveCount = 0; var matchedPairs = 0; var totalPairs = rows * cols / 2; // Create the UI text elements var movesText = new Text2('Moves: 0', { size: 75, fill: 0xFFFFFF }); movesText.anchor.set(0, 0); LK.gui.topLeft.addChild(movesText); movesText.x = 120; movesText.y = 20; var matchesText = new Text2('Matches: 0 / ' + totalPairs, { size: 75, fill: 0xFFFFFF }); matchesText.anchor.set(1, 0); LK.gui.topRight.addChild(matchesText); matchesText.x = -20; matchesText.y = 20; // Game board container to position the entire grid in the center var boardContainer = new Container(); game.addChild(boardContainer); // Position the board container in the center of the screen boardContainer.x = (2048 - boardWidth) / 2; boardContainer.y = (2732 - boardHeight) / 2; // Function to update the UI function updateUI() { movesText.setText('Moves: ' + moveCount); matchesText.setText('Matches: ' + matchedPairs + ' / ' + totalPairs); } // Function to create all the card values (pairs) function createCardValues() { var values = []; var pairsNeeded = rows * cols / 2; for (var i = 1; i <= pairsNeeded; i++) { values.push(i); values.push(i); } // Shuffle the values for (var i = values.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = values[i]; values[i] = values[j]; values[j] = temp; } return values; } // Function to initialize the game board function initializeGame() { // Clear existing cards if any if (cards.length > 0) { for (var i = 0; i < cards.length; i++) { boardContainer.removeChild(cards[i]); } cards = []; } // Reset game state firstCard = null; secondCard = null; isProcessingMatch = false; gameActive = true; moveCount = 0; matchedPairs = 0; // Create card values (1-32 pairs) var cardValues = createCardValues(); // Create and position all cards var index = 0; for (var row = 0; row < rows; row++) { for (var col = 0; col < cols; col++) { var card = new Card(cardValues[index]); // Position card in grid card.x = col * (cardWidth + cardPadding) + cardWidth / 2; card.y = row * (cardHeight + cardPadding) + cardHeight / 2; boardContainer.addChild(card); cards.push(card); index++; } } // Update UI to show initial state updateUI(); // Start background music LK.playMusic('bgmusic'); } // Check if the flipped card creates a match function checkForMatch(card) { if (!firstCard) { // This is the first card flipped firstCard = card; } else if (firstCard !== card && !secondCard) { // This is the second card flipped secondCard = card; moveCount++; updateUI(); // Process the match isProcessingMatch = true; if (firstCard.cardValue === secondCard.cardValue) { // Cards match LK.getSound('match').play(); matchedPairs++; updateUI(); firstCard.markAsMatched(); secondCard.markAsMatched(); // Reset for next pair LK.setTimeout(function () { firstCard = null; secondCard = null; isProcessingMatch = false; // Check if all pairs have been matched if (matchedPairs === totalPairs) { LK.setTimeout(function () { LK.setScore(moveCount); LK.showYouWin(); }, 500); } }, 500); } else { // Cards don't match LK.getSound('nomatch').play(); // Flip both cards back after a short delay LK.setTimeout(function () { firstCard.flipDown(); secondCard.flipDown(); // Reset for next attempt firstCard = null; secondCard = null; isProcessingMatch = false; }, 1000); } } } // Initialize the game initializeGame(); // Game update loop game.update = function () { // This game doesn't need any per-frame updates // All logic is handled by event callbacks }; // Handle moves on the game game.move = function (x, y, obj) { // We don't need move handling for this game };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,245 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var Card = Container.expand(function (cardValue) {
+ var self = Container.call(this);
+ self.cardValue = cardValue;
+ self.isFlipped = false;
+ self.isMatched = false;
+ // Create card back (visible when card is face down)
+ var back = self.back = self.attachAsset('cardBack', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 0
+ });
+ // Create card front (visible when card is face up)
+ var front = self.front = self.attachAsset('cardFront', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 0,
+ visible: false
+ });
+ // Create text to display card value
+ var valueText = self.valueText = new Text2(cardValue.toString(), {
+ size: 75,
+ fill: 0x333333
+ });
+ valueText.anchor.set(0.5, 0.5);
+ front.addChild(valueText);
+ // Method to flip card face up
+ self.flipUp = function () {
+ if (self.isFlipped || self.isMatched) {
+ return;
+ }
+ self.isFlipped = true;
+ back.visible = false;
+ front.visible = true;
+ LK.getSound('flip').play();
+ };
+ // Method to flip card face down
+ self.flipDown = function () {
+ if (!self.isFlipped || self.isMatched) {
+ return;
+ }
+ self.isFlipped = false;
+ back.visible = true;
+ front.visible = false;
+ };
+ // Method to mark card as matched
+ self.markAsMatched = function () {
+ self.isMatched = true;
+ // Change the card appearance to indicate it's matched
+ tween(front, {
+ tint: 0x2ecc71
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ };
+ // Event handlers
+ self.down = function (x, y, obj) {
+ if (!gameActive || isProcessingMatch || self.isMatched) {
+ return;
+ }
+ if (!self.isFlipped) {
+ self.flipUp();
+ checkForMatch(self);
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2c3e50
+});
+
+/****
+* Game Code
+****/
+// Game configuration
+var rows = 8;
+var cols = 8;
+var cardWidth = 200;
+var cardHeight = 200;
+var cardPadding = 10;
+var boardWidth = cols * (cardWidth + cardPadding) - cardPadding;
+var boardHeight = rows * (cardHeight + cardPadding) - cardPadding;
+// Game state variables
+var cards = [];
+var firstCard = null;
+var secondCard = null;
+var isProcessingMatch = false;
+var gameActive = false;
+var moveCount = 0;
+var matchedPairs = 0;
+var totalPairs = rows * cols / 2;
+// Create the UI text elements
+var movesText = new Text2('Moves: 0', {
+ size: 75,
+ fill: 0xFFFFFF
+});
+movesText.anchor.set(0, 0);
+LK.gui.topLeft.addChild(movesText);
+movesText.x = 120;
+movesText.y = 20;
+var matchesText = new Text2('Matches: 0 / ' + totalPairs, {
+ size: 75,
+ fill: 0xFFFFFF
+});
+matchesText.anchor.set(1, 0);
+LK.gui.topRight.addChild(matchesText);
+matchesText.x = -20;
+matchesText.y = 20;
+// Game board container to position the entire grid in the center
+var boardContainer = new Container();
+game.addChild(boardContainer);
+// Position the board container in the center of the screen
+boardContainer.x = (2048 - boardWidth) / 2;
+boardContainer.y = (2732 - boardHeight) / 2;
+// Function to update the UI
+function updateUI() {
+ movesText.setText('Moves: ' + moveCount);
+ matchesText.setText('Matches: ' + matchedPairs + ' / ' + totalPairs);
+}
+// Function to create all the card values (pairs)
+function createCardValues() {
+ var values = [];
+ var pairsNeeded = rows * cols / 2;
+ for (var i = 1; i <= pairsNeeded; i++) {
+ values.push(i);
+ values.push(i);
+ }
+ // Shuffle the values
+ for (var i = values.length - 1; i > 0; i--) {
+ var j = Math.floor(Math.random() * (i + 1));
+ var temp = values[i];
+ values[i] = values[j];
+ values[j] = temp;
+ }
+ return values;
+}
+// Function to initialize the game board
+function initializeGame() {
+ // Clear existing cards if any
+ if (cards.length > 0) {
+ for (var i = 0; i < cards.length; i++) {
+ boardContainer.removeChild(cards[i]);
+ }
+ cards = [];
+ }
+ // Reset game state
+ firstCard = null;
+ secondCard = null;
+ isProcessingMatch = false;
+ gameActive = true;
+ moveCount = 0;
+ matchedPairs = 0;
+ // Create card values (1-32 pairs)
+ var cardValues = createCardValues();
+ // Create and position all cards
+ var index = 0;
+ for (var row = 0; row < rows; row++) {
+ for (var col = 0; col < cols; col++) {
+ var card = new Card(cardValues[index]);
+ // Position card in grid
+ card.x = col * (cardWidth + cardPadding) + cardWidth / 2;
+ card.y = row * (cardHeight + cardPadding) + cardHeight / 2;
+ boardContainer.addChild(card);
+ cards.push(card);
+ index++;
+ }
+ }
+ // Update UI to show initial state
+ updateUI();
+ // Start background music
+ LK.playMusic('bgmusic');
+}
+// Check if the flipped card creates a match
+function checkForMatch(card) {
+ if (!firstCard) {
+ // This is the first card flipped
+ firstCard = card;
+ } else if (firstCard !== card && !secondCard) {
+ // This is the second card flipped
+ secondCard = card;
+ moveCount++;
+ updateUI();
+ // Process the match
+ isProcessingMatch = true;
+ if (firstCard.cardValue === secondCard.cardValue) {
+ // Cards match
+ LK.getSound('match').play();
+ matchedPairs++;
+ updateUI();
+ firstCard.markAsMatched();
+ secondCard.markAsMatched();
+ // Reset for next pair
+ LK.setTimeout(function () {
+ firstCard = null;
+ secondCard = null;
+ isProcessingMatch = false;
+ // Check if all pairs have been matched
+ if (matchedPairs === totalPairs) {
+ LK.setTimeout(function () {
+ LK.setScore(moveCount);
+ LK.showYouWin();
+ }, 500);
+ }
+ }, 500);
+ } else {
+ // Cards don't match
+ LK.getSound('nomatch').play();
+ // Flip both cards back after a short delay
+ LK.setTimeout(function () {
+ firstCard.flipDown();
+ secondCard.flipDown();
+ // Reset for next attempt
+ firstCard = null;
+ secondCard = null;
+ isProcessingMatch = false;
+ }, 1000);
+ }
+ }
+}
+// Initialize the game
+initializeGame();
+// Game update loop
+game.update = function () {
+ // This game doesn't need any per-frame updates
+ // All logic is handled by event callbacks
+};
+// Handle moves on the game
+game.move = function (x, y, obj) {
+ // We don't need move handling for this game
+};
\ No newline at end of file