User prompt
Süre 2 dakika olsun
User prompt
Süre 2 dakika 30 saniye olsun
User prompt
3 dakika içinde karların hepsi eşleştirilirse bir fotoğraf çıksın
User prompt
Süre hareket in yanında bulunsun
User prompt
3 dakika geri sayaç olsun
User prompt
Fotoğraflar kartlarla aynı boy olsun
User prompt
Ekranda her hangi bir kart büyümesin
User prompt
Seçtikten sonraki süre 1 saniyeden az olsun
User prompt
Seçtikten sonraki süre 1 dakikadan az olsun
User prompt
Seçtikten sonraki süre 80 salise olsun
User prompt
Seçtikten sonraki süre 20 salise olsun
User prompt
Seçtikten sonraki süre 1 saniye olsun
User prompt
Seçtikten sonraki süre 2 saniye daha uzun olsun
User prompt
Seçtikten sonraki süre biraz daha kısa olsun
User prompt
Ekrana biraz daha yaklaşınca
User prompt
Arka plan rengi kartların arkasının renginde biraz koyu olsun
User prompt
Süre olmasın
User prompt
Ekrana sığacak adar büyük olsun
User prompt
Sayı yerine fotoğraf olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Photo Match Frenzy
Initial prompt
Kart eşleştirme oyunu 6x6 lık her biri fotoğraf olsun
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
bestTime: 0,
bestMoves: 0
});
/****
* Classes
****/
var Card = Container.expand(function (cardId, cardValue) {
var self = Container.call(this);
// Properties
self.cardId = cardId;
self.cardValue = cardValue;
self.isFlipped = false;
self.isMatched = false;
// Card back - visible by default
var backShape = self.attachAsset('cardBack', {
anchorX: 0.5,
anchorY: 0.5,
width: 200,
height: 200
});
// Card front - hidden by default
var frontShape = self.attachAsset('card', {
anchorX: 0.5,
anchorY: 0.5,
width: 200,
height: 200,
visible: false
});
// Photo asset instead of text
var photoAsset = self.attachAsset('photo' + cardValue, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
visible: false
});
// Event handler for card click
self.down = function (x, y, obj) {
if (!self.isFlipped && !self.isMatched && !gameState.isProcessing) {
self.flip();
}
};
// Flip the card
self.flip = function () {
if (self.isFlipped) {
return;
}
self.isFlipped = true;
LK.getSound('flip').play();
// Reveal the card
tween(frontShape, {
scaleX: 1
}, {
duration: 200,
easing: tween.easeOut
});
frontShape.visible = true;
photoAsset.visible = true;
backShape.visible = false;
// Process the move in the game
checkForMatch();
};
// Match this card (permanently show it)
self.match = function () {
self.isMatched = true;
// Change appearance to indicate matched state
tween(frontShape, {
tint: 0x33cc33
}, {
duration: 300,
easing: tween.easeOut
});
};
// Reset the card (flip back)
self.reset = function () {
self.isFlipped = false;
frontShape.visible = false;
photoAsset.visible = false;
backShape.visible = true;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x10316b
});
/****
* Game Code
****/
// Initialize card photo assets - one for each pair (18 pairs)
// Game constants
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) {
return _arrayLikeToArray(r, a);
}
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) {
n[e] = r[e];
}
return n;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) {
return;
}
f = !1;
} else {
for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
;
}
}
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) {
return;
}
} finally {
if (o) {
throw n;
}
}
}
return a;
}
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) {
return r;
}
}
var GRID_SIZE = 6;
var CARD_COUNT = GRID_SIZE * GRID_SIZE;
var CARD_WIDTH = 200;
var CARD_HEIGHT = 200;
var CARD_SPACING = 20;
var GRID_WIDTH = GRID_SIZE * (CARD_WIDTH + CARD_SPACING) - CARD_SPACING;
var GRID_HEIGHT = GRID_SIZE * (CARD_HEIGHT + CARD_SPACING) - CARD_SPACING;
var GRID_START_X = (2048 - GRID_WIDTH) / 2;
var GRID_START_Y = (2732 - GRID_HEIGHT) / 2;
// Game state
var gameState = {
cards: [],
flippedCards: [],
isProcessing: false,
moves: 0,
matchesFound: 0,
totalMatches: CARD_COUNT / 2,
startTime: 0,
isGameOver: false
};
// GUI elements
var movesText = new Text2("Moves: 0", {
size: 70,
fill: 0xFFFFFF
});
movesText.anchor.set(0, 0.5);
LK.gui.left.addChild(movesText);
movesText.y = 100;
movesText.x = 50;
var timerText = new Text2("Time: 0s", {
size: 70,
fill: 0xFFFFFF
});
timerText.anchor.set(1, 0.5);
LK.gui.right.addChild(timerText);
timerText.y = 100;
timerText.x = -50;
var titleText = new Text2("Photo Match Frenzy", {
size: 90,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
LK.gui.top.addChild(titleText);
titleText.y = 80;
// Generate card values (pairs of values from 1 to CARD_COUNT/2)
function generateCardValues() {
var values = [];
for (var i = 1; i <= CARD_COUNT / 2; i++) {
values.push(i, i); // Add each value twice (to create pairs)
}
// Shuffle the array
for (var i = values.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var _ref = [values[j], values[i]];
values[i] = _ref[0];
values[j] = _ref[1];
}
return values;
}
// Initialize the game board
function initGame() {
// Reset game state
gameState.cards = [];
gameState.flippedCards = [];
gameState.isProcessing = false;
gameState.moves = 0;
gameState.matchesFound = 0;
gameState.isGameOver = false;
gameState.startTime = Date.now();
// Generate card values
var cardValues = generateCardValues();
// Create cards
for (var row = 0; row < GRID_SIZE; row++) {
for (var col = 0; col < GRID_SIZE; col++) {
var index = row * GRID_SIZE + col;
var cardId = index;
var cardValue = cardValues[index];
var card = new Card(cardId, cardValue);
// Position the card in the grid
card.x = GRID_START_X + col * (CARD_WIDTH + CARD_SPACING) + CARD_WIDTH / 2;
card.y = GRID_START_Y + row * (CARD_HEIGHT + CARD_SPACING) + CARD_HEIGHT / 2;
gameState.cards.push(card);
game.addChild(card);
}
}
// Update UI
updateMoves();
// Play background music
LK.playMusic('bgMusic');
}
// Update the moves counter
function updateMoves() {
movesText.setText("Moves: " + gameState.moves);
}
// Update the timer
function updateTimer() {
if (gameState.isGameOver) {
return;
}
var elapsedSeconds = Math.floor((Date.now() - gameState.startTime) / 1000);
timerText.setText("Time: " + elapsedSeconds + "s");
}
// Check if the flipped cards match
function checkForMatch() {
// Find all currently flipped but not matched cards
gameState.flippedCards = gameState.cards.filter(function (card) {
return card.isFlipped && !card.isMatched;
});
// If we have flipped 2 cards, check for a match
if (gameState.flippedCards.length === 2) {
gameState.moves++;
updateMoves();
var _gameState$flippedCar = _slicedToArray(gameState.flippedCards, 2),
card1 = _gameState$flippedCar[0],
card2 = _gameState$flippedCar[1];
// Set a small delay to let player see the cards
gameState.isProcessing = true;
LK.setTimeout(function () {
if (card1.cardValue === card2.cardValue) {
// Match found
LK.getSound('match').play();
card1.match();
card2.match();
gameState.matchesFound++;
// Check for game completion
if (gameState.matchesFound === gameState.totalMatches) {
endGame();
}
} else {
// No match
LK.getSound('noMatch').play();
card1.reset();
card2.reset();
}
gameState.flippedCards = [];
gameState.isProcessing = false;
}, 1000);
}
}
// End the game
function endGame() {
gameState.isGameOver = true;
// Calculate final score
var finalTime = Math.floor((Date.now() - gameState.startTime) / 1000);
// Check if we beat high score
var isNewBestTime = false;
var isNewBestMoves = false;
if (storage.bestTime === 0 || finalTime < storage.bestTime) {
storage.bestTime = finalTime;
isNewBestTime = true;
}
if (storage.bestMoves === 0 || gameState.moves < storage.bestMoves) {
storage.bestMoves = gameState.moves;
isNewBestMoves = true;
}
// Play victory sound
LK.getSound('victory').play();
// Update the score
LK.setScore(10000 - gameState.moves * 100 - finalTime * 10);
// Show the "You Win" screen
LK.setTimeout(function () {
LK.showYouWin();
}, 1500);
}
// Game update loop
game.update = function () {
// Update timer every second
if (LK.ticks % 60 === 0) {
updateTimer();
}
};
// Initialize the game
initGame(); ===================================================================
--- original.js
+++ change.js
@@ -31,16 +31,16 @@
width: 200,
height: 200,
visible: false
});
- // Card value (shown as a number for now - would be an image in a real implementation)
- var valueText = new Text2(cardValue.toString(), {
- size: 70,
- fill: 0xFFFFFF
+ // Photo asset instead of text
+ var photoAsset = self.attachAsset('photo' + cardValue, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1,
+ scaleY: 1,
+ visible: false
});
- valueText.anchor.set(0.5, 0.5);
- valueText.visible = false;
- self.addChild(valueText);
// Event handler for card click
self.down = function (x, y, obj) {
if (!self.isFlipped && !self.isMatched && !gameState.isProcessing) {
self.flip();
@@ -60,9 +60,9 @@
duration: 200,
easing: tween.easeOut
});
frontShape.visible = true;
- valueText.visible = true;
+ photoAsset.visible = true;
backShape.visible = false;
// Process the move in the game
checkForMatch();
};
@@ -80,9 +80,9 @@
// Reset the card (flip back)
self.reset = function () {
self.isFlipped = false;
frontShape.visible = false;
- valueText.visible = false;
+ photoAsset.visible = false;
backShape.visible = true;
};
return self;
});
@@ -96,8 +96,9 @@
/****
* Game Code
****/
+// Initialize card photo assets - one for each pair (18 pairs)
// Game constants
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}