User prompt
piano müziğini oyun müziği olarak kullan ekle
User prompt
sıralamyo doğru bildiğinde yes ses efektini yanlış bildiğinde zort ses efektini kullan
User prompt
yazılar daha modern olsun ve kalın olsun görünür şekilde sayılarda aynı şekilde
User prompt
arka planı kullan
User prompt
tamam güzel şimdi melodilerin notaların ara mesafesini aç ve braz büyüt birde her nota melodi için bir ses efekti ekle hepsinin bir notası olacak do re mi gibi
User prompt
hangi melodiye tıklayacağımızı gösterceksin ama başta sana dedimya görsel hafıza
User prompt
o resimler kaobolmuyacak resimler bizim tıklayacağımız yer aynı resimlerden üstte olacak yanıp sönecek klasik görsel hafıza oyunu
User prompt
şimdi oyunda meldoi resimleri görünecek ve hafza mantığı bir oyun göstercek kapanacak doğru tıklayın 2. bölüm olacak öyle zorluğu artacak yanana kadar sonsuz puanla devam edecek
User prompt
verdiğim melodi resimlerini kullan
Code edit (1 edits merged)
Please save this source code
User prompt
Color Path Memory
Initial prompt
https://upit.com/@eren_25/play/yer_VUCAde şu oyunun aynısını yap
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Tile class: represents a melody image tile in the grid var Tile = Container.expand(function () { var self = Container.call(this); // Properties self.tileIndex = -1; // index in the tiles array // Attach asset (melody image based on index) var melodyIds = ['melodi1', 'melodi2', 'melodi3', 'melodi4']; var tileAsset = self.attachAsset(melodyIds[self.tileIndex >= 0 ? self.tileIndex : 0], { anchorX: 0.5, anchorY: 0.5 }); // Set image (for initialization, called after tileIndex is set) self.setImage = function (idx) { // Remove old asset if exists if (tileAsset && tileAsset.parent) { tileAsset.parent.removeChild(tileAsset); } var melodyId = melodyIds[idx]; var newAsset = self.attachAsset(melodyId, { anchorX: 0.5, anchorY: 0.5 }); // Set size to TILE_SIZE newAsset.width = TILE_SIZE; newAsset.height = TILE_SIZE; // Save reference tileAsset = newAsset; }; // Flash animation for showing sequence or feedback self.flash = function (duration, highlightColor, _onFinish) { // Play sound effect based on tile index var soundNames = ['do', 're', 'mi', 'fa']; if (self.tileIndex >= 0 && self.tileIndex < soundNames.length) { LK.getSound(soundNames[self.tileIndex]).play(); } // Animate alpha to 0.5, then back to 1 for feedback tween(tileAsset, { alpha: 0.5 }, { duration: duration / 2, easing: tween.easeIn, onFinish: function onFinish() { tween(tileAsset, { alpha: 1 }, { duration: duration / 2, easing: tween.easeOut, onFinish: _onFinish }); } }); }; // Down event: called when player taps this tile self.down = function (x, y, obj) { if (game.inputEnabled) { game.handleTileTap(self.tileIndex); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ // --- START SCREEN --- // Show only the baslama image on top of everything at start, hide all other UI and tiles var startScreen = new Container(); // Calculate baslama image size to fully cover the screen proportionally (no cropping, no empty bars) var baslamaOrigW = 1000; var baslamaOrigH = 1000; var screenW = 2048; var screenH = 2732; // Scale so that the image fills the screen in both directions (no bars), but does not crop (fit inside) var baslamaScale = Math.max(screenW / baslamaOrigW, screenH / baslamaOrigH); var baslamaWidth = baslamaOrigW * baslamaScale; var baslamaHeight = baslamaOrigH * baslamaScale; // Center the image var baslamaImg = LK.getAsset('baslama', { anchorX: 0.5, anchorY: 0.5, x: screenW / 2, y: screenH / 2, width: baslamaWidth, height: baslamaHeight }); startScreen.addChild(baslamaImg); game.addChild(startScreen); // Always bring startScreen to top after all children are added game.setChildIndex(startScreen, game.children.length - 1); // Hide or show all UI and tiles except baslama image function setGameUIVisible(visible) { // Show/hide all UI and tiles except baslama image if (scoreTxt) scoreTxt.visible = visible; if (levelTxt) levelTxt.visible = visible; if (timerTxt) timerTxt.visible = visible; if (instructionTxt) instructionTxt.visible = visible; if (typeof tiles !== "undefined" && tiles && tiles.length) { for (var i = 0; i < tiles.length; i++) { if (tiles[i]) { tiles[i].visible = visible; if (tiles[i].children && tiles[i].children.length > 0) { for (var j = 0; j < tiles[i].children.length; j++) { tiles[i].children[j].visible = visible; } } } } } // Only show baslama image if visible is false (start screen) if (typeof startScreen !== "undefined" && startScreen) startScreen.visible = !visible; } // On load, show only baslama image and hide everything else setGameUIVisible(false); // Start button event (tap anywhere on baslama image) baslamaImg.down = function (x, y, obj) { // Hide baslama image, show all UI and tiles setGameUIVisible(true); // Make sure baslama image is not on top anymore if (typeof startScreen !== "undefined" && startScreen && startScreen.parent) { startScreen.parent.setChildIndex(startScreen, 0); } startGame(); }; // --- CONFIGURATION --- var GRID_SIZE = 2; // 2x2 grid (classic Simon style) var TILE_GAP = 120; // px gap between tiles - increased spacing var TILE_SIZE = 500; // px, will be scaled for iPad Pro - larger tiles var TILE_COLORS = [0xff3b30, 0x34c759, 0x007aff, 0xffcc00]; // red, green, blue, yellow var TILE_HIGHLIGHT = [0xff8880, 0x88ffb0, 0x80b0ff, 0xfff680]; // lighter highlight for each color var SEQUENCE_START_LENGTH = 3; var SEQUENCE_GROWTH = 1; var SEQUENCE_MAX_LENGTH = 100; var SHOW_STEP_BASE_DURATION = 500; // ms, will get faster var SHOW_STEP_MIN_DURATION = 200; // ms var INPUT_TIME_LIMIT = 5000; // ms per sequence (decreases as level increases) var TILE_FLASH_FEEDBACK = 250; // ms // --- ASSETS --- for (var i = 0; i < TILE_COLORS.length; i++) {} // generic, color set later // --- STATE --- var tiles = []; // array of Tile instances var sequence = []; // array of tile indices (the pattern to repeat) var playerInput = []; // array of tile indices (player's taps) var currentStep = 0; // which step in the sequence is being shown var showingSequence = false; var inputTimer = null; var inputTimeLeft = 0; var level = 1; var inputEnabled = false; var score = 0; // --- UI --- // Text UI is created only after the game starts, not on the baslama screen var scoreTxt, levelTxt, timerTxt, instructionTxt; // --- GAME LOGIC --- // Helper: center grid on screen function getTilePos(row, col) { var gridW = GRID_SIZE * TILE_SIZE + (GRID_SIZE - 1) * TILE_GAP; var gridH = GRID_SIZE * TILE_SIZE + (GRID_SIZE - 1) * TILE_GAP; var startX = (2048 - gridW) / 2 + TILE_SIZE / 2; var startY = (2732 - gridH) / 2 + TILE_SIZE / 2 + 100; // +100 to avoid top menu return { x: startX + col * (TILE_SIZE + TILE_GAP), y: startY + row * (TILE_SIZE + TILE_GAP) }; } // Create grid of tiles for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE; col++) { var idx = row * GRID_SIZE + col; var tile = new Tile(); tile.tileIndex = idx; tile.setImage(idx); // Set the melody image for this tile var pos = getTilePos(row, col); tile.x = pos.x; tile.y = pos.y; tiles.push(tile); game.addChild(tile); } } // --- GAME STATE MANAGEMENT --- // Start a new game function startGame() { sequence = []; playerInput = []; currentStep = 0; showingSequence = false; level = 1; score = 0; inputEnabled = false; // Create text UI now (after baslama image is hidden) if (!scoreTxt) { scoreTxt = new Text2('0', { size: 140, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif", fontWeight: 'bold' }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); } if (!levelTxt) { levelTxt = new Text2('Level 1', { size: 90, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif", fontWeight: 'bold' }); levelTxt.anchor.set(0.5, 0); LK.gui.top.addChild(levelTxt); levelTxt.y = 130; } if (!timerTxt) { timerTxt = new Text2('', { size: 90, fill: 0xFFCC00, font: "'Arial Black', 'Helvetica-Bold', sans-serif", fontWeight: 'bold' }); timerTxt.anchor.set(0.5, 0); LK.gui.top.addChild(timerTxt); timerTxt.y = 230; } if (!instructionTxt) { instructionTxt = new Text2('Watch the sequence!', { size: 80, fill: 0xFFFFFF, font: "'Arial Black', 'Helvetica-Bold', sans-serif", fontWeight: 'bold' }); instructionTxt.anchor.set(0.5, 0); LK.gui.top.addChild(instructionTxt); instructionTxt.y = 330; } updateScore(); updateLevel(); nextRound(); } // Start next round (add to sequence, show it) function nextRound() { playerInput = []; inputEnabled = false; // Add new random tile to sequence if (sequence.length < SEQUENCE_MAX_LENGTH) { for (var i = 0; i < SEQUENCE_GROWTH; i++) { var nextIdx = Math.floor(Math.random() * tiles.length); sequence.push(nextIdx); } } currentStep = 0; showSequence(); } // Show the sequence to the player function showSequence() { showingSequence = true; inputEnabled = false; instructionTxt.setText('Watch the sequence!'); var stepDuration = Math.max(SHOW_STEP_BASE_DURATION - (level - 1) * 30, SHOW_STEP_MIN_DURATION); // Helper: show all tile images (make visible when game starts) function showAllTiles() { for (var i = 0; i < tiles.length; i++) { tiles[i].visible = true; if (tiles[i].children.length > 0) { for (var j = 0; j < tiles[i].children.length; j++) { tiles[i].children[j].visible = true; } } } } // Always show all tiles before sequence showAllTiles(); function showStep(step) { if (step >= sequence.length) { showingSequence = false; // Do NOT hide tiles for memory challenge; keep them visible enableInput(); return; } var idx = sequence[step]; // More pronounced visual feedback during sequence showing var tile = tiles[idx]; // Scale up the tile to make it more obvious tween(tile, { scaleX: 1.2, scaleY: 1.2 }, { duration: stepDuration / 3, easing: tween.easeOut, onFinish: function onFinish() { // Scale back down tween(tile, { scaleX: 1.0, scaleY: 1.0 }, { duration: stepDuration / 3, easing: tween.easeIn, onFinish: function onFinish() { LK.setTimeout(function () { showStep(step + 1); }, 100); } }); } }); // Also keep the flash effect tiles[idx].flash(stepDuration, TILE_HIGHLIGHT[idx], function () { // Flash completed }); } showStep(0); } // Enable player input function enableInput() { inputEnabled = true; game.inputEnabled = true; instructionTxt.setText('Repeat the sequence!'); inputTimeLeft = Math.max(INPUT_TIME_LIMIT - (level - 1) * 200, 2000); updateTimerText(); if (inputTimer) { LK.clearInterval(inputTimer); } inputTimer = LK.setInterval(function () { inputTimeLeft -= 100; updateTimerText(); if (inputTimeLeft <= 0) { inputEnabled = false; game.inputEnabled = false; LK.clearInterval(inputTimer); inputTimer = null; failSequence(); } }, 100); } // Handle player tapping a tile game.handleTileTap = function (tileIdx) { if (!inputEnabled || showingSequence) return; playerInput.push(tileIdx); // Play sound effect immediately when tapped var soundNames = ['do', 're', 'mi', 'fa']; if (tileIdx >= 0 && tileIdx < soundNames.length) { LK.getSound(soundNames[tileIdx]).play(); } // Flash feedback (no hiding/showing, just flash effect) tiles[tileIdx].flash(TILE_FLASH_FEEDBACK, TILE_HIGHLIGHT[tileIdx], function () { // No need to hide or show tile images; always visible }); // Check correctness var expected = sequence[playerInput.length - 1]; if (tileIdx !== expected) { inputEnabled = false; game.inputEnabled = false; if (inputTimer) { LK.clearInterval(inputTimer); inputTimer = null; } // Play wrong answer sound LK.getSound('zort').play(); // Flash red LK.effects.flashScreen(0xff0000, 800); LK.setTimeout(function () { LK.showGameOver(); }, 800); return; } // If correct and finished input if (playerInput.length === sequence.length) { if (inputTimer) { LK.clearInterval(inputTimer); inputTimer = null; } // Play success sound LK.getSound('yes').play(); // Success! Increase score, level, and go to next round score += sequence.length; level += 1; updateScore(); updateLevel(); // Flash green LK.effects.flashScreen(0x00ff00, 400); LK.setTimeout(function () { nextRound(); }, 500); } }; // Player failed to input in time function failSequence() { inputEnabled = false; game.inputEnabled = false; // Play wrong answer sound LK.getSound('zort').play(); // Flash red LK.effects.flashScreen(0xff0000, 800); LK.setTimeout(function () { LK.showGameOver(); }, 800); } // Update score display function updateScore() { scoreTxt.setText(score); LK.setScore(score); } // Update level display function updateLevel() { levelTxt.setText('Level ' + level); } // Update timer display function updateTimerText() { if (!inputEnabled) { timerTxt.setText(''); return; } var sec = Math.ceil(inputTimeLeft / 100) / 10; timerTxt.setText(sec.toFixed(1) + 's'); } // --- BACKGROUND MUSIC --- LK.playMusic('piano'); // --- GAME EVENT HOOKS --- // On game reset, show only baslama image and hide all UI game.on('reset', function () { setGameUIVisible(false); // Bring baslama image to front again after reset if (typeof startScreen !== "undefined" && startScreen && startScreen.parent) { startScreen.parent.setChildIndex(startScreen, startScreen.parent.children.length - 1); } }); // --- DRAGGING DISABLED --- // No dragging or move events needed for this game // --- WIN CONDITION --- // If player reaches max sequence length, show win function checkWin() { if (sequence.length >= SEQUENCE_MAX_LENGTH) { LK.effects.flashScreen(0x00ff00, 1000); LK.setTimeout(function () { LK.showYouWin(); }, 1000); } } // --- GAME UPDATE LOOP --- game.update = function () { // Nothing needed here for this game // Timer is handled by inputTimer // Could check for win checkWin(); // Always bring baslama image to top if visible if (typeof startScreen !== "undefined" && startScreen && startScreen.visible && startScreen.parent) { startScreen.parent.setChildIndex(startScreen, startScreen.parent.children.length - 1); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Tile class: represents a melody image tile in the grid
var Tile = Container.expand(function () {
var self = Container.call(this);
// Properties
self.tileIndex = -1; // index in the tiles array
// Attach asset (melody image based on index)
var melodyIds = ['melodi1', 'melodi2', 'melodi3', 'melodi4'];
var tileAsset = self.attachAsset(melodyIds[self.tileIndex >= 0 ? self.tileIndex : 0], {
anchorX: 0.5,
anchorY: 0.5
});
// Set image (for initialization, called after tileIndex is set)
self.setImage = function (idx) {
// Remove old asset if exists
if (tileAsset && tileAsset.parent) {
tileAsset.parent.removeChild(tileAsset);
}
var melodyId = melodyIds[idx];
var newAsset = self.attachAsset(melodyId, {
anchorX: 0.5,
anchorY: 0.5
});
// Set size to TILE_SIZE
newAsset.width = TILE_SIZE;
newAsset.height = TILE_SIZE;
// Save reference
tileAsset = newAsset;
};
// Flash animation for showing sequence or feedback
self.flash = function (duration, highlightColor, _onFinish) {
// Play sound effect based on tile index
var soundNames = ['do', 're', 'mi', 'fa'];
if (self.tileIndex >= 0 && self.tileIndex < soundNames.length) {
LK.getSound(soundNames[self.tileIndex]).play();
}
// Animate alpha to 0.5, then back to 1 for feedback
tween(tileAsset, {
alpha: 0.5
}, {
duration: duration / 2,
easing: tween.easeIn,
onFinish: function onFinish() {
tween(tileAsset, {
alpha: 1
}, {
duration: duration / 2,
easing: tween.easeOut,
onFinish: _onFinish
});
}
});
};
// Down event: called when player taps this tile
self.down = function (x, y, obj) {
if (game.inputEnabled) {
game.handleTileTap(self.tileIndex);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222222
});
/****
* Game Code
****/
// --- START SCREEN ---
// Show only the baslama image on top of everything at start, hide all other UI and tiles
var startScreen = new Container();
// Calculate baslama image size to fully cover the screen proportionally (no cropping, no empty bars)
var baslamaOrigW = 1000;
var baslamaOrigH = 1000;
var screenW = 2048;
var screenH = 2732;
// Scale so that the image fills the screen in both directions (no bars), but does not crop (fit inside)
var baslamaScale = Math.max(screenW / baslamaOrigW, screenH / baslamaOrigH);
var baslamaWidth = baslamaOrigW * baslamaScale;
var baslamaHeight = baslamaOrigH * baslamaScale;
// Center the image
var baslamaImg = LK.getAsset('baslama', {
anchorX: 0.5,
anchorY: 0.5,
x: screenW / 2,
y: screenH / 2,
width: baslamaWidth,
height: baslamaHeight
});
startScreen.addChild(baslamaImg);
game.addChild(startScreen);
// Always bring startScreen to top after all children are added
game.setChildIndex(startScreen, game.children.length - 1);
// Hide or show all UI and tiles except baslama image
function setGameUIVisible(visible) {
// Show/hide all UI and tiles except baslama image
if (scoreTxt) scoreTxt.visible = visible;
if (levelTxt) levelTxt.visible = visible;
if (timerTxt) timerTxt.visible = visible;
if (instructionTxt) instructionTxt.visible = visible;
if (typeof tiles !== "undefined" && tiles && tiles.length) {
for (var i = 0; i < tiles.length; i++) {
if (tiles[i]) {
tiles[i].visible = visible;
if (tiles[i].children && tiles[i].children.length > 0) {
for (var j = 0; j < tiles[i].children.length; j++) {
tiles[i].children[j].visible = visible;
}
}
}
}
}
// Only show baslama image if visible is false (start screen)
if (typeof startScreen !== "undefined" && startScreen) startScreen.visible = !visible;
}
// On load, show only baslama image and hide everything else
setGameUIVisible(false);
// Start button event (tap anywhere on baslama image)
baslamaImg.down = function (x, y, obj) {
// Hide baslama image, show all UI and tiles
setGameUIVisible(true);
// Make sure baslama image is not on top anymore
if (typeof startScreen !== "undefined" && startScreen && startScreen.parent) {
startScreen.parent.setChildIndex(startScreen, 0);
}
startGame();
};
// --- CONFIGURATION ---
var GRID_SIZE = 2; // 2x2 grid (classic Simon style)
var TILE_GAP = 120; // px gap between tiles - increased spacing
var TILE_SIZE = 500; // px, will be scaled for iPad Pro - larger tiles
var TILE_COLORS = [0xff3b30, 0x34c759, 0x007aff, 0xffcc00]; // red, green, blue, yellow
var TILE_HIGHLIGHT = [0xff8880, 0x88ffb0, 0x80b0ff, 0xfff680]; // lighter highlight for each color
var SEQUENCE_START_LENGTH = 3;
var SEQUENCE_GROWTH = 1;
var SEQUENCE_MAX_LENGTH = 100;
var SHOW_STEP_BASE_DURATION = 500; // ms, will get faster
var SHOW_STEP_MIN_DURATION = 200; // ms
var INPUT_TIME_LIMIT = 5000; // ms per sequence (decreases as level increases)
var TILE_FLASH_FEEDBACK = 250; // ms
// --- ASSETS ---
for (var i = 0; i < TILE_COLORS.length; i++) {}
// generic, color set later
// --- STATE ---
var tiles = []; // array of Tile instances
var sequence = []; // array of tile indices (the pattern to repeat)
var playerInput = []; // array of tile indices (player's taps)
var currentStep = 0; // which step in the sequence is being shown
var showingSequence = false;
var inputTimer = null;
var inputTimeLeft = 0;
var level = 1;
var inputEnabled = false;
var score = 0;
// --- UI ---
// Text UI is created only after the game starts, not on the baslama screen
var scoreTxt, levelTxt, timerTxt, instructionTxt;
// --- GAME LOGIC ---
// Helper: center grid on screen
function getTilePos(row, col) {
var gridW = GRID_SIZE * TILE_SIZE + (GRID_SIZE - 1) * TILE_GAP;
var gridH = GRID_SIZE * TILE_SIZE + (GRID_SIZE - 1) * TILE_GAP;
var startX = (2048 - gridW) / 2 + TILE_SIZE / 2;
var startY = (2732 - gridH) / 2 + TILE_SIZE / 2 + 100; // +100 to avoid top menu
return {
x: startX + col * (TILE_SIZE + TILE_GAP),
y: startY + row * (TILE_SIZE + TILE_GAP)
};
}
// Create grid of tiles
for (var row = 0; row < GRID_SIZE; row++) {
for (var col = 0; col < GRID_SIZE; col++) {
var idx = row * GRID_SIZE + col;
var tile = new Tile();
tile.tileIndex = idx;
tile.setImage(idx); // Set the melody image for this tile
var pos = getTilePos(row, col);
tile.x = pos.x;
tile.y = pos.y;
tiles.push(tile);
game.addChild(tile);
}
}
// --- GAME STATE MANAGEMENT ---
// Start a new game
function startGame() {
sequence = [];
playerInput = [];
currentStep = 0;
showingSequence = false;
level = 1;
score = 0;
inputEnabled = false;
// Create text UI now (after baslama image is hidden)
if (!scoreTxt) {
scoreTxt = new Text2('0', {
size: 140,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif",
fontWeight: 'bold'
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
}
if (!levelTxt) {
levelTxt = new Text2('Level 1', {
size: 90,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif",
fontWeight: 'bold'
});
levelTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(levelTxt);
levelTxt.y = 130;
}
if (!timerTxt) {
timerTxt = new Text2('', {
size: 90,
fill: 0xFFCC00,
font: "'Arial Black', 'Helvetica-Bold', sans-serif",
fontWeight: 'bold'
});
timerTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(timerTxt);
timerTxt.y = 230;
}
if (!instructionTxt) {
instructionTxt = new Text2('Watch the sequence!', {
size: 80,
fill: 0xFFFFFF,
font: "'Arial Black', 'Helvetica-Bold', sans-serif",
fontWeight: 'bold'
});
instructionTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionTxt);
instructionTxt.y = 330;
}
updateScore();
updateLevel();
nextRound();
}
// Start next round (add to sequence, show it)
function nextRound() {
playerInput = [];
inputEnabled = false;
// Add new random tile to sequence
if (sequence.length < SEQUENCE_MAX_LENGTH) {
for (var i = 0; i < SEQUENCE_GROWTH; i++) {
var nextIdx = Math.floor(Math.random() * tiles.length);
sequence.push(nextIdx);
}
}
currentStep = 0;
showSequence();
}
// Show the sequence to the player
function showSequence() {
showingSequence = true;
inputEnabled = false;
instructionTxt.setText('Watch the sequence!');
var stepDuration = Math.max(SHOW_STEP_BASE_DURATION - (level - 1) * 30, SHOW_STEP_MIN_DURATION);
// Helper: show all tile images (make visible when game starts)
function showAllTiles() {
for (var i = 0; i < tiles.length; i++) {
tiles[i].visible = true;
if (tiles[i].children.length > 0) {
for (var j = 0; j < tiles[i].children.length; j++) {
tiles[i].children[j].visible = true;
}
}
}
}
// Always show all tiles before sequence
showAllTiles();
function showStep(step) {
if (step >= sequence.length) {
showingSequence = false;
// Do NOT hide tiles for memory challenge; keep them visible
enableInput();
return;
}
var idx = sequence[step];
// More pronounced visual feedback during sequence showing
var tile = tiles[idx];
// Scale up the tile to make it more obvious
tween(tile, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: stepDuration / 3,
easing: tween.easeOut,
onFinish: function onFinish() {
// Scale back down
tween(tile, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: stepDuration / 3,
easing: tween.easeIn,
onFinish: function onFinish() {
LK.setTimeout(function () {
showStep(step + 1);
}, 100);
}
});
}
});
// Also keep the flash effect
tiles[idx].flash(stepDuration, TILE_HIGHLIGHT[idx], function () {
// Flash completed
});
}
showStep(0);
}
// Enable player input
function enableInput() {
inputEnabled = true;
game.inputEnabled = true;
instructionTxt.setText('Repeat the sequence!');
inputTimeLeft = Math.max(INPUT_TIME_LIMIT - (level - 1) * 200, 2000);
updateTimerText();
if (inputTimer) {
LK.clearInterval(inputTimer);
}
inputTimer = LK.setInterval(function () {
inputTimeLeft -= 100;
updateTimerText();
if (inputTimeLeft <= 0) {
inputEnabled = false;
game.inputEnabled = false;
LK.clearInterval(inputTimer);
inputTimer = null;
failSequence();
}
}, 100);
}
// Handle player tapping a tile
game.handleTileTap = function (tileIdx) {
if (!inputEnabled || showingSequence) return;
playerInput.push(tileIdx);
// Play sound effect immediately when tapped
var soundNames = ['do', 're', 'mi', 'fa'];
if (tileIdx >= 0 && tileIdx < soundNames.length) {
LK.getSound(soundNames[tileIdx]).play();
}
// Flash feedback (no hiding/showing, just flash effect)
tiles[tileIdx].flash(TILE_FLASH_FEEDBACK, TILE_HIGHLIGHT[tileIdx], function () {
// No need to hide or show tile images; always visible
});
// Check correctness
var expected = sequence[playerInput.length - 1];
if (tileIdx !== expected) {
inputEnabled = false;
game.inputEnabled = false;
if (inputTimer) {
LK.clearInterval(inputTimer);
inputTimer = null;
}
// Play wrong answer sound
LK.getSound('zort').play();
// Flash red
LK.effects.flashScreen(0xff0000, 800);
LK.setTimeout(function () {
LK.showGameOver();
}, 800);
return;
}
// If correct and finished input
if (playerInput.length === sequence.length) {
if (inputTimer) {
LK.clearInterval(inputTimer);
inputTimer = null;
}
// Play success sound
LK.getSound('yes').play();
// Success! Increase score, level, and go to next round
score += sequence.length;
level += 1;
updateScore();
updateLevel();
// Flash green
LK.effects.flashScreen(0x00ff00, 400);
LK.setTimeout(function () {
nextRound();
}, 500);
}
};
// Player failed to input in time
function failSequence() {
inputEnabled = false;
game.inputEnabled = false;
// Play wrong answer sound
LK.getSound('zort').play();
// Flash red
LK.effects.flashScreen(0xff0000, 800);
LK.setTimeout(function () {
LK.showGameOver();
}, 800);
}
// Update score display
function updateScore() {
scoreTxt.setText(score);
LK.setScore(score);
}
// Update level display
function updateLevel() {
levelTxt.setText('Level ' + level);
}
// Update timer display
function updateTimerText() {
if (!inputEnabled) {
timerTxt.setText('');
return;
}
var sec = Math.ceil(inputTimeLeft / 100) / 10;
timerTxt.setText(sec.toFixed(1) + 's');
}
// --- BACKGROUND MUSIC ---
LK.playMusic('piano');
// --- GAME EVENT HOOKS ---
// On game reset, show only baslama image and hide all UI
game.on('reset', function () {
setGameUIVisible(false);
// Bring baslama image to front again after reset
if (typeof startScreen !== "undefined" && startScreen && startScreen.parent) {
startScreen.parent.setChildIndex(startScreen, startScreen.parent.children.length - 1);
}
});
// --- DRAGGING DISABLED ---
// No dragging or move events needed for this game
// --- WIN CONDITION ---
// If player reaches max sequence length, show win
function checkWin() {
if (sequence.length >= SEQUENCE_MAX_LENGTH) {
LK.effects.flashScreen(0x00ff00, 1000);
LK.setTimeout(function () {
LK.showYouWin();
}, 1000);
}
}
// --- GAME UPDATE LOOP ---
game.update = function () {
// Nothing needed here for this game
// Timer is handled by inputTimer
// Could check for win
checkWin();
// Always bring baslama image to top if visible
if (typeof startScreen !== "undefined" && startScreen && startScreen.visible && startScreen.parent) {
startScreen.parent.setChildIndex(startScreen, startScreen.parent.children.length - 1);
}
};
START BUTTON. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A single glowing blue melody symbol in the center, surrounded by soft blue light, abstract sound waves gently radiating outward, dreamy and minimalistic background, magical atmosphere, high contrast lighting, perfect for a music-themed game, 4K, highly detailed. In-Game asset. 2d. High contrast. No shadows
A single glowing green melody symbol in the center, surrounded by soft blue light, abstract sound waves gently radiating outward, dreamy and minimalistic background, magical atmosphere, high contrast lighting, perfect for a music-themed game, 4K, highly detailed. In-Game asset. 2d. High contrast. No shadows
A single glowing red melody symbol in the center, surrounded by soft blue light, abstract sound waves gently radiating outward, dreamy and minimalistic background, magical atmosphere, high contrast lighting, perfect for a music-themed game, 4K, highly detailed. In-Game asset. 2d. High contrast. No shadows
A single glowing yellow melody symbol in the center, surrounded by soft blue light, abstract sound waves gently radiating outward, dreamy and minimalistic background, magical atmosphere, high contrast lighting, perfect for a music-themed game, 4K, highly detailed. In-Game asset. 2d. High contrast. No shadows
A vertical 9:16 mobile game start screen for a music-themed game called "Melody Memory". A glowing blue melody symbol floats in the center, with dreamy blue and purple gradient background. Soft abstract sound waves and light particles surround the symbol. At the top, stylish title text "Melody Memory" in elegant font. In the center, a prominent "Start Game" button with a glowing, rounded design. At the bottom, soft hint text saying "Tap to Start". Futuristic, minimalistic, high contrast, cinematic lighting, 4K, high quality, mobile UI friendly.. In-Game asset. 2d. High contrast. No shadows