User prompt
ismimi giremiyorum buton ekle
User prompt
hiç bişi yapma sadece ismini gir yerine tıklayıp kendi ismimi yazabileyim
User prompt
o zaman kaydetmesin ismimi giremiyorum tıklanmıyor
User prompt
Please fix the bug: 'The supplied DisplayObject must be a child of the caller' in or related to this line: 'game.setChildIndex(nameInfo, game.children.length - 1);' Line Number: 204
User prompt
visible hatalarını sil
User prompt
Please fix the bug: 'The supplied DisplayObject must be a child of the caller' in or related to this line: 'game.setChildIndex(nameInputBtn, game.children.length - 1);' Line Number: 209
User prompt
Please fix the bug: 'hideAllMiniGames is not defined' in or related to this line: 'hideAllMiniGames();' Line Number: 207
User prompt
bütün oyunları sil
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < mini4Obstacles.length; i++) {' Line Number: 691
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < mini2Coins.length; i++) {' Line Number: 596
User prompt
Fix all the mistakes in 1 minute, if you can't fix them, delete them
User prompt
oyunun yüklenme menüsüne Welcome yazısı ekle
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInfo.visible = false;' Line Number: 466
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = false;' Line Number: 461
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInfo.visible = true;' Line Number: 366
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = true;' Line Number: 363
User prompt
bütün hata yapan şeyleri sil
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInfo.visible = false;' Line Number: 468
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInfo.visible = false;' Line Number: 468
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = false;' Line Number: 461
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = false;' Line Number: 459
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = false;' Line Number: 459
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = false;' Line Number: 456
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = false;' Line Number: 459
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'visible')' in or related to this line: 'nameInputBtn.visible = false;' Line Number: 456
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // --- Mini Game 4: Araba Sürme (Dodge Obstacles) --- var Car = Container.expand(function () { var self = Container.call(this); var car = self.attachAsset('car', { width: 180, height: 320, color: 0x0077b6, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.car = car; return self; }); var CarObstacle = Container.expand(function () { var self = Container.call(this); var obs = self.attachAsset('carObs', { width: 180, height: 180, color: 0x22223b, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); self.obs = obs; return self; }); // --- Mini Game 6: Sürpriz Oyun (Memory: Tap the Shown Box) --- var MemoryBox = Container.expand(function () { var self = Container.call(this); var box = self.attachAsset('memoryBox', { width: 200, height: 200, color: 0x8ac926, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.box = box; self.down = function (x, y, obj) { if (self.onTap) self.onTap(); }; return self; }); // --- Main Menu Button Class --- var MenuButton = Container.expand(function () { var self = Container.call(this); var btnWidth = 700; var btnHeight = 180; var bg = self.attachAsset('menuBtnBg', { width: btnWidth, height: btnHeight, color: 0x2d2d2d, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.bg = bg; var label = new Text2('', { size: 80, fill: "#fff" }); label.anchor.set(0.5, 0.5); self.addChild(label); self.label = label; self.setText = function (txt) { label.setText(txt); }; self.setColor = function (color) { bg.color = color; }; self.down = function (x, y, obj) { if (self.onClick) self.onClick(); }; return self; }); // --- Name Input Button (for name selection) --- var NameInputButton = Container.expand(function () { var self = Container.call(this); var btnWidth = 900; var btnHeight = 200; var bg = self.attachAsset('nameInputBg', { width: btnWidth, height: btnHeight, color: 0x3a3a3a, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.bg = bg; var label = new Text2('İsmini Gir: ', { size: 80, fill: "#fff" }); label.anchor.set(0, 0.5); label.x = -btnWidth / 2 + 40; self.addChild(label); var nameText = new Text2('', { size: 80, fill: 0xFFE066 }); nameText.anchor.set(0, 0.5); nameText.x = label.x + 420; self.addChild(nameText); self.nameText = nameText; self.setName = function (txt) { nameText.setText(txt); }; self.down = function (x, y, obj) { if (self.onClick) self.onClick(); }; return self; }); // --- Mini Game 2: Rol Yapma (RPG: Tap to Collect Coins) --- var RPGCoin = Container.expand(function () { var self = Container.call(this); var coin = self.attachAsset('rpgCoin', { width: 120, height: 120, color: 0xffd700, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); self.coin = coin; self.down = function (x, y, obj) { if (self.onCollect) self.onCollect(); self.destroy(); }; return self; }); // --- Mini Game 1: Savaş (Simple Tap to Hit) --- var SavasEnemy = Container.expand(function () { var self = Container.call(this); var enemy = self.attachAsset('savasEnemy', { width: 200, height: 200, color: 0xd83318, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); self.enemy = enemy; self.hp = 3; self.down = function (x, y, obj) { self.hp--; tween(enemy, { scaleX: 1.2, scaleY: 1.2 }, { duration: 80, onFinish: function onFinish() { tween(enemy, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); if (self.hp <= 0) { if (self.onDefeat) self.onDefeat(); self.destroy(); } }; return self; }); var SpaceBullet = Container.expand(function () { var self = Container.call(this); var bullet = self.attachAsset('spaceBullet', { width: 40, height: 80, color: 0xffffff, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.bullet = bullet; self.speed = -30; self.update = function () { self.y += self.speed; }; return self; }); var SpaceEnemy = Container.expand(function () { var self = Container.call(this); var enemy = self.attachAsset('spaceEnemy', { width: 120, height: 120, color: 0xff006e, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); self.enemy = enemy; return self; }); // --- Mini Game 5: Uzay Savaşı (Move & Shoot) --- var SpaceShip = Container.expand(function () { var self = Container.call(this); var ship = self.attachAsset('spaceship', { width: 160, height: 160, color: 0x00b4d8, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); self.ship = ship; return self; }); // --- Mini Game 3: Tycoon (Tap to Earn) --- var TycoonFactory = Container.expand(function () { var self = Container.call(this); var fac = self.attachAsset('tycoonFactory', { width: 300, height: 200, color: 0x6c757d, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.fac = fac; self.down = function (x, y, obj) { if (self.onProduce) self.onProduce(); tween(fac, { scaleX: 1.1, scaleY: 1.1 }, { duration: 60, onFinish: function onFinish() { tween(fac, { scaleX: 1, scaleY: 1 }, { duration: 60 }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff }); /**** * Game Code ****/ var playerName = storage.playerName || ''; var currentScreen = 'name'; // 'name', 'menu', 'mini1', ..., 'mini6' var miniGameScores = storage.miniGameScores || [0, 0, 0, 0, 0, 0]; // --- Loading Text --- var loadingText = new Text2('Yükleniyor', { size: 100, fill: "#000" }); loadingText.anchor.set(0.5, 0.5); loadingText.x = 2048 / 2; loadingText.y = 2732 / 2; game.addChild(loadingText); loadingText.visible = true; showNameScreen(); // --- GUI Elements --- var guiTitle = new Text2('', { size: 120, fill: "#fff" }); guiTitle.anchor.set(0.5, 0); guiTitle.visible = false; LK.gui.top.addChild(guiTitle); var guiScore = new Text2('', { size: 80, fill: 0xFFE066 }); guiScore.anchor.set(0.5, 0); guiScore.visible = false; LK.gui.top.addChild(guiScore); function showTitle(txt) { guiTitle.setText(txt); guiTitle.visible = true; } function hideTitle() { if (typeof guiTitle !== "undefined" && guiTitle) { guiTitle.visible = false; } } function showScore(txt) { guiScore.setText(txt); guiScore.visible = true; } function hideScore() { if (typeof guiScore !== "undefined" && guiScore) { guiScore.visible = false; } } // --- Name Selection Screen --- var nameInputBtn; if (typeof NameInputButton !== "undefined") { nameInputBtn = new NameInputButton(); nameInputBtn.x = 2048 / 2; nameInputBtn.y = 2732 / 2 - 100; nameInputBtn.setName(playerName); game.addChild(nameInputBtn); nameInputBtn.visible = false; } var nameInfo = new Text2('İsminizi girmek için butona dokunun.', { size: 60, fill: "#fff" }); nameInfo.anchor.set(0.5, 0); nameInfo.x = 2048 / 2; nameInfo.y = 2732 / 2 + 60; nameInfo.visible = false; game.addChild(nameInfo); function showNameScreen() { currentScreen = 'name'; if (typeof loadingText !== "undefined" && loadingText) { loadingText.visible = false; } if (nameInputBtn) { nameInputBtn.visible = true; } if (nameInfo) { nameInfo.visible = true; } hideTitle(); hideScore(); hideMenu(); hideAllMiniGames(); // Ensure name input is on top game.setChildIndex(nameInputBtn, game.children.length - 1); game.setChildIndex(nameInfo, game.children.length - 1); } function hideNameScreen() { nameInputBtn.visible = false; nameInfo.visible = false; } // --- Name Input Logic (simple prompt) --- nameInputBtn.onClick = function () { var newName = ''; if (typeof prompt === 'function') { newName = prompt('İsminizi girin:', playerName); } else { // Fallback for environments without prompt newName = 'Oyuncu'; } if (newName && newName.length > 0) { playerName = newName; storage.playerName = playerName; nameInputBtn.setName(playerName); showMenu(); } }; // --- Main Menu --- if (!menuButtons) { var menuButtons = []; } var menuTitles = ["Savaş (Düşmanı Yen!)", "Rol Yapma (Altın Topla!)", "Tycoon (Fabrika Kur!)", "Araba Sürme (Engellerden Kaç!)", "Uzay Savaşı (Düşmanları Vur!)", "Sürpriz Oyun (Hafıza Kutusu!)"]; function showMenu() { currentScreen = 'menu'; if (typeof loadingText !== "undefined" && loadingText) { loadingText.visible = false; } hideNameScreen(); hideAllMiniGames(); hideScore(); showTitle("Oyun Dünyası: 6'lı Macera"); // Remove old buttons if (!menuButtons) menuButtons = []; if (!menuButtons) menuButtons = []; if (!menuButtons) menuButtons = []; for (var i = 0; i < menuButtons.length; i++) { menuButtons[i].visible = false; menuButtons[i].destroy(); } menuButtons = []; // Create new buttons var startY = 700; for (var i = 0; i < 6; i++) { var btn = new MenuButton(); btn.x = 2048 / 2; btn.y = startY + i * 240; btn.setText(menuTitles[i]); btn.setColor(0x2d2d2d); btn.visible = true; // Ensure the button is displayed on top of other elements game.setChildIndex(btn, game.children.length - 1); btn.onClick = function (idx) { return function () { startMiniGame(idx + 1); }; }(i); game.addChild(btn); menuButtons.push(btn); } // Show name change button nameInputBtn.visible = true; nameInputBtn.y = 2732 - 300; nameInputBtn.setName(playerName); nameInfo.visible = false; game.setChildIndex(nameInputBtn, game.children.length - 1); } function hideMenu() { if (!menuButtons) menuButtons = []; for (var i = 0; i < menuButtons.length; i++) { menuButtons[i].visible = false; menuButtons[i].destroy(); } menuButtons = []; nameInputBtn.visible = false; nameInfo.visible = false; } // --- Mini Game Management --- function hideAllMiniGames() { hideMini1(); hideMini2(); hideMini3(); hideMini4(); hideMini5(); hideMini6(); } // --- Mini Game 1: Savaş (Tap to Defeat Enemy) --- var mini1Enemy = null; var mini1Score = 0; var mini1BackBtn = null; function startMiniGame1() { currentScreen = 'mini1'; hideMenu(); hideAllMiniGames(); showTitle("Savaş: Düşmanı Yen!"); mini1Score = 0; showScore("Skor: 0"); mini1Enemy = new SavasEnemy(); mini1Enemy.x = 2048 / 2; mini1Enemy.y = 2732 / 2; mini1Enemy.onDefeat = function () { mini1Score++; showScore("Skor: " + mini1Score); // Respawn enemy at random position mini1Enemy = new SavasEnemy(); mini1Enemy.x = 400 + Math.floor(Math.random() * 1200); mini1Enemy.y = 700 + Math.floor(Math.random() * 1600); mini1Enemy.onDefeat = arguments.callee; game.addChild(mini1Enemy); game.setChildIndex(mini1Enemy, game.children.length - 1); }; game.addChild(mini1Enemy); game.setChildIndex(mini1Enemy, game.children.length - 1); // Back to menu button mini1BackBtn = new MenuButton(); mini1BackBtn.x = 2048 / 2; mini1BackBtn.y = 2732 - 200; mini1BackBtn.setText("Ana Menüye Dön"); mini1BackBtn.setColor(0x444444); mini1BackBtn.onClick = function () { miniGameScores[0] = mini1Score; storage.miniGameScores = miniGameScores; showMenu(); }; game.addChild(mini1BackBtn); game.setChildIndex(mini1BackBtn, game.children.length - 1); } function hideMini1() { if (mini1Enemy) { mini1Enemy.destroy(); mini1Enemy = null; } if (mini1BackBtn) { mini1BackBtn.destroy(); mini1BackBtn = null; } hideScore(); } // --- Mini Game 2: Rol Yapma (Tap to Collect Coins) --- var mini2Coins = []; var mini2Score = 0; var mini2BackBtn = null; function startMiniGame2() { currentScreen = 'mini2'; hideMenu(); hideAllMiniGames(); showTitle("Rol Yapma: Altın Topla!"); mini2Score = 0; showScore("Altın: 0"); mini2Coins = []; for (var i = 0; i < 5; i++) { var coin = new RPGCoin(); coin.x = 300 + Math.floor(Math.random() * 1400); coin.y = 600 + Math.floor(Math.random() * 1800); coin.onCollect = function (coinObj) { return function () { mini2Score++; showScore("Altın: " + mini2Score); coinObj.destroy(); // Spawn new coin var newCoin = new RPGCoin(); newCoin.x = 300 + Math.floor(Math.random() * 1400); newCoin.y = 600 + Math.floor(Math.random() * 1800); newCoin.onCollect = arguments.callee; game.addChild(newCoin); game.setChildIndex(newCoin, game.children.length - 1); mini2Coins.push(newCoin); }; }(coin); game.addChild(coin); game.setChildIndex(coin, game.children.length - 1); mini2Coins.push(coin); } mini2BackBtn = new MenuButton(); mini2BackBtn.x = 2048 / 2; mini2BackBtn.y = 2732 - 200; mini2BackBtn.setText("Ana Menüye Dön"); mini2BackBtn.setColor(0x444444); mini2BackBtn.onClick = function () { miniGameScores[1] = mini2Score; storage.miniGameScores = miniGameScores; showMenu(); }; game.addChild(mini2BackBtn); game.setChildIndex(mini2BackBtn, game.children.length - 1); } function hideMini2() { for (var i = 0; i < mini2Coins.length; i++) { mini2Coins[i].destroy(); } mini2Coins = []; if (mini2BackBtn) { mini2BackBtn.destroy(); mini2BackBtn = null; } hideScore(); } // --- Mini Game 3: Tycoon (Tap to Produce) --- var mini3Factory = null; var mini3Score = 0; var mini3BackBtn = null; function startMiniGame3() { currentScreen = 'mini3'; hideMenu(); hideAllMiniGames(); showTitle("Tycoon: Fabrika Kur!"); mini3Score = 0; showScore("Para: 0"); mini3Factory = new TycoonFactory(); mini3Factory.x = 2048 / 2; mini3Factory.y = 2732 / 2; mini3Factory.onProduce = function () { mini3Score += 10; showScore("Para: " + mini3Score); }; game.addChild(mini3Factory); game.setChildIndex(mini3Factory, game.children.length - 1); mini3BackBtn = new MenuButton(); mini3BackBtn.x = 2048 / 2; mini3BackBtn.y = 2732 - 200; mini3BackBtn.setText("Ana Menüye Dön"); mini3BackBtn.setColor(0x444444); mini3BackBtn.onClick = function () { miniGameScores[2] = mini3Score; storage.miniGameScores = miniGameScores; showMenu(); }; game.addChild(mini3BackBtn); game.setChildIndex(mini3BackBtn, game.children.length - 1); } function hideMini3() { if (mini3Factory) { mini3Factory.destroy(); mini3Factory = null; } if (mini3BackBtn) { mini3BackBtn.destroy(); mini3BackBtn = null; } hideScore(); } // --- Mini Game 4: Araba Sürme (Dodge Obstacles) --- var mini4Car = null; var mini4Obstacles = []; var mini4Score = 0; var mini4BackBtn = null; var mini4GameOver = false; function startMiniGame4() { currentScreen = 'mini4'; hideMenu(); hideAllMiniGames(); showTitle("Araba Sürme: Engellerden Kaç!"); mini4Score = 0; showScore("Skor: 0"); mini4GameOver = false; mini4Obstacles = []; mini4Car = new Car(); mini4Car.x = 2048 / 2; mini4Car.y = 2732 - 400; game.addChild(mini4Car); game.setChildIndex(mini4Car, game.children.length - 1); mini4BackBtn = new MenuButton(); mini4BackBtn.x = 2048 / 2; mini4BackBtn.y = 2732 - 200; mini4BackBtn.setText("Ana Menüye Dön"); mini4BackBtn.setColor(0x444444); mini4BackBtn.onClick = function () { miniGameScores[3] = mini4Score; storage.miniGameScores = miniGameScores; showMenu(); }; game.addChild(mini4BackBtn); game.setChildIndex(mini4BackBtn, game.children.length - 1); } function hideMini4() { if (mini4Car) { mini4Car.destroy(); mini4Car = null; } for (var i = 0; i < mini4Obstacles.length; i++) { mini4Obstacles[i].destroy(); } mini4Obstacles = []; if (mini4BackBtn) { mini4BackBtn.destroy(); mini4BackBtn = null; } hideScore(); } // --- Mini Game 5: Uzay Savaşı (Move & Shoot) --- var mini5Ship = null; var mini5Enemies = []; var mini5Bullets = []; var mini5Score = 0; var mini5BackBtn = null; function startMiniGame5() { currentScreen = 'mini5'; hideMenu(); hideAllMiniGames(); showTitle("Uzay Savaşı: Düşmanları Vur!"); mini5Score = 0; showScore("Skor: 0"); mini5Enemies = []; mini5Bullets = []; mini5Ship = new SpaceShip(); mini5Ship.x = 2048 / 2; mini5Ship.y = 2732 - 400; game.addChild(mini5Ship); game.setChildIndex(mini5Ship, game.children.length - 1); mini5BackBtn = new MenuButton(); mini5BackBtn.x = 2048 / 2; mini5BackBtn.y = 2732 - 200; mini5BackBtn.setText("Ana Menüye Dön"); mini5BackBtn.setColor(0x444444); mini5BackBtn.onClick = function () { miniGameScores[4] = mini5Score; storage.miniGameScores = miniGameScores; showMenu(); }; game.addChild(mini5BackBtn); game.setChildIndex(mini5BackBtn, game.children.length - 1); } function hideMini5() { if (mini5Ship) { mini5Ship.destroy(); mini5Ship = null; } for (var i = 0; i < mini5Enemies.length; i++) { mini5Enemies[i].destroy(); } mini5Enemies = []; for (var i = 0; i < mini5Bullets.length; i++) { mini5Bullets[i].destroy(); } mini5Bullets = []; if (mini5BackBtn) { mini5BackBtn.destroy(); mini5BackBtn = null; } hideScore(); } // --- Mini Game 6: Sürpriz Oyun (Memory: Tap the Shown Box) --- var mini6Boxes = []; var mini6TargetIdx = 0; var mini6Score = 0; var mini6BackBtn = null; var mini6ShowTimer = null; function startMiniGame6() { currentScreen = 'mini6'; hideMenu(); hideAllMiniGames(); showTitle("Sürpriz Oyun: Hafıza Kutusu!"); mini6Score = 0; showScore("Skor: 0"); mini6Boxes = []; var boxPositions = [[600, 1000], [1448, 1000], [600, 1800], [1448, 1800]]; for (var i = 0; i < 4; i++) { var box = new MemoryBox(); box.x = boxPositions[i][0]; box.y = boxPositions[i][1]; box.visible = false; box.onTap = function (idx) { return function () { if (idx === mini6TargetIdx) { mini6Score++; showScore("Skor: " + mini6Score); showNextMemoryBox(); } else { // Wrong box, reset score mini6Score = 0; showScore("Skor: 0"); showNextMemoryBox(); } }; }(i); game.addChild(box); game.setChildIndex(box, game.children.length - 1); mini6Boxes.push(box); } showNextMemoryBox(); mini6BackBtn = new MenuButton(); mini6BackBtn.x = 2048 / 2; mini6BackBtn.y = 2732 - 200; mini6BackBtn.setText("Ana Menüye Dön"); mini6BackBtn.setColor(0x444444); mini6BackBtn.onClick = function () { miniGameScores[5] = mini6Score; storage.miniGameScores = miniGameScores; showMenu(); }; game.addChild(mini6BackBtn); game.setChildIndex(mini6BackBtn, game.children.length - 1); } function showNextMemoryBox() { for (var i = 0; i < mini6Boxes.length; i++) { mini6Boxes[i].visible = false; } mini6TargetIdx = Math.floor(Math.random() * 4); mini6Boxes[mini6TargetIdx].visible = true; } function hideMini6() { for (var i = 0; i < mini6Boxes.length; i++) { mini6Boxes[i].destroy(); } mini6Boxes = []; if (mini6BackBtn) { mini6BackBtn.destroy(); mini6BackBtn = null; } hideScore(); } // --- Mini Game Starters --- function startMiniGame(idx) { if (idx === 1) startMiniGame1();else if (idx === 2) startMiniGame2();else if (idx === 3) startMiniGame3();else if (idx === 4) startMiniGame4();else if (idx === 5) startMiniGame5();else if (idx === 6) startMiniGame6(); } // --- Game Move Handlers (for mini games that need it) --- var dragCar = false; var dragShip = false; game.move = function (x, y, obj) { if (currentScreen === 'mini4' && mini4Car && !mini4GameOver) { // Move car horizontally only mini4Car.x = Math.max(200, Math.min(2048 - 200, x)); } if (currentScreen === 'mini5' && mini5Ship) { mini5Ship.x = Math.max(100, Math.min(2048 - 100, x)); } }; game.down = function (x, y, obj) { if (currentScreen === 'mini4' && mini4Car && !mini4GameOver) { dragCar = true; mini4Car.x = Math.max(200, Math.min(2048 - 200, x)); } if (currentScreen === 'mini5' && mini5Ship) { dragShip = true; mini5Ship.x = Math.max(100, Math.min(2048 - 100, x)); } }; game.up = function (x, y, obj) { dragCar = false; dragShip = false; }; // --- Game Update Loop --- game.update = function () { // Mini Game 4: Araba Sürme (Obstacles) if (currentScreen === 'mini4' && mini4Car && !mini4GameOver) { // Spawn obstacles if (LK.ticks % 40 === 0) { var obs = new CarObstacle(); obs.x = 300 + Math.floor(Math.random() * 1400); obs.y = -100; mini4Obstacles.push(obs); game.addChild(obs); game.setChildIndex(obs, game.children.length - 1); } // Move obstacles for (var i = mini4Obstacles.length - 1; i >= 0; i--) { var obs = mini4Obstacles[i]; obs.y += 28; if (obs.y > 2732 + 100) { obs.destroy(); mini4Obstacles.splice(i, 1); mini4Score++; showScore("Skor: " + mini4Score); } else if (obs.intersects(mini4Car)) { mini4GameOver = true; LK.effects.flashScreen(0xff0000, 800); miniGameScores[3] = mini4Score; storage.miniGameScores = miniGameScores; setTimeout(function () { showMenu(); }, 900); } } } // Mini Game 5: Uzay Savaşı (Enemies & Bullets) if (currentScreen === 'mini5' && mini5Ship) { // Spawn enemies if (LK.ticks % 50 === 0) { var enemy = new SpaceEnemy(); enemy.x = 200 + Math.floor(Math.random() * 1648); enemy.y = -100; mini5Enemies.push(enemy); game.addChild(enemy); game.setChildIndex(enemy, game.children.length - 1); } // Move enemies for (var i = mini5Enemies.length - 1; i >= 0; i--) { var enemy = mini5Enemies[i]; enemy.y += 18; if (enemy.y > 2732 + 100) { enemy.destroy(); mini5Enemies.splice(i, 1); } else if (enemy.intersects(mini5Ship)) { LK.effects.flashScreen(0xff0000, 800); miniGameScores[4] = mini5Score; storage.miniGameScores = miniGameScores; setTimeout(function () { showMenu(); }, 900); } } // Fire bullets if (LK.ticks % 20 === 0) { var bullet = new SpaceBullet(); bullet.x = mini5Ship.x; bullet.y = mini5Ship.y - 90; mini5Bullets.push(bullet); game.addChild(bullet); game.setChildIndex(bullet, game.children.length - 1); } // Move bullets for (var i = mini5Bullets.length - 1; i >= 0; i--) { var bullet = mini5Bullets[i]; bullet.update(); if (bullet.y < -100) { bullet.destroy(); mini5Bullets.splice(i, 1); } else { // Check collision with enemies for (var j = mini5Enemies.length - 1; j >= 0; j--) { var enemy = mini5Enemies[j]; if (bullet.intersects(enemy)) { bullet.destroy(); enemy.destroy(); mini5Bullets.splice(i, 1); mini5Enemies.splice(j, 1); mini5Score++; showScore("Skor: " + mini5Score); break; } } } } } }; // --- Initial Screen --- if (!playerName || playerName.length === 0) { showNameScreen(); hideMenu(); } else { showMenu(); }
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// --- Mini Game 4: Araba Sürme (Dodge Obstacles) ---
var Car = Container.expand(function () {
var self = Container.call(this);
var car = self.attachAsset('car', {
width: 180,
height: 320,
color: 0x0077b6,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.car = car;
return self;
});
var CarObstacle = Container.expand(function () {
var self = Container.call(this);
var obs = self.attachAsset('carObs', {
width: 180,
height: 180,
color: 0x22223b,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.obs = obs;
return self;
});
// --- Mini Game 6: Sürpriz Oyun (Memory: Tap the Shown Box) ---
var MemoryBox = Container.expand(function () {
var self = Container.call(this);
var box = self.attachAsset('memoryBox', {
width: 200,
height: 200,
color: 0x8ac926,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.box = box;
self.down = function (x, y, obj) {
if (self.onTap) self.onTap();
};
return self;
});
// --- Main Menu Button Class ---
var MenuButton = Container.expand(function () {
var self = Container.call(this);
var btnWidth = 700;
var btnHeight = 180;
var bg = self.attachAsset('menuBtnBg', {
width: btnWidth,
height: btnHeight,
color: 0x2d2d2d,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.bg = bg;
var label = new Text2('', {
size: 80,
fill: "#fff"
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.label = label;
self.setText = function (txt) {
label.setText(txt);
};
self.setColor = function (color) {
bg.color = color;
};
self.down = function (x, y, obj) {
if (self.onClick) self.onClick();
};
return self;
});
// --- Name Input Button (for name selection) ---
var NameInputButton = Container.expand(function () {
var self = Container.call(this);
var btnWidth = 900;
var btnHeight = 200;
var bg = self.attachAsset('nameInputBg', {
width: btnWidth,
height: btnHeight,
color: 0x3a3a3a,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.bg = bg;
var label = new Text2('İsmini Gir: ', {
size: 80,
fill: "#fff"
});
label.anchor.set(0, 0.5);
label.x = -btnWidth / 2 + 40;
self.addChild(label);
var nameText = new Text2('', {
size: 80,
fill: 0xFFE066
});
nameText.anchor.set(0, 0.5);
nameText.x = label.x + 420;
self.addChild(nameText);
self.nameText = nameText;
self.setName = function (txt) {
nameText.setText(txt);
};
self.down = function (x, y, obj) {
if (self.onClick) self.onClick();
};
return self;
});
// --- Mini Game 2: Rol Yapma (RPG: Tap to Collect Coins) ---
var RPGCoin = Container.expand(function () {
var self = Container.call(this);
var coin = self.attachAsset('rpgCoin', {
width: 120,
height: 120,
color: 0xffd700,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.coin = coin;
self.down = function (x, y, obj) {
if (self.onCollect) self.onCollect();
self.destroy();
};
return self;
});
// --- Mini Game 1: Savaş (Simple Tap to Hit) ---
var SavasEnemy = Container.expand(function () {
var self = Container.call(this);
var enemy = self.attachAsset('savasEnemy', {
width: 200,
height: 200,
color: 0xd83318,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.enemy = enemy;
self.hp = 3;
self.down = function (x, y, obj) {
self.hp--;
tween(enemy, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 80,
onFinish: function onFinish() {
tween(enemy, {
scaleX: 1,
scaleY: 1
}, {
duration: 80
});
}
});
if (self.hp <= 0) {
if (self.onDefeat) self.onDefeat();
self.destroy();
}
};
return self;
});
var SpaceBullet = Container.expand(function () {
var self = Container.call(this);
var bullet = self.attachAsset('spaceBullet', {
width: 40,
height: 80,
color: 0xffffff,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.bullet = bullet;
self.speed = -30;
self.update = function () {
self.y += self.speed;
};
return self;
});
var SpaceEnemy = Container.expand(function () {
var self = Container.call(this);
var enemy = self.attachAsset('spaceEnemy', {
width: 120,
height: 120,
color: 0xff006e,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.enemy = enemy;
return self;
});
// --- Mini Game 5: Uzay Savaşı (Move & Shoot) ---
var SpaceShip = Container.expand(function () {
var self = Container.call(this);
var ship = self.attachAsset('spaceship', {
width: 160,
height: 160,
color: 0x00b4d8,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.ship = ship;
return self;
});
// --- Mini Game 3: Tycoon (Tap to Earn) ---
var TycoonFactory = Container.expand(function () {
var self = Container.call(this);
var fac = self.attachAsset('tycoonFactory', {
width: 300,
height: 200,
color: 0x6c757d,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.fac = fac;
self.down = function (x, y, obj) {
if (self.onProduce) self.onProduce();
tween(fac, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 60,
onFinish: function onFinish() {
tween(fac, {
scaleX: 1,
scaleY: 1
}, {
duration: 60
});
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xffffff
});
/****
* Game Code
****/
var playerName = storage.playerName || '';
var currentScreen = 'name'; // 'name', 'menu', 'mini1', ..., 'mini6'
var miniGameScores = storage.miniGameScores || [0, 0, 0, 0, 0, 0];
// --- Loading Text ---
var loadingText = new Text2('Yükleniyor', {
size: 100,
fill: "#000"
});
loadingText.anchor.set(0.5, 0.5);
loadingText.x = 2048 / 2;
loadingText.y = 2732 / 2;
game.addChild(loadingText);
loadingText.visible = true;
showNameScreen();
// --- GUI Elements ---
var guiTitle = new Text2('', {
size: 120,
fill: "#fff"
});
guiTitle.anchor.set(0.5, 0);
guiTitle.visible = false;
LK.gui.top.addChild(guiTitle);
var guiScore = new Text2('', {
size: 80,
fill: 0xFFE066
});
guiScore.anchor.set(0.5, 0);
guiScore.visible = false;
LK.gui.top.addChild(guiScore);
function showTitle(txt) {
guiTitle.setText(txt);
guiTitle.visible = true;
}
function hideTitle() {
if (typeof guiTitle !== "undefined" && guiTitle) {
guiTitle.visible = false;
}
}
function showScore(txt) {
guiScore.setText(txt);
guiScore.visible = true;
}
function hideScore() {
if (typeof guiScore !== "undefined" && guiScore) {
guiScore.visible = false;
}
}
// --- Name Selection Screen ---
var nameInputBtn;
if (typeof NameInputButton !== "undefined") {
nameInputBtn = new NameInputButton();
nameInputBtn.x = 2048 / 2;
nameInputBtn.y = 2732 / 2 - 100;
nameInputBtn.setName(playerName);
game.addChild(nameInputBtn);
nameInputBtn.visible = false;
}
var nameInfo = new Text2('İsminizi girmek için butona dokunun.', {
size: 60,
fill: "#fff"
});
nameInfo.anchor.set(0.5, 0);
nameInfo.x = 2048 / 2;
nameInfo.y = 2732 / 2 + 60;
nameInfo.visible = false;
game.addChild(nameInfo);
function showNameScreen() {
currentScreen = 'name';
if (typeof loadingText !== "undefined" && loadingText) {
loadingText.visible = false;
}
if (nameInputBtn) {
nameInputBtn.visible = true;
}
if (nameInfo) {
nameInfo.visible = true;
}
hideTitle();
hideScore();
hideMenu();
hideAllMiniGames();
// Ensure name input is on top
game.setChildIndex(nameInputBtn, game.children.length - 1);
game.setChildIndex(nameInfo, game.children.length - 1);
}
function hideNameScreen() {
nameInputBtn.visible = false;
nameInfo.visible = false;
}
// --- Name Input Logic (simple prompt) ---
nameInputBtn.onClick = function () {
var newName = '';
if (typeof prompt === 'function') {
newName = prompt('İsminizi girin:', playerName);
} else {
// Fallback for environments without prompt
newName = 'Oyuncu';
}
if (newName && newName.length > 0) {
playerName = newName;
storage.playerName = playerName;
nameInputBtn.setName(playerName);
showMenu();
}
};
// --- Main Menu ---
if (!menuButtons) {
var menuButtons = [];
}
var menuTitles = ["Savaş (Düşmanı Yen!)", "Rol Yapma (Altın Topla!)", "Tycoon (Fabrika Kur!)", "Araba Sürme (Engellerden Kaç!)", "Uzay Savaşı (Düşmanları Vur!)", "Sürpriz Oyun (Hafıza Kutusu!)"];
function showMenu() {
currentScreen = 'menu';
if (typeof loadingText !== "undefined" && loadingText) {
loadingText.visible = false;
}
hideNameScreen();
hideAllMiniGames();
hideScore();
showTitle("Oyun Dünyası: 6'lı Macera");
// Remove old buttons
if (!menuButtons) menuButtons = [];
if (!menuButtons) menuButtons = [];
if (!menuButtons) menuButtons = [];
for (var i = 0; i < menuButtons.length; i++) {
menuButtons[i].visible = false;
menuButtons[i].destroy();
}
menuButtons = [];
// Create new buttons
var startY = 700;
for (var i = 0; i < 6; i++) {
var btn = new MenuButton();
btn.x = 2048 / 2;
btn.y = startY + i * 240;
btn.setText(menuTitles[i]);
btn.setColor(0x2d2d2d);
btn.visible = true;
// Ensure the button is displayed on top of other elements
game.setChildIndex(btn, game.children.length - 1);
btn.onClick = function (idx) {
return function () {
startMiniGame(idx + 1);
};
}(i);
game.addChild(btn);
menuButtons.push(btn);
}
// Show name change button
nameInputBtn.visible = true;
nameInputBtn.y = 2732 - 300;
nameInputBtn.setName(playerName);
nameInfo.visible = false;
game.setChildIndex(nameInputBtn, game.children.length - 1);
}
function hideMenu() {
if (!menuButtons) menuButtons = [];
for (var i = 0; i < menuButtons.length; i++) {
menuButtons[i].visible = false;
menuButtons[i].destroy();
}
menuButtons = [];
nameInputBtn.visible = false;
nameInfo.visible = false;
}
// --- Mini Game Management ---
function hideAllMiniGames() {
hideMini1();
hideMini2();
hideMini3();
hideMini4();
hideMini5();
hideMini6();
}
// --- Mini Game 1: Savaş (Tap to Defeat Enemy) ---
var mini1Enemy = null;
var mini1Score = 0;
var mini1BackBtn = null;
function startMiniGame1() {
currentScreen = 'mini1';
hideMenu();
hideAllMiniGames();
showTitle("Savaş: Düşmanı Yen!");
mini1Score = 0;
showScore("Skor: 0");
mini1Enemy = new SavasEnemy();
mini1Enemy.x = 2048 / 2;
mini1Enemy.y = 2732 / 2;
mini1Enemy.onDefeat = function () {
mini1Score++;
showScore("Skor: " + mini1Score);
// Respawn enemy at random position
mini1Enemy = new SavasEnemy();
mini1Enemy.x = 400 + Math.floor(Math.random() * 1200);
mini1Enemy.y = 700 + Math.floor(Math.random() * 1600);
mini1Enemy.onDefeat = arguments.callee;
game.addChild(mini1Enemy);
game.setChildIndex(mini1Enemy, game.children.length - 1);
};
game.addChild(mini1Enemy);
game.setChildIndex(mini1Enemy, game.children.length - 1);
// Back to menu button
mini1BackBtn = new MenuButton();
mini1BackBtn.x = 2048 / 2;
mini1BackBtn.y = 2732 - 200;
mini1BackBtn.setText("Ana Menüye Dön");
mini1BackBtn.setColor(0x444444);
mini1BackBtn.onClick = function () {
miniGameScores[0] = mini1Score;
storage.miniGameScores = miniGameScores;
showMenu();
};
game.addChild(mini1BackBtn);
game.setChildIndex(mini1BackBtn, game.children.length - 1);
}
function hideMini1() {
if (mini1Enemy) {
mini1Enemy.destroy();
mini1Enemy = null;
}
if (mini1BackBtn) {
mini1BackBtn.destroy();
mini1BackBtn = null;
}
hideScore();
}
// --- Mini Game 2: Rol Yapma (Tap to Collect Coins) ---
var mini2Coins = [];
var mini2Score = 0;
var mini2BackBtn = null;
function startMiniGame2() {
currentScreen = 'mini2';
hideMenu();
hideAllMiniGames();
showTitle("Rol Yapma: Altın Topla!");
mini2Score = 0;
showScore("Altın: 0");
mini2Coins = [];
for (var i = 0; i < 5; i++) {
var coin = new RPGCoin();
coin.x = 300 + Math.floor(Math.random() * 1400);
coin.y = 600 + Math.floor(Math.random() * 1800);
coin.onCollect = function (coinObj) {
return function () {
mini2Score++;
showScore("Altın: " + mini2Score);
coinObj.destroy();
// Spawn new coin
var newCoin = new RPGCoin();
newCoin.x = 300 + Math.floor(Math.random() * 1400);
newCoin.y = 600 + Math.floor(Math.random() * 1800);
newCoin.onCollect = arguments.callee;
game.addChild(newCoin);
game.setChildIndex(newCoin, game.children.length - 1);
mini2Coins.push(newCoin);
};
}(coin);
game.addChild(coin);
game.setChildIndex(coin, game.children.length - 1);
mini2Coins.push(coin);
}
mini2BackBtn = new MenuButton();
mini2BackBtn.x = 2048 / 2;
mini2BackBtn.y = 2732 - 200;
mini2BackBtn.setText("Ana Menüye Dön");
mini2BackBtn.setColor(0x444444);
mini2BackBtn.onClick = function () {
miniGameScores[1] = mini2Score;
storage.miniGameScores = miniGameScores;
showMenu();
};
game.addChild(mini2BackBtn);
game.setChildIndex(mini2BackBtn, game.children.length - 1);
}
function hideMini2() {
for (var i = 0; i < mini2Coins.length; i++) {
mini2Coins[i].destroy();
}
mini2Coins = [];
if (mini2BackBtn) {
mini2BackBtn.destroy();
mini2BackBtn = null;
}
hideScore();
}
// --- Mini Game 3: Tycoon (Tap to Produce) ---
var mini3Factory = null;
var mini3Score = 0;
var mini3BackBtn = null;
function startMiniGame3() {
currentScreen = 'mini3';
hideMenu();
hideAllMiniGames();
showTitle("Tycoon: Fabrika Kur!");
mini3Score = 0;
showScore("Para: 0");
mini3Factory = new TycoonFactory();
mini3Factory.x = 2048 / 2;
mini3Factory.y = 2732 / 2;
mini3Factory.onProduce = function () {
mini3Score += 10;
showScore("Para: " + mini3Score);
};
game.addChild(mini3Factory);
game.setChildIndex(mini3Factory, game.children.length - 1);
mini3BackBtn = new MenuButton();
mini3BackBtn.x = 2048 / 2;
mini3BackBtn.y = 2732 - 200;
mini3BackBtn.setText("Ana Menüye Dön");
mini3BackBtn.setColor(0x444444);
mini3BackBtn.onClick = function () {
miniGameScores[2] = mini3Score;
storage.miniGameScores = miniGameScores;
showMenu();
};
game.addChild(mini3BackBtn);
game.setChildIndex(mini3BackBtn, game.children.length - 1);
}
function hideMini3() {
if (mini3Factory) {
mini3Factory.destroy();
mini3Factory = null;
}
if (mini3BackBtn) {
mini3BackBtn.destroy();
mini3BackBtn = null;
}
hideScore();
}
// --- Mini Game 4: Araba Sürme (Dodge Obstacles) ---
var mini4Car = null;
var mini4Obstacles = [];
var mini4Score = 0;
var mini4BackBtn = null;
var mini4GameOver = false;
function startMiniGame4() {
currentScreen = 'mini4';
hideMenu();
hideAllMiniGames();
showTitle("Araba Sürme: Engellerden Kaç!");
mini4Score = 0;
showScore("Skor: 0");
mini4GameOver = false;
mini4Obstacles = [];
mini4Car = new Car();
mini4Car.x = 2048 / 2;
mini4Car.y = 2732 - 400;
game.addChild(mini4Car);
game.setChildIndex(mini4Car, game.children.length - 1);
mini4BackBtn = new MenuButton();
mini4BackBtn.x = 2048 / 2;
mini4BackBtn.y = 2732 - 200;
mini4BackBtn.setText("Ana Menüye Dön");
mini4BackBtn.setColor(0x444444);
mini4BackBtn.onClick = function () {
miniGameScores[3] = mini4Score;
storage.miniGameScores = miniGameScores;
showMenu();
};
game.addChild(mini4BackBtn);
game.setChildIndex(mini4BackBtn, game.children.length - 1);
}
function hideMini4() {
if (mini4Car) {
mini4Car.destroy();
mini4Car = null;
}
for (var i = 0; i < mini4Obstacles.length; i++) {
mini4Obstacles[i].destroy();
}
mini4Obstacles = [];
if (mini4BackBtn) {
mini4BackBtn.destroy();
mini4BackBtn = null;
}
hideScore();
}
// --- Mini Game 5: Uzay Savaşı (Move & Shoot) ---
var mini5Ship = null;
var mini5Enemies = [];
var mini5Bullets = [];
var mini5Score = 0;
var mini5BackBtn = null;
function startMiniGame5() {
currentScreen = 'mini5';
hideMenu();
hideAllMiniGames();
showTitle("Uzay Savaşı: Düşmanları Vur!");
mini5Score = 0;
showScore("Skor: 0");
mini5Enemies = [];
mini5Bullets = [];
mini5Ship = new SpaceShip();
mini5Ship.x = 2048 / 2;
mini5Ship.y = 2732 - 400;
game.addChild(mini5Ship);
game.setChildIndex(mini5Ship, game.children.length - 1);
mini5BackBtn = new MenuButton();
mini5BackBtn.x = 2048 / 2;
mini5BackBtn.y = 2732 - 200;
mini5BackBtn.setText("Ana Menüye Dön");
mini5BackBtn.setColor(0x444444);
mini5BackBtn.onClick = function () {
miniGameScores[4] = mini5Score;
storage.miniGameScores = miniGameScores;
showMenu();
};
game.addChild(mini5BackBtn);
game.setChildIndex(mini5BackBtn, game.children.length - 1);
}
function hideMini5() {
if (mini5Ship) {
mini5Ship.destroy();
mini5Ship = null;
}
for (var i = 0; i < mini5Enemies.length; i++) {
mini5Enemies[i].destroy();
}
mini5Enemies = [];
for (var i = 0; i < mini5Bullets.length; i++) {
mini5Bullets[i].destroy();
}
mini5Bullets = [];
if (mini5BackBtn) {
mini5BackBtn.destroy();
mini5BackBtn = null;
}
hideScore();
}
// --- Mini Game 6: Sürpriz Oyun (Memory: Tap the Shown Box) ---
var mini6Boxes = [];
var mini6TargetIdx = 0;
var mini6Score = 0;
var mini6BackBtn = null;
var mini6ShowTimer = null;
function startMiniGame6() {
currentScreen = 'mini6';
hideMenu();
hideAllMiniGames();
showTitle("Sürpriz Oyun: Hafıza Kutusu!");
mini6Score = 0;
showScore("Skor: 0");
mini6Boxes = [];
var boxPositions = [[600, 1000], [1448, 1000], [600, 1800], [1448, 1800]];
for (var i = 0; i < 4; i++) {
var box = new MemoryBox();
box.x = boxPositions[i][0];
box.y = boxPositions[i][1];
box.visible = false;
box.onTap = function (idx) {
return function () {
if (idx === mini6TargetIdx) {
mini6Score++;
showScore("Skor: " + mini6Score);
showNextMemoryBox();
} else {
// Wrong box, reset score
mini6Score = 0;
showScore("Skor: 0");
showNextMemoryBox();
}
};
}(i);
game.addChild(box);
game.setChildIndex(box, game.children.length - 1);
mini6Boxes.push(box);
}
showNextMemoryBox();
mini6BackBtn = new MenuButton();
mini6BackBtn.x = 2048 / 2;
mini6BackBtn.y = 2732 - 200;
mini6BackBtn.setText("Ana Menüye Dön");
mini6BackBtn.setColor(0x444444);
mini6BackBtn.onClick = function () {
miniGameScores[5] = mini6Score;
storage.miniGameScores = miniGameScores;
showMenu();
};
game.addChild(mini6BackBtn);
game.setChildIndex(mini6BackBtn, game.children.length - 1);
}
function showNextMemoryBox() {
for (var i = 0; i < mini6Boxes.length; i++) {
mini6Boxes[i].visible = false;
}
mini6TargetIdx = Math.floor(Math.random() * 4);
mini6Boxes[mini6TargetIdx].visible = true;
}
function hideMini6() {
for (var i = 0; i < mini6Boxes.length; i++) {
mini6Boxes[i].destroy();
}
mini6Boxes = [];
if (mini6BackBtn) {
mini6BackBtn.destroy();
mini6BackBtn = null;
}
hideScore();
}
// --- Mini Game Starters ---
function startMiniGame(idx) {
if (idx === 1) startMiniGame1();else if (idx === 2) startMiniGame2();else if (idx === 3) startMiniGame3();else if (idx === 4) startMiniGame4();else if (idx === 5) startMiniGame5();else if (idx === 6) startMiniGame6();
}
// --- Game Move Handlers (for mini games that need it) ---
var dragCar = false;
var dragShip = false;
game.move = function (x, y, obj) {
if (currentScreen === 'mini4' && mini4Car && !mini4GameOver) {
// Move car horizontally only
mini4Car.x = Math.max(200, Math.min(2048 - 200, x));
}
if (currentScreen === 'mini5' && mini5Ship) {
mini5Ship.x = Math.max(100, Math.min(2048 - 100, x));
}
};
game.down = function (x, y, obj) {
if (currentScreen === 'mini4' && mini4Car && !mini4GameOver) {
dragCar = true;
mini4Car.x = Math.max(200, Math.min(2048 - 200, x));
}
if (currentScreen === 'mini5' && mini5Ship) {
dragShip = true;
mini5Ship.x = Math.max(100, Math.min(2048 - 100, x));
}
};
game.up = function (x, y, obj) {
dragCar = false;
dragShip = false;
};
// --- Game Update Loop ---
game.update = function () {
// Mini Game 4: Araba Sürme (Obstacles)
if (currentScreen === 'mini4' && mini4Car && !mini4GameOver) {
// Spawn obstacles
if (LK.ticks % 40 === 0) {
var obs = new CarObstacle();
obs.x = 300 + Math.floor(Math.random() * 1400);
obs.y = -100;
mini4Obstacles.push(obs);
game.addChild(obs);
game.setChildIndex(obs, game.children.length - 1);
}
// Move obstacles
for (var i = mini4Obstacles.length - 1; i >= 0; i--) {
var obs = mini4Obstacles[i];
obs.y += 28;
if (obs.y > 2732 + 100) {
obs.destroy();
mini4Obstacles.splice(i, 1);
mini4Score++;
showScore("Skor: " + mini4Score);
} else if (obs.intersects(mini4Car)) {
mini4GameOver = true;
LK.effects.flashScreen(0xff0000, 800);
miniGameScores[3] = mini4Score;
storage.miniGameScores = miniGameScores;
setTimeout(function () {
showMenu();
}, 900);
}
}
}
// Mini Game 5: Uzay Savaşı (Enemies & Bullets)
if (currentScreen === 'mini5' && mini5Ship) {
// Spawn enemies
if (LK.ticks % 50 === 0) {
var enemy = new SpaceEnemy();
enemy.x = 200 + Math.floor(Math.random() * 1648);
enemy.y = -100;
mini5Enemies.push(enemy);
game.addChild(enemy);
game.setChildIndex(enemy, game.children.length - 1);
}
// Move enemies
for (var i = mini5Enemies.length - 1; i >= 0; i--) {
var enemy = mini5Enemies[i];
enemy.y += 18;
if (enemy.y > 2732 + 100) {
enemy.destroy();
mini5Enemies.splice(i, 1);
} else if (enemy.intersects(mini5Ship)) {
LK.effects.flashScreen(0xff0000, 800);
miniGameScores[4] = mini5Score;
storage.miniGameScores = miniGameScores;
setTimeout(function () {
showMenu();
}, 900);
}
}
// Fire bullets
if (LK.ticks % 20 === 0) {
var bullet = new SpaceBullet();
bullet.x = mini5Ship.x;
bullet.y = mini5Ship.y - 90;
mini5Bullets.push(bullet);
game.addChild(bullet);
game.setChildIndex(bullet, game.children.length - 1);
}
// Move bullets
for (var i = mini5Bullets.length - 1; i >= 0; i--) {
var bullet = mini5Bullets[i];
bullet.update();
if (bullet.y < -100) {
bullet.destroy();
mini5Bullets.splice(i, 1);
} else {
// Check collision with enemies
for (var j = mini5Enemies.length - 1; j >= 0; j--) {
var enemy = mini5Enemies[j];
if (bullet.intersects(enemy)) {
bullet.destroy();
enemy.destroy();
mini5Bullets.splice(i, 1);
mini5Enemies.splice(j, 1);
mini5Score++;
showScore("Skor: " + mini5Score);
break;
}
}
}
}
}
};
// --- Initial Screen ---
if (!playerName || playerName.length === 0) {
showNameScreen();
hideMenu();
} else {
showMenu();
}