User prompt
Oyun bölümler halinde olmalı ve her bölümden önce ana sayfada olmalıyız
User prompt
Oyunda daha fazla kelime olsun
User prompt
Please fix the bug: 'storage.getItem is not a function' in or related to this line: 'var currentLevel = storage.getItem('currentLevel') || 1;' Line Number: 167 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyun bölüm bölüm olsun bir bölüm bitince ana sayfaya dönüp yeni bölüme geçelim
User prompt
Her doğruda 10 puan kazanıp her yanlışta 5 puan kaybedelim skor ekranda yazsin
Code edit (1 edits merged)
Please save this source code
User prompt
Word Match: English-Turkish
Initial prompt
> Project Title: Mobile Word Matching Game (English–Turkish) Project Description: I want to build a 2-column word matching game for mobile (Android and optionally iOS), similar to the layout in the attached image. The game should allow users to match English and Turkish words by tapping. When a correct match is made, both words are disabled or marked as matched. If the match is incorrect, the selection resets after a short delay. Visual Style: Cartoonish, colorful, fun interface Rounded buttons with shadows and simple animations Background like a night scene with soft light elements (similar to the image) Button layout: Words appear in a grid, English words and Turkish words are shuffled Game Logic: Words are presented as buttons in a shuffled order. The player taps two words (one after the other). If the words match (e.g., "SOCKS" = "çorap"), mark them as correct (disable or animate). If incorrect, reset both selections after a delay. There is a mistake counter (3 hearts or 3 tries). Game ends when mistakes run out or all matches are found. Score system optional but nice to have. Sample Word Pairs (can be stored in a JSON or scriptable object): "ALREADY" — "çoktan" "MUSICIAN" — "müzisyen" "PHOTOGRAPHER" — "fotoğrafçı" "SOCKS" — "çorap" "FEW" — "bir kaç" "LEARNT" — "öğrenilen" Extra Features (Optional but nice): Light background music and simple click sounds Hints (like revealing one match) Animated hearts or mistake counter Level system with increasing difficulty (more pairs)
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var HeartDisplay = Container.expand(function () { var self = Container.call(this); self.hearts = []; self.maxHearts = 3; self.currentHearts = 3; for (var i = 0; i < self.maxHearts; i++) { var heart = self.attachAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); heart.x = i * 80; self.hearts.push(heart); } self.loseHeart = function () { if (self.currentHearts > 0) { self.currentHearts--; var heartToRemove = self.hearts[self.currentHearts]; heartToRemove.tint = 0x666666; tween(heartToRemove, { scaleX: 0.5, scaleY: 0.5 }, { duration: 300 }); if (self.currentHearts === 0) { LK.setTimeout(function () { LK.showGameOver(); }, 1000); } } }; return self; }); var WordButton = Container.expand(function (word, isEnglish) { var self = Container.call(this); self.word = word; self.isEnglish = isEnglish; self.isSelected = false; self.isMatched = false; var buttonShape = self.attachAsset('wordButton', { anchorX: 0.5, anchorY: 0.5 }); var wordText = new Text2(word, { size: 32, fill: 0xFFFFFF }); wordText.anchor.set(0.5, 0.5); self.addChild(wordText); self.setSelected = function (selected) { self.isSelected = selected; if (selected) { buttonShape.tint = 0x2196F3; } else { buttonShape.tint = 0x4CAF50; } }; self.setMatched = function () { self.isMatched = true; buttonShape.tint = 0x8BC34A; tween(self, { alpha: 0.7 }, { duration: 300 }); }; self.showIncorrect = function () { buttonShape.tint = 0xFF5722; tween(self, { scaleX: 1.1, scaleY: 1.1 }, { duration: 150, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 150 }); } }); }; self.down = function (x, y, obj) { if (!self.isMatched) { handleWordButtonPress(self); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ var wordPairs = [{ english: "ALREADY", turkish: "çoktan" }, { english: "MUSICIAN", turkish: "müzisyen" }, { english: "PHOTOGRAPHER", turkish: "fotoğrafçı" }, { english: "SOCKS", turkish: "çorap" }, { english: "FEW", turkish: "bir kaç" }, { english: "LEARNT", turkish: "öğrenilen" }, { english: "BEAUTIFUL", turkish: "güzel" }, { english: "KITCHEN", turkish: "mutfak" }]; var englishWords = []; var turkishWords = []; var selectedButton = null; var matchedPairs = 0; var heartDisplay; var isProcessing = false; var currentScore = 0; var scoreText; 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; } } function createWordButtons() { var englishList = []; var turkishList = []; for (var i = 0; i < wordPairs.length; i++) { englishList.push(wordPairs[i].english); turkishList.push(wordPairs[i].turkish); } shuffleArray(englishList); shuffleArray(turkishList); // Create English column for (var i = 0; i < englishList.length; i++) { var englishButton = new WordButton(englishList[i], true); englishButton.x = 2048 * 0.25; englishButton.y = 300 + i * 120; englishWords.push(englishButton); game.addChild(englishButton); } // Create Turkish column for (var i = 0; i < turkishList.length; i++) { var turkishButton = new WordButton(turkishList[i], false); turkishButton.x = 2048 * 0.75; turkishButton.y = 300 + i * 120; turkishWords.push(turkishButton); game.addChild(turkishButton); } } function findMatchingWord(word, isEnglish) { for (var i = 0; i < wordPairs.length; i++) { if (isEnglish && wordPairs[i].english === word) { return wordPairs[i].turkish; } else if (!isEnglish && wordPairs[i].turkish === word) { return wordPairs[i].english; } } return null; } function handleWordButtonPress(button) { if (isProcessing) return; if (selectedButton === null) { selectedButton = button; button.setSelected(true); } else if (selectedButton === button) { selectedButton.setSelected(false); selectedButton = null; } else { isProcessing = true; var firstWord = selectedButton.word; var secondWord = button.word; var isFirstEnglish = selectedButton.isEnglish; var matchingWord = findMatchingWord(firstWord, isFirstEnglish); if (matchingWord === secondWord) { // Correct match selectedButton.setMatched(); button.setMatched(); matchedPairs++; currentScore += 10; scoreText.setText("Score: " + currentScore); LK.getSound('correct').play(); if (matchedPairs === wordPairs.length) { LK.setTimeout(function () { LK.showYouWin(); }, 1000); } selectedButton = null; isProcessing = false; } else { // Incorrect match selectedButton.showIncorrect(); button.showIncorrect(); heartDisplay.loseHeart(); currentScore -= 5; if (currentScore < 0) currentScore = 0; scoreText.setText("Score: " + currentScore); LK.getSound('incorrect').play(); LK.getSound('heartLost').play(); LK.setTimeout(function () { selectedButton.setSelected(false); button.setSelected(false); selectedButton = null; isProcessing = false; }, 1000); } } } // Initialize heart display heartDisplay = new HeartDisplay(); heartDisplay.x = 2048 / 2 - 120; heartDisplay.y = 150; LK.gui.top.addChild(heartDisplay); // Add title var titleText = new Text2("Word Match: English-Turkish", { size: 48, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 2048 / 2; titleText.y = 50; game.addChild(titleText); // Add score display scoreText = new Text2("Score: 0", { size: 36, fill: 0xFFD700 }); scoreText.anchor.set(0.5, 0); scoreText.x = 2048 / 2; scoreText.y = 100; game.addChild(scoreText); // Create word buttons createWordButtons(); game.update = function () { // Game logic is handled by button presses and timers };
===================================================================
--- original.js
+++ change.js
@@ -137,8 +137,10 @@
var selectedButton = null;
var matchedPairs = 0;
var heartDisplay;
var isProcessing = false;
+var currentScore = 0;
+var scoreText;
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
@@ -200,8 +202,10 @@
// Correct match
selectedButton.setMatched();
button.setMatched();
matchedPairs++;
+ currentScore += 10;
+ scoreText.setText("Score: " + currentScore);
LK.getSound('correct').play();
if (matchedPairs === wordPairs.length) {
LK.setTimeout(function () {
LK.showYouWin();
@@ -213,8 +217,11 @@
// Incorrect match
selectedButton.showIncorrect();
button.showIncorrect();
heartDisplay.loseHeart();
+ currentScore -= 5;
+ if (currentScore < 0) currentScore = 0;
+ scoreText.setText("Score: " + currentScore);
LK.getSound('incorrect').play();
LK.getSound('heartLost').play();
LK.setTimeout(function () {
selectedButton.setSelected(false);
@@ -238,8 +245,17 @@
titleText.anchor.set(0.5, 0);
titleText.x = 2048 / 2;
titleText.y = 50;
game.addChild(titleText);
+// Add score display
+scoreText = new Text2("Score: 0", {
+ size: 36,
+ fill: 0xFFD700
+});
+scoreText.anchor.set(0.5, 0);
+scoreText.x = 2048 / 2;
+scoreText.y = 100;
+game.addChild(scoreText);
// Create word buttons
createWordButtons();
game.update = function () {
// Game logic is handled by button presses and timers