User prompt
mermi atıldığında silahın resminin üzerinden gidiyor mermi silah resminin altından gitsin
User prompt
geri sayımda rakamlar ince onları biraz kalın yap ve büyüt biraz
User prompt
Start menuda oyunu duraklatma tuşunu gizle sadece oyun içinde olsun
User prompt
İbutonunu birazcık daha büyüt
User prompt
İbutona basıldığıma ipucun arkasında ki resmi kaldır
User prompt
İbutona basıldığında bu mesaj gözüksün ekrana düzgün şekilde yerleştir oyuncu göre bilsin How to Play: Move your head to aim at the notes, and tap the screen to shoot them. If you miss a note, you’ll lose a life. As you progress, small notes will appear they give 2 points and missing them won't reduce your life. WARNING: Don’t shoot the black notes, or you’ll lose a life! Good luck, NOTE HUNTER!
User prompt
İbutona basıldığında aşağıda Ok yazan buton koy
User prompt
aşağıda üzerine ok yazan buton koy
User prompt
ibutona basıldığında aşağıda anladım (inglizce) yazan bir küçük btnbg olsun
User prompt
bitna basıldığnda siya çizgi çıkıyor onu da kaldlr
User prompt
İbutona bastığmızda çıkan resmi kaldır
User prompt
İbutona basan oyuncu oyun nasıl oynanlr hakkında ipucu gözükecek "Kafanı haralet ettirerek nişan al elrana tıklayarak hedefleri vur Dikkat ! sakın Siyah notaları vurma toksa canın azalır notları canın bitmeden vurmaya çalış iyi oyunlar NOTA AVCISI" bunu inglizceye çevir yerleştir
User prompt
Menuda sağ üste İbuton resmini koy
User prompt
Menuda ipucu yazısımıb ve arkasında ki resmi kaldlr
User prompt
o zaman ball silahının oyun içi görselini küçült biraz
User prompt
Menuda ipucunun arkaaında ki resmi kaldır yerine Ipucu resmini koy
User prompt
Start menuda ipucun arkasında ki resmi sil yerine Marketalan resmini koy
User prompt
Oyuncu Home tuşuna bastığında 'Çıkmak istediğinize emin misiniz?' şeklinde bir onay penceresi çıkmalı. Bu pencere açıkken oyun arka planda tamamen durmalı — hiçbir nota hareket etmemeli, oyuncu karar verene kadar oyun donmuş şekilde kalmalı.
User prompt
home tuşuna gir çık yaptığında oyuncu ard arda müzik kendiliğden değiştiryor o oyun hangi müzikle başladıysa öyle de devam etsin
User prompt
Ana sayfa tuşuna basdığında elrana çıkmak istedğinize eminmisiniz yazısı geldiğinse arka planda oyun duraklasın
User prompt
home tuşuna basıldığnda oyun duraklar
User prompt
Oyundan çıkmak istedğinize eminmisiniz yazısı inglizce yap ve arkasında ki resmi kaldır
User prompt
Oyunda home tuəuna bastıkta elrana soru çıskın oyundan çıkmak istedğinize eminmisiniz yes no eğer no derse geri satım başlasın ve oyuna devam etsin
User prompt
Marlete diyelim ki üste Silah2 use seçili aşağıda Note2 seçili oyuncu üste ki silahı değiştirdiği zaman mesela Silah3 seçtiği zaman aşağıda seçili olan Note2 gei rengi yok oluyor bunu düzelt
User prompt
Marketb resmini kaldlr
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var facekit = LK.import("@upit/facekit.v1"); var storage = LK.import("@upit/storage.v1", { highScore_slow: 0, highScore_normal: 0, highScore_fast: 0, totalPoints: 0, extraLives: 0, extraLifeOwned: false, silah2Owned: false, silah3Owned: false, silah4Owned: false, note2Owned: false, note3Owned: false, note4Owned: false, currentNoteType: "note", currentWeapon: "ball" }); /**** * Classes ****/ // Ball class: the fixed shooter at bottom left var Ball = Container.expand(function () { var self = Container.call(this); var ballSize = currentWeapon === 'Silah3' ? 700 : currentWeapon === 'Silah4' ? 700 : 850; var ballAsset = self.attachAsset(currentWeapon, { anchorX: 0.5, anchorY: 0.5, width: ballSize, height: ballSize, color: 0xffffff, shape: 'ellipse' }); return self; }); // Bullet class: fired from ball towards crosshair var Bullet = Container.expand(function () { var self = Container.call(this); var bulletAsset = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5, width: BULLET_SIZE, height: BULLET_SIZE, color: 0x00e6e6, shape: 'ellipse' }); self.vx = 0; self.vy = 0; self.update = function () { self.x += self.vx; self.y += self.vy; }; return self; }); // Crosshair class: follows facekit position var Crosshair = Container.expand(function () { var self = Container.call(this); var crossAsset = self.attachAsset('crosshair', { anchorX: 0.5, anchorY: 0.5, width: CROSS_SIZE, height: CROSS_SIZE, color: 0xff0000, shape: 'ellipse' }); return self; }); // Ball // Crosshair // Bullet // Button background // Music tracks // KucukNote class: horizontal moving note (slides left to right or right to left) var KucukNote = Container.expand(function () { var self = Container.call(this); var kucukAsset = self.attachAsset('kucuk_nota', { anchorX: 0.5, anchorY: 0.5, width: 160, height: 160 }); self.vx = 0; // horizontal velocity self.vy = 0; // vertical velocity (minimal) self.hit = false; self.isKucuk = true; // flag for special handling self.update = function () { self.x += self.vx; self.y += self.vy; }; return self; }); // MusicNoteEffect class: floating music note symbol when a note is hit var MusicNoteEffect = Container.expand(function () { var self = Container.call(this); // Use a Text2 object for the music note symbol var noteSymbol = new Text2("♪", { size: 120, fill: "#fff" }); noteSymbol.anchor.set(0.5, 0.5); self.addChild(noteSymbol); // Animate: float up and fade out self.start = function (startX, startY) { self.x = startX; self.y = startY; self.alpha = 1; // Tween upward and fade out tween(self, { y: self.y - 220, alpha: 0 }, { duration: 700, easing: tween.cubicOut, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); // NotaggNote class: falling notagg note (special note, ends game if tapped) var NotaggNote = Container.expand(function () { var self = Container.call(this); var notaggAsset = self.attachAsset('Notagg', { anchorX: 0.5, anchorY: 0.5, width: NOTE_WIDTH, height: NOTE_HEIGHT }); self.column = 0; self.speed = noteFallSpeed; self.hit = false; self.isNotagg = true; // flag for special handling self.update = function () { self.y += self.speed; }; return self; }); // Note class: falling note var Note = Container.expand(function () { var self = Container.call(this); // Use the currently selected note type var noteAssetId = currentNoteType; // Randomly pick a color for the note var color = NOTE_COLORS[Math.floor(Math.random() * NOTE_COLORS.length)]; var noteAsset = self.attachAsset(noteAssetId, { anchorX: 0.5, anchorY: 0.5, width: NOTE_WIDTH, // now wider height: NOTE_HEIGHT, color: noteAssetId === 'note' ? color : 0xffffff, shape: noteAssetId === 'note' ? 'box' : 'ellipse' }); self.column = 0; // which column this note is in self.speed = noteFallSpeed; // will be set on spawn self.hit = false; // has this note been hit self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181a20 }); /**** * Game Code ****/ // Ensure Notagg matches note image size // --- Constants --- // Note: All note assets will be ellipses with different colors for variety var NOTE_COLORS = [0xffe066, 0x66b3ff, 0xff66a3, 0x7cff66, 0xff8c66]; var GAME_W = 2048; var GAME_H = 2732; // --- Dynamic Gradient Background --- // We'll use two large colored rectangles, tweening their tints and alpha for a subtle animated gradient effect. var bgLayer1 = null; var bgLayer2 = null; var bgGradientColors = [0x8635f1, // purple 0x66b3ff, // blue 0xff66a3, // pink 0x7cff66, // green 0xffe066, // yellow 0xb39ddb // lavender ]; var bgColorIdx1 = 0; var bgColorIdx2 = 1; var bgTweenDuration = 8000; // ms, slightly longer for smoother transitions function setupGradientBackground() { // Remove if already present if (bgLayer1) { bgLayer1.destroy(); bgLayer1 = null; } if (bgLayer2) { bgLayer2.destroy(); bgLayer2 = null; } // Layer 1 bgLayer1 = LK.getAsset('softbg2', { anchorX: 0.5, anchorY: 0.5, width: GAME_W * 1.1, height: GAME_H * 1.1, x: GAME_W / 2, y: GAME_H / 2, // Start with first color, slightly more visible tint: bgGradientColors[bgColorIdx1], alpha: 0.32 }); // Layer 2 bgLayer2 = LK.getAsset('softbg2', { anchorX: 0.5, anchorY: 0.5, width: GAME_W * 1.1, height: GAME_H * 1.1, x: GAME_W / 2, y: GAME_H / 2, // Start with second color, slightly more visible tint: bgGradientColors[bgColorIdx2], alpha: 0.22 }); // Add to back of display list game.addChildAt(bgLayer1, 0); game.addChildAt(bgLayer2, 1); // Start the animation loop animateGradientBackground(); } function animateGradientBackground() { // Pick next color indices var nextIdx1 = (bgColorIdx1 + 1) % bgGradientColors.length; var nextIdx2 = (bgColorIdx2 + 1) % bgGradientColors.length; // Animate tints and alpha for both layers, smoothly transitioning to next color tween(bgLayer1, { tint: bgGradientColors[nextIdx1], alpha: 0.32 }, { duration: bgTweenDuration, easing: tween.easeInOut, onFinish: function onFinish() { bgColorIdx1 = nextIdx1; animateGradientBackground(); } }); tween(bgLayer2, { tint: bgGradientColors[nextIdx2], alpha: 0.22 }, { duration: bgTweenDuration, easing: tween.easeInOut, onFinish: function onFinish() { bgColorIdx2 = nextIdx2; } }); } // Call setupGradientBackground once at game start setupGradientBackground(); var BALL_SIZE = currentWeapon === 'Silah3' ? 700 : currentWeapon === 'Silah4' ? 700 : 550; var NOTE_WIDTH = 180; // was 120, now wider for less thin look var NOTE_HEIGHT = 180; // reduced from 260 to make notes less long var CROSS_SIZE = 160; var BULLET_SIZE = 60; var NOTE_COLS = 5; var NOTE_MARGIN = 60; var NOTE_AREA_W = GAME_W - 2 * NOTE_MARGIN; var NOTE_COL_W = NOTE_AREA_W / NOTE_COLS; var NOTE_START_Y = -NOTE_HEIGHT; var BALL_X = 180; var BALL_Y = GAME_H - 150; var CROSS_MIN_X = 200; var CROSS_MAX_X = GAME_W - 200; var CROSS_MIN_Y = 200; var CROSS_MAX_Y = GAME_H - 400; var BULLET_SPEED = 48; // px per frame // --- Game State --- var notes = []; var kucukNotes = []; var bullets = []; var crosshair = null; var ball = null; var scoreTxt = null; var livesTxt = null; var tipTxt = null; var lastNoteSpawnTick = 0; var noteFallSpeed = 12; // will be set by difficulty var noteSpawnInterval = 60; // ticks between notes, will be set by difficulty var difficulty = null; // 'slow', 'normal', 'fast', 'training' var gameStarted = false; var trainingMode = false; // flag for training mode var canShoot = true; var lastScore = 0; var lives = 3; // Player starts with 3 lives var kucukNoteActive = false; // Track if kucuk note is active var kucukNoteTimer = null; // Timer for kucuk note duration var KUCUK_NOTE_DURATION = 10000; // 10 seconds in milliseconds // Wave system variables var waveActive = false; var waveStartTime = 0; var waveDuration = 6000; // 6 seconds in milliseconds var waveNumber = 0; var lastWaveScore = 0; var waveSpawnTimer = 0; var waveSpawnInterval = 800; // spawn every 800ms during wave var musicTracks = [{ id: 'music1', name: 'Parça 1' }, { id: 'music2', name: 'Parça 2' }, { id: 'music3', name: 'Parça 3' }]; var currentMusic = null; var musicPaused = false; var musicPosition = 0; // Market state var marketOpen = false; var marketItems = {}; // Initialize current selections from storage or use defaults var currentWeapon = storage.currentWeapon || 'ball'; // Track current weapon, restore from storage var currentNoteType = storage.currentNoteType || 'note'; // Track current note type, restore from storage // Ensure the storage values are properly set if they don't exist if (!storage.currentWeapon) { storage.currentWeapon = 'ball'; } if (!storage.currentNoteType) { storage.currentNoteType = 'note'; } // --- Difficulty Presets --- // Slowed down for all modes var DIFFICULTY_PRESETS = { 'slow': { noteFallSpeed: 5, noteSpawnInterval: 120 }, 'normal': { noteFallSpeed: 6, noteSpawnInterval: 90 }, 'fast': { noteFallSpeed: 8, noteSpawnInterval: 60 } }; // --- UI: Difficulty Selection --- var diffBtns = []; function showDifficultyMenu() { // Only start menu music if not paused (coming from market) if (!musicPaused) { LK.stopMusic(); LK.playMusic('Menu1', { loop: true }); } // Hide facekit video feed if visible if (facekit && typeof facekit.setVisible === "function") { facekit.setVisible(false); } // Add Backr image as background if (!game._diffMenuBackr) { var backr = LK.getAsset('Backr', { anchorX: 0.5, anchorY: 0.5, width: GAME_W, height: GAME_H, x: GAME_W / 2, y: GAME_H / 2, scaleMode: 'nearest' // prevent blurriness by using nearest neighbor scaling }); if (typeof backr.setScaleMode === "function") { backr.setScaleMode('nearest'); } game.addChild(backr); game._diffMenuBackr = backr; } var btnLabels = [{ key: 'slow', label: 'Slow' }, { key: 'normal', label: 'Normal' }, { key: 'fast', label: 'Fast' }, { key: 'training', label: 'Training' }]; var btnW = 500, btnH = 180, btnGap = 60; var startY = GAME_H / 2 - (btnLabels.length * btnH + (btnLabels.length - 1) * btnGap) / 2; for (var i = 0; i < btnLabels.length; i++) { var btn = new Container(); var bg = btn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: btnW, height: btnH, color: 0x222a38, shape: 'box' }); bg.y += 18; // Move the btnbg image slightly downward // High score text above the button (skip for training mode) if (btnLabels[i].key !== 'training') { var hsKey = "highScore_" + btnLabels[i].key; var hsVal = storage[hsKey] || 0; var hsTxt = new Text2("High Score: " + hsVal, { size: 54, fill: "#fff" }); hsTxt.anchor.set(0.5, 1); hsTxt.x = 0; // Move the high score text closer to the btnmg box (was -btnH/2-2, now -btnH/2+24) hsTxt.y = -btnH / 2 + 24; // above the btnbg, but closer to the button btn.addChild(hsTxt); } else { // Training mode - no description text } var txt = new Text2(btnLabels[i].label, { size: 90, fill: "#fff" }); txt.anchor.set(0.5, 0.5); txt.x = 0; txt.y = 18; // Match the btnbg y offset to center text in button box btn.addChild(txt); btn.x = GAME_W / 2; btn.y = startY + i * (btnH + btnGap); btn.difficulty = btnLabels[i].key; btn.down = function (x, y, obj) { // Play button sound var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } startGame(this.difficulty); }; game.addChild(btn); diffBtns.push(btn); } // Add market button in bottom right corner var marketBtn = new Container(); var marketBg = marketBtn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: 250, height: 220, color: 0x4a5568, shape: 'box' }); var marketImg = marketBtn.attachAsset('Market', { anchorX: 0.5, anchorY: 0.5, width: 100, height: 100, x: 0, y: 0 }); marketBtn.x = GAME_W - 200; marketBtn.y = GAME_H - 150; marketBtn.down = function (x, y, obj) { // Play button sound var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } // Play Marketdoor sound when market opens var marketdoorSound = LK.getSound('Marketdoor'); if (marketdoorSound && typeof marketdoorSound.play === "function") { marketdoorSound.play(); } showMarket(); }; game.addChild(marketBtn); diffBtns.push(marketBtn); // Show tip if (!tipTxt) { tipTxt = new Text2("AIM AT THE NOTES BY\nMOVING YOUR HEAD\nAND FIRE THE GUN BY\nTAPPING THE SCREEN.", { size: 70, fill: 0xFFFFFF }); tipTxt.anchor.set(0.5, 0); // Add border image behind tipTxt, sized to match the text (increased size for more padding) var borderImg = LK.getAsset('Cercive', { anchorX: 0.5, anchorY: 0, width: tipTxt.width * 1.28, height: tipTxt.height * 1.28 }); borderImg.x = 0; borderImg.y = -38; // move border up a bit more // Create a container to hold both var tipContainer = new Container(); tipContainer.addChild(borderImg); tipContainer.addChild(tipTxt); tipContainer.x = GAME_W / 2; tipContainer.y = 180; game.addChild(tipContainer); // Store for later removal game._tipBg = borderImg; game._tipContainer = tipContainer; } else { // If already created, just update position if (game._tipContainer) { game._tipContainer.x = GAME_W / 2; game._tipContainer.y = 180; } } } // Remove difficulty menu function hideDifficultyMenu() { // Restore facekit video feed if (facekit && typeof facekit.setVisible === "function") { facekit.setVisible(true); } // Remove Backr background if present if (game._diffMenuBackr) { game._diffMenuBackr.destroy(); game._diffMenuBackr = null; } for (var i = 0; i < diffBtns.length; i++) { diffBtns[i].destroy(); } diffBtns = []; if (tipTxt) { tipTxt.destroy(); tipTxt = null; if (game._tipBg) { game._tipBg.destroy(); game._tipBg = null; } if (game._tipContainer) { game._tipContainer.destroy(); game._tipContainer = null; } } } // --- Market Functions --- function showMarket() { marketOpen = true; // Pause current music instead of stopping if (!musicPaused) { musicPaused = true; // Note: LK doesn't have pause functionality, so we'll track this state } hideDifficultyMenu(); // Add market background var marketBg = LK.getAsset('MarketB', { anchorX: 0.5, anchorY: 0.5, width: GAME_W, height: GAME_H, x: GAME_W / 2, y: GAME_H / 2 }); game.addChild(marketBg); game._marketBg = marketBg; // Market title removed per request // Currency display in top right corner with Para symbol var paraSymbol = LK.getAsset('Para', { anchorX: 1, anchorY: 0, width: 110, height: 110, x: GAME_W - 50, y: 50 }); game.addChild(paraSymbol); game._marketPara = paraSymbol; var currencyTxt = new Text2(storage.totalPoints.toString(), { size: 80, fill: 0xFFFFFF }); currencyTxt.anchor.set(1, 0); currencyTxt.x = GAME_W - 170; // Position to the left of Para symbol (adjusted for larger symbol) currencyTxt.y = 50; game.addChild(currencyTxt); game._marketCurrency = currencyTxt; // Create weapon card items var itemBtns = []; var weaponItems = { ballSilah: { name: 'Ball Weapon', cost: 0, image: 'ball', owned: true }, silah2: { name: 'Silah2', cost: 50, image: 'Silah2' }, silah3: { name: 'Silah3', cost: 134, image: 'Silah3' }, silah4: { name: 'Silah4', cost: 179, image: 'Silah4' } }; // Create note items var noteItems = { note: { name: 'Note', cost: 0, image: 'note', owned: true }, note2: { name: 'Note2', cost: 45, image: 'Note2' }, note3: { name: 'Note3', cost: 70, image: 'Note3' }, note4: { name: 'Note4', cost: 110, image: 'Note4' } }; var weaponKeys = Object.keys(weaponItems); var noteKeys = Object.keys(noteItems); var cardsPerRow = 4; // Changed from 3 to 4 to fit all weapons in one row var cardW = 350; var cardH = 450; var cardGapX = 80; var cardGapY = 60; var startX = 50; // Adjusted to center 4 cards horizontally var startY = 500; // Move higher to make room for note row for (var i = 0; i < weaponKeys.length; i++) { var itemKey = weaponKeys[i]; var item = weaponItems[itemKey]; var row = Math.floor(i / cardsPerRow); var col = i % cardsPerRow; var itemCard = new Container(); // Card background var cardBg = itemCard.attachAsset('Marketalan', { anchorX: 0.5, anchorY: 0.5, width: cardW, height: cardH - 100 }); // Weapon image at top of card var weaponImg = itemCard.attachAsset(item.image, { anchorX: 0.5, anchorY: 0.5, width: item.image === 'Silah3' ? 350 : item.image === 'Silah2' ? 350 : item.image === 'Silah4' ? 300 : 250, height: item.image === 'Silah3' ? 350 : item.image === 'Silah2' ? 350 : item.image === 'Silah4' ? 300 : 250, x: 0, y: item.image === 'Silah3' ? 0 : item.image === 'ball' ? 20 : item.image === 'Silah4' ? 10 : 15 }); // Weapon name below image - removed for cleaner display // Buy button at bottom var buyBtn = new Container(); var isOwned = item.owned === true; var canAfford = canAffordItem(itemKey); var buyBg = buyBtn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: 280, height: 100, color: isOwned ? 0x444444 : canAfford ? 0x00cc00 : 0x666666, shape: 'box' }); // Check if item is purchased (not just owned by default) var isPurchased = itemKey === 'silah2' && storage.silah2Owned || itemKey === 'silah3' && storage.silah3Owned || itemKey === 'silah4' && storage.silah4Owned || itemKey === 'ballSilah' && item.owned; // Check if this is the currently active weapon var isActiveWeapon = itemKey === 'ballSilah' && currentWeapon === 'ball' || itemKey === 'silah2' && currentWeapon === 'Silah2' || itemKey === 'silah3' && currentWeapon === 'Silah3' || itemKey === 'silah4' && currentWeapon === 'Silah4'; var buttonText = isPurchased ? "Use" : isOwned ? "Owned" : "Buy - " + item.cost; // Update button color based on whether it's active if (isPurchased && isActiveWeapon) { buyBg.tint = 0x808080; // Gray for active weapon } var buyTxt = new Text2(buttonText, { size: 45, fill: "#fff" }); buyTxt.anchor.set(0.5, 0.5); buyTxt.x = 0; buyTxt.y = 0; buyBtn.addChild(buyTxt); buyBtn.x = 0; buyBtn.y = cardH / 2 + 30; // Position button closer to the card frame // Add all elements to card itemCard.addChild(weaponImg); itemCard.addChild(buyBtn); // Position card itemCard.x = startX + col * (cardW + cardGapX) + cardW / 2; itemCard.y = startY + row * (cardH + cardGapY); itemCard.itemKey = itemKey; // Store button background reference for color updates buyBtn.buyBg = buyBg; // Button functionality if (isPurchased) { // Use button functionality buyBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } // Switch weapon var weaponKey = this.parent.itemKey; if (weaponKey === 'ballSilah') { currentWeapon = 'ball'; } else if (weaponKey === 'silah2') { currentWeapon = 'Silah2'; } else if (weaponKey === 'silah3') { currentWeapon = 'Silah3'; } else if (weaponKey === 'silah4') { currentWeapon = 'Silah4'; } // Save the selected weapon to storage storage.currentWeapon = currentWeapon; console.log("Using weapon: " + currentWeapon); // Update all use buttons to reflect current selections (both weapons and notes) if (game._marketBtns) { for (var i = 0; i < game._marketBtns.length; i++) { var card = game._marketBtns[i]; // Find the use button in this card var useBtn = null; for (var j = 0; j < card.children.length; j++) { if (card.children[j].buyBg) { useBtn = card.children[j]; break; } } if (useBtn && useBtn.buyBg) { // Check if this is the active weapon var isActiveWeapon = false; if (card.itemKey === 'ballSilah' && currentWeapon === 'ball') { isActiveWeapon = true; } else if (card.itemKey === 'silah2' && currentWeapon === 'Silah2') { isActiveWeapon = true; } else if (card.itemKey === 'silah3' && currentWeapon === 'Silah3') { isActiveWeapon = true; } else if (card.itemKey === 'silah4' && currentWeapon === 'Silah4') { isActiveWeapon = true; } // Check if this is the active note var isActiveNote = false; if (card.itemKey === 'note' && currentNoteType === 'note') { isActiveNote = true; } else if (card.itemKey === 'note2' && currentNoteType === 'Note2') { isActiveNote = true; } else if (card.itemKey === 'note3' && currentNoteType === 'Note3') { isActiveNote = true; } else if (card.itemKey === 'note4' && currentNoteType === 'Note4') { isActiveNote = true; } // Update button color - gray if active, light blue if not useBtn.buyBg.tint = isActiveWeapon || isActiveNote ? 0x808080 : 0x87CEEB; } } } }; } else if (!isOwned && canAfford) { // Purchase functionality - only if not owned and can afford buyBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } purchaseItem(this.parent.itemKey); }; } game.addChild(itemCard); itemBtns.push(itemCard); } // Create note cards in second row for (var i = 0; i < noteKeys.length; i++) { var noteKey = noteKeys[i]; var noteItem = noteItems[noteKey]; var noteCard = new Container(); // Card background var cardBg = noteCard.attachAsset('Marketalan', { anchorX: 0.5, anchorY: 0.5, width: cardW, height: cardH - 100 }); // Note image at top of card var noteImg = noteCard.attachAsset(noteItem.image, { anchorX: 0.5, anchorY: 0.5, width: 250, height: 250, x: 0, y: 20 }); // Buy/Use button at bottom var buyBtn = new Container(); var isOwned = noteItem.owned === true; var canAfford = canAffordNoteItem(noteKey); var buyBg = buyBtn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: 280, height: 100, color: isOwned ? 0x444444 : canAfford ? 0x00cc00 : 0x666666, shape: 'box' }); // Check if note item is purchased var isPurchased = noteKey === 'note' && noteItem.owned || noteKey === 'note2' && storage.note2Owned || noteKey === 'note3' && storage.note3Owned || noteKey === 'note4' && storage.note4Owned; // Check if this is the currently active note type var isActiveNote = noteKey === 'note' && currentNoteType === 'note' || noteKey === 'note2' && currentNoteType === 'Note2' || noteKey === 'note3' && currentNoteType === 'Note3' || noteKey === 'note4' && currentNoteType === 'Note4'; var buttonText = isPurchased ? "Use" : isOwned ? "Owned" : "Buy - " + noteItem.cost; // Update button color based on whether it's active if (isPurchased && isActiveNote) { buyBg.tint = 0x808080; // Gray for active note } var buyTxt = new Text2(buttonText, { size: 45, fill: "#fff" }); buyTxt.anchor.set(0.5, 0.5); buyTxt.x = 0; buyTxt.y = 0; buyBtn.addChild(buyTxt); buyBtn.x = 0; buyBtn.y = cardH / 2 + 30; // Add elements to note card noteCard.addChild(noteImg); noteCard.addChild(buyBtn); // Position note card in second row noteCard.x = startX + i * (cardW + cardGapX) + cardW / 2; noteCard.y = startY + (cardH + cardGapY); // Second row noteCard.itemKey = noteKey; // Store button background reference buyBtn.buyBg = buyBg; // Button functionality if (isPurchased) { // Use button functionality buyBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } // Switch note type var noteTypeKey = this.parent.itemKey; // Set the current note type based on selection if (noteTypeKey === 'note') { currentNoteType = 'note'; } else if (noteTypeKey === 'note2') { currentNoteType = 'Note2'; } else if (noteTypeKey === 'note3') { currentNoteType = 'Note3'; } else if (noteTypeKey === 'note4') { currentNoteType = 'Note4'; } // Save the selected note type to storage storage.currentNoteType = currentNoteType; console.log("Using note type: " + currentNoteType); // Update all note use buttons to reflect current selection if (game._marketBtns) { for (var i = 0; i < game._marketBtns.length; i++) { var card = game._marketBtns[i]; // Only process note cards (not weapon cards) if (card.itemKey === 'note' || card.itemKey === 'note2' || card.itemKey === 'note3' || card.itemKey === 'note4') { // Find the use button in this card var useBtn = null; for (var j = 0; j < card.children.length; j++) { if (card.children[j].buyBg) { useBtn = card.children[j]; break; } } if (useBtn && useBtn.buyBg) { // Check if this is the active note var isActive = card.itemKey === noteTypeKey; // Update button color - gray if active, light blue if not useBtn.buyBg.tint = isActive ? 0x808080 : 0x87CEEB; } } } } }; } else if (!isOwned && canAfford) { // Purchase functionality buyBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } purchaseNoteItem(this.parent.itemKey); }; } game.addChild(noteCard); itemBtns.push(noteCard); } // Create extra life card below note cards var extraLifeCard = new Container(); // Card background var extraLifeBg = extraLifeCard.attachAsset('Marketalan', { anchorX: 0.5, anchorY: 0.5, width: cardW, height: cardH - 100 }); // Extra life image var extraLifeImg = extraLifeCard.attachAsset('canbar', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 200, x: 0, y: 20 }); // Buy button var extraLifeBtn = new Container(); var isExtraLifeOwned = storage.extraLifeOwned; var canAffordExtraLife = storage.totalPoints >= 90; var extraLifeBuyBg = extraLifeBtn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: 280, height: 100, color: isExtraLifeOwned ? 0x444444 : canAffordExtraLife ? 0x00cc00 : 0x666666, shape: 'box' }); var extraLifeButtonText = isExtraLifeOwned ? "Owned" : "Buy - 90"; var extraLifeBuyTxt = new Text2(extraLifeButtonText, { size: 45, fill: "#fff" }); extraLifeBuyTxt.anchor.set(0.5, 0.5); extraLifeBuyTxt.x = 0; extraLifeBuyTxt.y = 0; extraLifeBtn.addChild(extraLifeBuyTxt); extraLifeBtn.x = 0; extraLifeBtn.y = cardH / 2 + 30; // Add elements to card extraLifeCard.addChild(extraLifeImg); extraLifeCard.addChild(extraLifeBtn); // Position extra life card in third row, first position extraLifeCard.x = startX + cardW / 2; extraLifeCard.y = startY + 2 * (cardH + cardGapY); // Store button background reference extraLifeBtn.buyBg = extraLifeBuyBg; // Button functionality if (!isExtraLifeOwned && canAffordExtraLife) { // Purchase functionality extraLifeBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } // Purchase extra life storage.totalPoints -= 90; storage.extraLifeOwned = true; storage.extraLives = 1; // Play Marketbuy sound var marketbuySound = LK.getSound('Marketbuy'); if (marketbuySound && typeof marketbuySound.play === "function") { marketbuySound.play(); } // Refresh market display hideMarket(); showMarket(); }; } game.addChild(extraLifeCard); itemBtns.push(extraLifeCard); // Back button var backBtn = new Container(); var backBg = backBtn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: 260, height: 130, color: 0x4a5568, shape: 'box' }); var backTxt = new Text2("Back", { size: 75, fill: "#fff" }); backTxt.anchor.set(0.5, 0.5); backTxt.x = 0; backTxt.y = 0; backBtn.addChild(backTxt); backBtn.x = GAME_W / 2; backBtn.y = GAME_H - 150; backBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } hideMarket(); }; game.addChild(backBtn); game._marketBtns = itemBtns; game._marketBackBtn = backBtn; } function hideMarket() { marketOpen = false; // Resume music state musicPaused = false; // Remove all market elements if (game._marketBg) { game._marketBg.destroy(); game._marketBg = null; } // Market title cleanup removed (title no longer exists) if (game._marketCurrency) { game._marketCurrency.destroy(); game._marketCurrency = null; } if (game._marketPara) { game._marketPara.destroy(); game._marketPara = null; } if (game._marketBtns) { for (var i = 0; i < game._marketBtns.length; i++) { game._marketBtns[i].destroy(); } game._marketBtns = null; } if (game._marketBackBtn) { game._marketBackBtn.destroy(); game._marketBackBtn = null; } showDifficultyMenu(); } function canAffordNoteItem(noteKey) { var noteItems = { note: { name: 'Note', cost: 0, image: 'note', owned: true }, note2: { name: 'Note2', cost: 45, image: 'Note2' }, note3: { name: 'Note3', cost: 70, image: 'Note3' }, note4: { name: 'Note4', cost: 110, image: 'Note4' } }; var item = noteItems[noteKey]; if (item.owned) return false; // Owned items cannot be purchased if (noteKey === 'note2' && storage.note2Owned) return false; // Already purchased if (noteKey === 'note3' && storage.note3Owned) return false; // Already purchased if (noteKey === 'note4' && storage.note4Owned) return false; // Already purchased return storage.totalPoints >= item.cost; } function canAffordItem(itemKey) { var weaponItems = { ballSilah: { name: 'Ball Weapon', cost: 0, image: 'ball', owned: true }, silah2: { name: 'Silah2', cost: 50, image: 'Silah2' }, silah3: { name: 'Silah3', cost: 134, image: 'Silah3' }, silah4: { name: 'Silah4', cost: 179, image: 'Silah4' } }; var item = weaponItems[itemKey]; if (item.owned) return false; // Owned items cannot be purchased if (itemKey === 'silah2' && storage.silah2Owned) return false; // Already purchased if (itemKey === 'silah3' && storage.silah3Owned) return false; // Already purchased if (itemKey === 'silah4' && storage.silah4Owned) return false; // Already purchased return storage.totalPoints >= item.cost; } function purchaseNoteItem(noteKey) { if (!canAffordNoteItem(noteKey)) return; var noteItems = { note: { name: 'Note', cost: 0, image: 'note', owned: true }, note2: { name: 'Note2', cost: 45, image: 'Note2' }, note3: { name: 'Note3', cost: 70, image: 'Note3' }, note4: { name: 'Note4', cost: 110, image: 'Note4' } }; var item = noteItems[noteKey]; if (item.owned) return; // Cannot purchase owned items storage.totalPoints -= item.cost; if (noteKey === 'note2') { storage.note2Owned = true; } else if (noteKey === 'note3') { storage.note3Owned = true; } else if (noteKey === 'note4') { storage.note4Owned = true; } // Play Marketbuy sound when purchase is successful var marketbuySound = LK.getSound('Marketbuy'); if (marketbuySound && typeof marketbuySound.play === "function") { marketbuySound.play(); } // Refresh market display hideMarket(); showMarket(); } function purchaseItem(itemKey) { if (!canAffordItem(itemKey)) return; var weaponItems = { ballSilah: { name: 'Ball Weapon', cost: 0, image: 'ball', owned: true }, silah2: { name: 'Silah2', cost: 50, image: 'Silah2' }, silah3: { name: 'Silah3', cost: 134, image: 'Silah3' }, silah4: { name: 'Silah4', cost: 179, image: 'Silah4' } }; var item = weaponItems[itemKey]; if (item.owned) return; // Cannot purchase owned items storage.totalPoints -= item.cost; if (itemKey === 'silah2') { storage.silah2Owned = true; } else if (itemKey === 'silah3') { storage.silah3Owned = true; } else if (itemKey === 'silah4') { storage.silah4Owned = true; } // Play Marketbuy sound when purchase is successful var marketbuySound = LK.getSound('Marketbuy'); if (marketbuySound && typeof marketbuySound.play === "function") { marketbuySound.play(); } // Refresh market display hideMarket(); showMarket(); } // --- Start Game --- var countdownActive = false; // Track if countdown is in progress function startGame(diffKey) { difficulty = diffKey; trainingMode = diffKey === 'training'; if (trainingMode) { // Training mode uses slow settings noteFallSpeed = DIFFICULTY_PRESETS['slow'].noteFallSpeed; noteSpawnInterval = DIFFICULTY_PRESETS['slow'].noteSpawnInterval; } else { noteFallSpeed = DIFFICULTY_PRESETS[diffKey].noteFallSpeed; noteSpawnInterval = DIFFICULTY_PRESETS[diffKey].noteSpawnInterval; } gameStarted = false; // Will be set to true after countdown countdownActive = true; // Set countdown as active // Stop menu music if playing LK.stopMusic(); hideDifficultyMenu(); LK.setScore(0); lastScore = 0; // Clean up any existing notes and bullets before starting for (var i = 0; i < notes.length; i++) { if (notes[i]) notes[i].destroy(); } notes = []; for (var i = 0; i < bullets.length; i++) { if (bullets[i]) bullets[i].destroy(); } bullets = []; // Clean up kucuk notes for (var i = 0; i < kucukNotes.length; i++) { if (kucukNotes[i]) kucukNotes[i].destroy(); } kucukNotes = []; // Reset wave system state waveActive = false; waveNumber = 0; lastWaveScore = 0; waveSpawnTimer = 0; // Reset kucuk note state kucukNoteActive = false; if (kucukNoteTimer) { LK.clearTimeout(kucukNoteTimer); kucukNoteTimer = null; } // Play PH6 only in fast mode, and make it more dominant in randomization var musicChoices; if (difficulty === 'fast') { // PH6 is more dominant: add it multiple times to increase its chance musicChoices = ['Ph6', 'Ph6', 'Ph6', 'Piano1', 'P2', 'P3', 'P4', 'P5']; } else { musicChoices = ['Piano1', 'P2', 'P3', 'P4', 'P5']; } var selectedMusic = musicChoices[Math.floor(Math.random() * musicChoices.length)]; // Stop any currently playing music before starting new one LK.stopMusic(); // Play the selected music with default options (looping, full volume) LK.playMusic(selectedMusic, { loop: true, fade: { start: 0, end: 1, duration: 400 } }); // Ball ball = new Ball(); ball.x = BALL_X; ball.y = BALL_Y + 20; game.addChild(ball); // Crosshair crosshair = new Crosshair(); crosshair.x = BALL_X + 400; crosshair.y = BALL_Y - 400; game.addChild(crosshair); // Score or Training Mode indicator if (!scoreTxt) { scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); } if (trainingMode) { scoreTxt.setText('Training Mode'); scoreTxt.size = 20; // Even smaller text size for training mode } else { scoreTxt.setText(0); scoreTxt.size = 120; // Normal size for score } // Lives display in top right corner as 3 life images (hidden in training mode) lives = 3 + (storage.extraLifeOwned ? 1 : 0); // Reset lives to 3, or 4 if extra life is owned // Clean up existing lives display if (livesTxt) { livesTxt.destroy(); livesTxt = null; } if (game.livesImages) { for (var i = 0; i < game.livesImages.length; i++) { if (game.livesImages[i]) game.livesImages[i].destroy(); } } // Clean up existing home button if (game.homeButton) { game.homeButton.destroy(); game.homeButton = null; } // Only create life images if not in training mode if (!trainingMode) { // Create life images (3 or 4 based on extra life ownership) var totalLives = storage.extraLifeOwned ? 4 : 3; game.livesImages = []; for (var i = 0; i < totalLives; i++) { var lifeImg = LK.getAsset('canbar', { anchorX: 0.5, anchorY: 0.5, width: 80, height: 80 }); lifeImg.x = -295 + i * 90; // Position side by side with 90px spacing, moved 55 pixels further to the left lifeImg.y = 60; LK.gui.topRight.addChild(lifeImg); game.livesImages.push(lifeImg); } } // Create home button in top left var homeBtn = new Container(); var homeImg = homeBtn.attachAsset('Home', { anchorX: 0.5, anchorY: 0.5, width: 135, height: 135, x: 0, y: 0 }); homeBtn.x = 130; // Move slightly to the right (1mm = ~5px) homeBtn.y = 360; // Move further down homeBtn.down = function (x, y, obj) { // Don't allow home button to work during countdown if (countdownActive) { return; } // Pause the game by setting gameStarted to false gameStarted = false; // Stop music LK.stopMusic(); // Play button sound var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } // Show confirmation dialog showExitConfirmation(); }; game.addChild(homeBtn); game.homeButton = homeBtn; // Remove tipTxt and border image immediately if present when game starts if (tipTxt) { tipTxt.destroy(); tipTxt = null; if (game._tipBg) { game._tipBg.destroy(); game._tipBg = null; } if (game._tipContainer) { game._tipContainer.destroy(); game._tipContainer = null; } } // --- 3 2 1 Go! Countdown --- var countdownColors = ["#ff2d2d", "#ffe066", "#7cff66", "#a259ff"]; var countdownTexts = ["3", "2", "1", "Go!"]; var countdownObjs = []; var countdownIdx = 0; function showCountdownStep(idx) { // Remove previous countdown text if any for (var i = 0; i < countdownObjs.length; i++) { if (countdownObjs[i]) { countdownObjs[i].destroy(); } } countdownObjs = []; if (idx < countdownTexts.length) { var txt = new Text2(countdownTexts[idx], { size: idx === 3 ? 180 : 160, fill: countdownColors[idx] }); txt.anchor.set(0.5, 0.5); txt.x = GAME_W / 2; txt.y = GAME_H / 2; game.addChild(txt); countdownObjs.push(txt); // Animate scale up and fade out txt.scale.set(1, 1); txt.alpha = 1; tween(txt, { scaleX: 1.25, scaleY: 1.25, alpha: 0.0 }, { duration: 600, delay: 400, onFinish: function onFinish() { txt.destroy(); } }); // Next step after 800ms LK.setTimeout(function () { showCountdownStep(idx + 1); }, 800); } else { // Countdown finished, start game gameStarted = true; countdownActive = false; // Countdown is no longer active } } showCountdownStep(0); } // --- Life Loss Function --- function loseLife() { lives--; // Animate the life image disappearing from left to right instead of right to left // Find the leftmost remaining life image (index 0, 1, or 2) var lifeToRemove = null; if (game.livesImages) { for (var i = 0; i < game.livesImages.length; i++) { if (game.livesImages[i] && game.livesImages[i].alpha > 0) { lifeToRemove = game.livesImages[i]; break; } } } if (lifeToRemove) { tween(lifeToRemove, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { lifeToRemove.destroy(); } }); } // Flash screen red for feedback LK.effects.flashScreen(0xff0000, 500); // Check if game over if (lives <= 0) { endGame(false); } } // --- End Game --- function endGame(win) { // Clean up for (var i = 0; i < notes.length; i++) { if (notes[i]) notes[i].destroy(); } notes = []; for (var i = 0; i < bullets.length; i++) { if (bullets[i]) bullets[i].destroy(); } bullets = []; // Clean up kucuk notes for (var i = 0; i < kucukNotes.length; i++) { if (kucukNotes[i]) kucukNotes[i].destroy(); } kucukNotes = []; // Reset wave system state waveActive = false; waveNumber = 0; lastWaveScore = 0; waveSpawnTimer = 0; // Reset kucuk note state kucukNoteActive = false; if (kucukNoteTimer) { LK.clearTimeout(kucukNoteTimer); kucukNoteTimer = null; } if (ball) { ball.destroy(); ball = null; } if (crosshair) { crosshair.destroy(); crosshair = null; } if (livesTxt) { livesTxt.destroy(); livesTxt = null; } // Clean up lives images if (game.livesImages) { for (var i = 0; i < game.livesImages.length; i++) { if (game.livesImages[i]) game.livesImages[i].destroy(); } game.livesImages = null; } // Clean up home button if (game.homeButton) { game.homeButton.destroy(); game.homeButton = null; } // Clean up score text and reset states if (scoreTxt) { scoreTxt.destroy(); scoreTxt = null; } // Reset training mode flag trainingMode = false; gameStarted = false; // Update high score for this difficulty if needed (skip for training mode) if (!trainingMode) { var score = LK.getScore(); var hsKey = "highScore_" + difficulty; if (typeof storage[hsKey] === "undefined" || score > storage[hsKey]) { storage[hsKey] = score; } // Add points to total currency storage.totalPoints += score; } LK.stopMusic(); if (win) { // Show win, then play menu music after popup closes LK.showYouWin(); LK.setTimeout(function () { LK.stopMusic(); LK.playMusic('Menu1', { loop: true }); }, 1200); } else { // Play go2 sound once when the player loses var go2Sound = LK.getSound('go2'); if (go2Sound && typeof go2Sound.play === "function") { go2Sound.play(); } // Play button sound for back-to-menu var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } // Delay Game Over screen by 2.5 seconds (2500ms) LK.setTimeout(function () { LK.showGameOver(); // After Game Over, play menu music after 1.2s as before LK.setTimeout(function () { LK.stopMusic(); LK.playMusic('Menu1', { loop: true }); }, 1200); }, 2500); } } // --- Note Spawning --- function spawnNote() { // Don't spawn regular notes during wave periods if (waveActive) { return; } // 15% chance to spawn NotaggNote, otherwise normal Note var isNotagg = Math.random() < 0.15; var note; if (isNotagg) { note = new NotaggNote(); } else { note = new Note(); } // Pick a random column, now including the far left (index 0) so notes can fall above the gun // allowedCols now includes 0,1,2,3,4 (all columns) var allowedCols = []; for (var i = 0; i < NOTE_COLS; i++) { allowedCols.push(i); } // Increase position variation: allow some random offset within each column var col = allowedCols[Math.floor(Math.random() * allowedCols.length)]; note.column = col; // Add random offset within the column for more variation var colOffset = 0; if (difficulty === 'slow') { colOffset = (Math.random() - 0.5) * (NOTE_COL_W * 0.3); // up to ±15% of col width } else if (difficulty === 'normal') { colOffset = (Math.random() - 0.5) * (NOTE_COL_W * 0.5); // up to ±25% of col width } else if (difficulty === 'fast') { colOffset = (Math.random() - 0.5) * (NOTE_COL_W * 0.7); // up to ±35% of col width } note.x = NOTE_MARGIN + NOTE_COL_W / 2 + col * NOTE_COL_W + colOffset; note.y = NOTE_START_Y; // Increase falling speed slightly per mode if (difficulty === 'slow') { note.speed = noteFallSpeed + 1.2 + Math.random() * 0.8; // 1.2-2.0 px/frame more } else if (difficulty === 'normal') { note.speed = noteFallSpeed + 2.2 + Math.random() * 1.2; // 2.2-3.4 px/frame more } else if (difficulty === 'fast') { note.speed = noteFallSpeed + 3.2 + Math.random() * 1.8; // 3.2-5 px/frame more } else { note.speed = noteFallSpeed; } notes.push(note); game.addChild(note); } // --- Wave System --- function startWave() { waveActive = true; waveStartTime = LK.ticks * (1000 / 60); // Convert ticks to milliseconds waveNumber++; waveSpawnTimer = LK.ticks; // Increase speed with each wave var speedMultiplier = 1 + (waveNumber - 1) * 0.3; // 30% faster each wave waveSpawnInterval = Math.max(600, 1200 - (waveNumber - 1) * 150); // Better spacing, minimum 600ms } function endWave() { waveActive = false; } function spawnWaveKucukNote() { // Create 3 fixed horizontal rows var rows = [GAME_H * 0.25, // Top row GAME_H * 0.45, // Middle row GAME_H * 0.65 // Bottom row ]; // Calculate total notes to spawn (5-7 per wave) var totalNotes = 5 + Math.floor(Math.random() * 3); // Random between 5-7 // Distribute notes across 3 rows as evenly as possible var notesPerRow = [Math.floor(totalNotes / 3), Math.floor(totalNotes / 3), Math.floor(totalNotes / 3)]; // Add remaining notes to random rows var remaining = totalNotes - (notesPerRow[0] + notesPerRow[1] + notesPerRow[2]); for (var r = 0; r < remaining; r++) { var randomRow = Math.floor(Math.random() * 3); notesPerRow[randomRow]++; } // Check if it's time to spawn a new wave set var timeInWave = LK.ticks - waveSpawnTimer; var waveInterval = 240; // 4 seconds between each complete wave spawn if (timeInWave % waveInterval === 0) { // Spawn all 3 rows at once with different movement directions for (var rowIndex = 0; rowIndex < 3; rowIndex++) { var notesToSpawn = notesPerRow[rowIndex]; if (notesToSpawn === 0) continue; // Alternate direction per row: even rows go left-to-right, odd rows go right-to-left var moveLeftToRight = rowIndex % 2 === 0; var baseSpeed = 8.5; // Increased from 4.5 to 8.5 for faster movement var waveSpeedMultiplier = 1 + (waveNumber - 1) * 0.3; var speed = baseSpeed * waveSpeedMultiplier; for (var noteIndex = 0; noteIndex < notesToSpawn; noteIndex++) { var note = new KucukNote(); // Set Y position for this row note.y = rows[rowIndex]; // Calculate horizontal spacing with proper distance between notes var noteSpacing = 200; // Minimum distance between notes if (moveLeftToRight) { // Start off-screen left, with proper spacing between notes note.x = -100 - noteIndex * noteSpacing; note.vx = speed; } else { // Start off-screen right, with proper spacing between notes note.x = GAME_W + 100 + noteIndex * noteSpacing; note.vx = -speed; } note.vy = 0; // No vertical movement for clean horizontal lines kucukNotes.push(note); game.addChild(note); } } } } // --- Kucuk Note Spawning --- function spawnKucukNote() { var note = new KucukNote(); // Randomly choose direction: 0 = left to right, 1 = right to left var direction = Math.floor(Math.random() * 2); if (direction === 0) { // Left to right note.x = -60; // Start off-screen left note.vx = 8 + Math.random() * 3; // Speed 8-11 px/frame - increased for faster movement } else { // Right to left note.x = GAME_W + 60; // Start off-screen right note.vx = -(8 + Math.random() * 3); // Speed -8 to -11 px/frame - increased for faster movement } // Random Y position in middle area of screen note.y = GAME_H * 0.3 + Math.random() * (GAME_H * 0.4); note.vy = (Math.random() - 0.5) * 2; // Slight vertical drift kucukNotes.push(note); game.addChild(note); // Activate kucuk note state - pause regular note spawning kucukNoteActive = true; // Clear any existing timer if (kucukNoteTimer) { LK.clearTimeout(kucukNoteTimer); } // Set timer to resume regular notes after 10 seconds kucukNoteTimer = LK.setTimeout(function () { kucukNoteActive = false; kucukNoteTimer = null; }, KUCUK_NOTE_DURATION); } // --- Difficulty Increase --- function maybeIncreaseDifficulty() { var score = LK.getScore(); if (score > 0 && score % 10 === 0 && score !== lastScore) { // Increase speed and spawn rate noteFallSpeed += 2; if (noteSpawnInterval > 20) noteSpawnInterval -= 6; lastScore = score; } } // --- Facekit Crosshair Update --- function updateCrosshair() { if (!crosshair) return; // Use facekit.noseTip or facekit.mouthCenter for aiming var fx = facekit.noseTip ? facekit.noseTip.x : facekit.mouthCenter ? facekit.mouthCenter.x : GAME_W / 2; var fy = facekit.noseTip ? facekit.noseTip.y : facekit.mouthCenter ? facekit.mouthCenter.y : GAME_H / 2; // Clamp to play area if (fx < CROSS_MIN_X) fx = CROSS_MIN_X; if (fx > CROSS_MAX_X) fx = CROSS_MAX_X; if (fy < CROSS_MIN_Y) fy = CROSS_MIN_Y; if (fy > CROSS_MAX_Y) fy = CROSS_MAX_Y; // Instantly set crosshair position (no smoothing, no tween) crosshair.x = fx; crosshair.y = fy; } // --- Fire Bullet --- function fireBullet() { if (!canShoot || !gameStarted) return; canShoot = false; // Find if crosshair is over a note (regular notes) var hitNote = null; for (var i = 0; i < notes.length; i++) { var n = notes[i]; if (!n.hit && crosshair && crosshair.intersects(n)) { hitNote = n; break; } } // Check for kucuk note hits var hitKucukNote = null; for (var i = 0; i < kucukNotes.length; i++) { var kn = kucukNotes[i]; if (!kn.hit && crosshair && crosshair.intersects(kn)) { hitKucukNote = kn; break; } } // Fire bullet towards crosshair var b = new Bullet(); if (!ball) return; // Safety check to prevent null reference error b.x = ball.x; b.y = ball.y; // Direction vector var dx = crosshair.x - ball.x; var dy = crosshair.y - ball.y; var len = Math.sqrt(dx * dx + dy * dy); if (len === 0) { dx = 0; dy = -1; len = 1; } b.vx = BULLET_SPEED * dx / len; b.vy = BULLET_SPEED * dy / len; bullets.push(b); game.addChild(b); // If hitNote, mark as hit (so only one bullet per note) if (hitNote) { // If it's a NotaggNote, lose a life (unless training mode) if (hitNote.isNotagg && !trainingMode) { loseLife(); if (lives <= 0) return; // Game ended in loseLife function } hitNote.hit = true; } // If hitKucukNote, mark as hit and remove immediately if (hitKucukNote) { hitKucukNote.hit = true; // Remove from array and destroy quickly for (var i = 0; i < kucukNotes.length; i++) { if (kucukNotes[i] === hitKucukNote) { kucukNotes.splice(i, 1); break; } } hitKucukNote.destroy(); // Award 2 points for hitting kucuk note LK.setScore(LK.getScore() + 2); if (!trainingMode) { scoreTxt.setText(LK.getScore()); } // Spawn floating music note effect var effect = new MusicNoteEffect(); // Scale down the effect if using Silah3 or Silah4 weapon if (currentWeapon === 'Silah3') { effect.scale.set(0.6, 0.6); // Make Silah3 explosions 60% of normal size } else if (currentWeapon === 'Silah4') { effect.scale.set(0.5, 0.5); // Make Silah4 explosions 50% of normal size } effect.start(hitKucukNote.x, hitKucukNote.y); game.addChild(effect); } // Play note sound (simulate: play a sound per note column) // Stop all note sounds before playing a new one to prevent overlap for (var i = 0; i < NOTE_COLS; i++) { var s = LK.getSound('note' + i); if (s && typeof s.stop === "function") s.stop(); } var soundId = 'note' + (hitNote ? hitNote.column : Math.floor(Math.random() * NOTE_COLS)); LK.getSound(soundId).play(); // Allow next shot after a normal delay (normal fire rate) LK.setTimeout(function () { canShoot = true; }, 320); } // --- Main Game Loop --- game.down = function (x, y, obj) { if (gameStarted) { fireBullet(); } }; game.update = function () { if (!gameStarted) return; // --- Optimize: Use local variables, avoid per-frame allocations, and minimize nested loops --- // Update crosshair position from facekit updateCrosshair(); // Spawn notes if (LK.ticks - lastNoteSpawnTick >= noteSpawnInterval) { spawnNote(); lastNoteSpawnTick = LK.ticks; } // Wave system: trigger waves every 10 points var currentScore = LK.getScore(); // Check if we should start a new wave if (currentScore > 0 && currentScore % 10 === 0 && currentScore !== lastWaveScore && !waveActive) { startWave(); lastWaveScore = currentScore; } // Handle active wave if (waveActive) { var waveElapsed = LK.ticks * (1000 / 60) - waveStartTime; // Convert ticks to milliseconds // Check if wave should end if (waveElapsed >= waveDuration) { endWave(); } else { // Continuously call spawnWaveKucukNote - it handles its own timing internally spawnWaveKucukNote(); } } // --- Update kucuk notes --- for (var i = kucukNotes.length - 1; i >= 0; i--) { var kn = kucukNotes[i]; kn.update(); // Remove if moved off screen horizontally or vertically (no game over for kucuk notes) if (kn.x < -200 || kn.x > GAME_W + 200 || kn.y < -100 || kn.y > GAME_H + 100) { kn.destroy(); kucukNotes.splice(i, 1); } } // --- Update notes --- // Use a single pass to update and remove notes that are offscreen or hit for (var i = notes.length - 1; i >= 0; i--) { var n = notes[i]; // Only update regular notes if kucuk note is not active if (!kucukNoteActive) { n.update(); } // If note falls below screen, handle based on note type if (n.y > GAME_H + NOTE_HEIGHT / 2) { // If it's a NotaggNote or training mode, just remove it, do not lose life if (n.isNotagg || trainingMode) { n.visible = false; n.destroy(); notes.splice(i, 1); continue; } // For all other notes, losing them costs a life loseLife(); n.visible = false; n.destroy(); notes.splice(i, 1); continue; } } // --- Update bullets --- // Use local references to avoid repeated property lookups for (var i = bullets.length - 1; i >= 0; i--) { var b = bullets[i]; b.update(); // Remove bullet if out of bounds if (b.x < -100 || b.x > GAME_W + 100 || b.y < -100 || b.y > GAME_H + 100) { b.destroy(); bullets.splice(i, 1); continue; } // --- Optimize: Only check for collisions with visible, unhit notes --- var bulletHit = false; for (var j = notes.length - 1; j >= 0; j--) { var n = notes[j]; if (n.hit || n.visible === false) continue; // Initialize lastWasIntersecting if not set if (typeof b.lastWasIntersecting === "undefined") b.lastWasIntersecting = false; var isIntersecting = b.intersects(n); // Make hitbox more forgiving: allow hit if bullet is close to note center (within 0.6*NOTE_WIDTH and 0.6*NOTE_HEIGHT) var forgivingHit = false; var dx = Math.abs(b.x - n.x); var dy = Math.abs(b.y - n.y); if (dx < NOTE_WIDTH * 0.6 && dy < NOTE_HEIGHT * 0.6) { forgivingHit = true; } // Only allow hit if note is not already hit and not already destroyed, and bullet just started intersecting or is within forgiving hitbox if (b.lastWasIntersecting === false && isIntersecting || forgivingHit) { // If it's a NotaggNote, lose a life (unless training mode) if (n.isNotagg && !trainingMode) { loseLife(); if (lives <= 0) return; // Game ended in loseLife function } n.hit = true; // Mark as hit immediately to prevent double hits notes.splice(j, 1); // Remove from notes array immediately to prevent further processing LK.setScore(LK.getScore() + 1); if (!trainingMode) { scoreTxt.setText(LK.getScore()); } // Animate note color to gray/black, then remove if (n.children && n.children.length > 0 && n.children[0]) { var noteAsset = n.children[0]; tween(noteAsset, { tint: 0x222222 }, { duration: 60, onFinish: function (noteAsset, n) { return function () { if (noteAsset && noteAsset.parent) { noteAsset.parent.removeChild(noteAsset); } n.visible = false; n.destroy(); }; }(noteAsset, n) }); } else { n.visible = false; n.destroy(); } // Spawn floating music note effect at note position var effect = new MusicNoteEffect(); // Scale down the effect if using Silah3 or Silah4 weapon if (currentWeapon === 'Silah3') { effect.scale.set(0.6, 0.6); // Make Silah3 explosions 60% of normal size } else if (currentWeapon === 'Silah4') { effect.scale.set(0.5, 0.5); // Make Silah4 explosions 50% of normal size } effect.start(n.x, n.y); game.addChild(effect); b.destroy(); bullets.splice(i, 1); // Difficulty up maybeIncreaseDifficulty(); // Removed win condition - game is now infinite bulletHit = true; break; } b.lastWasIntersecting = isIntersecting; } // Check bullet collision with kucuk notes if (!bulletHit) { for (var j = kucukNotes.length - 1; j >= 0; j--) { var kn = kucukNotes[j]; if (kn.hit) continue; if (b.intersects(kn)) { kn.hit = true; kucukNotes.splice(j, 1); // Award 2 points LK.setScore(LK.getScore() + 2); if (!trainingMode) { scoreTxt.setText(LK.getScore()); } // Quick destruction with tween tween(kn, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 100, onFinish: function onFinish() { kn.destroy(); } }); // Spawn floating music note effect var effect = new MusicNoteEffect(); // Scale down the effect if using Silah3 or Silah4 weapon if (currentWeapon === 'Silah3') { effect.scale.set(0.6, 0.6); // Make Silah3 explosions 60% of normal size } else if (currentWeapon === 'Silah4') { effect.scale.set(0.5, 0.5); // Make Silah4 explosions 50% of normal size } effect.start(kn.x, kn.y); game.addChild(effect); b.destroy(); bullets.splice(i, 1); // Removed win condition - game is now infinite bulletHit = true; break; } } } if (bulletHit) continue; } }; // --- Show Difficulty Menu on Start --- showDifficultyMenu(); // Prevent in-game sounds from playing in the menu by disabling their playback when not in game // Patch LK.getSound to return a dummy object with a no-op play() if not gameStarted var _LK_getSound = LK.getSound; LK.getSound = function (id) { if (!gameStarted) { return { play: function play() {} }; } return _LK_getSound.call(LK, id); }; /**** * Asset Initialization (for static analysis) ****/ // Notes (5 columns, 5 colors) for (var i = 0; i < NOTE_COLS; i++) {} // --- Exit Confirmation Dialog --- function showExitConfirmation() { // Pause the game var gamePaused = true; var confirmationDialog = new Container(); // Semi-transparent background overlay var overlay = LK.getAsset('softbg2', { anchorX: 0.5, anchorY: 0.5, width: GAME_W, height: GAME_H, x: GAME_W / 2, y: GAME_H / 2, alpha: 0.7, color: 0x000000, shape: 'box' }); confirmationDialog.addChild(overlay); // Dialog box background removed per request // Question text var questionTxt = new Text2("Are you sure you want to exit the game?", { size: 60, fill: 0xFFFFFF }); questionTxt.anchor.set(0.5, 0.5); questionTxt.x = GAME_W / 2; questionTxt.y = GAME_H / 2 - 80; confirmationDialog.addChild(questionTxt); // Yes button var yesBtn = new Container(); var yesBg = yesBtn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 100, color: 0xff4444, shape: 'box' }); var yesTxt = new Text2("YES", { size: 50, fill: 0xFFFFFF }); yesTxt.anchor.set(0.5, 0.5); yesTxt.x = 0; yesTxt.y = 0; yesBtn.addChild(yesTxt); yesBtn.x = GAME_W / 2 - 150; yesBtn.y = GAME_H / 2 + 80; // No button var noBtn = new Container(); var noBg = noBtn.attachAsset('btnbg', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 100, color: 0x44ff44, shape: 'box' }); var noTxt = new Text2("NO", { size: 50, fill: 0xFFFFFF }); noTxt.anchor.set(0.5, 0.5); noTxt.x = 0; noTxt.y = 0; noBtn.addChild(noTxt); noBtn.x = GAME_W / 2 + 150; noBtn.y = GAME_H / 2 + 80; confirmationDialog.addChild(yesBtn); confirmationDialog.addChild(noBtn); // Yes button functionality yesBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } hideExitConfirmation(); exitToMainMenu(); }; // No button functionality noBtn.down = function (x, y, obj) { var buttonSound = LK.getSound('buton'); if (buttonSound && typeof buttonSound.play === "function") { buttonSound.play(); } hideExitConfirmation(); // Resume game by setting gameStarted to true gameStarted = true; // Resume music var musicChoices; if (difficulty === 'fast') { musicChoices = ['Ph6', 'Ph6', 'Ph6', 'Piano1', 'P2', 'P3', 'P4', 'P5']; } else { musicChoices = ['Piano1', 'P2', 'P3', 'P4', 'P5']; } var selectedMusic = musicChoices[Math.floor(Math.random() * musicChoices.length)]; LK.playMusic(selectedMusic, { loop: true }); }; // Add to game game.addChild(confirmationDialog); game._exitConfirmation = confirmationDialog; } function hideExitConfirmation() { if (game._exitConfirmation) { game._exitConfirmation.destroy(); game._exitConfirmation = null; } } function exitToMainMenu() { // Clean up game state gameStarted = false; countdownActive = false; // Reset countdown state when going home // Reset score to prevent it showing in menu LK.setScore(0); // Clean up score text and reset training mode state if (scoreTxt) { scoreTxt.destroy(); scoreTxt = null; } // Reset training mode flag trainingMode = false; // Clean up all game objects for (var i = 0; i < notes.length; i++) { if (notes[i]) notes[i].destroy(); } notes = []; for (var i = 0; i < bullets.length; i++) { if (bullets[i]) bullets[i].destroy(); } bullets = []; for (var i = 0; i < kucukNotes.length; i++) { if (kucukNotes[i]) kucukNotes[i].destroy(); } kucukNotes = []; // Reset wave system state waveActive = false; waveNumber = 0; lastWaveScore = 0; waveSpawnTimer = 0; // Reset kucuk note state kucukNoteActive = false; if (kucukNoteTimer) { LK.clearTimeout(kucukNoteTimer); kucukNoteTimer = null; } if (ball) { ball.destroy(); ball = null; } if (crosshair) { crosshair.destroy(); crosshair = null; } if (livesTxt) { livesTxt.destroy(); livesTxt = null; } // Clean up lives images if (game.livesImages) { for (var i = 0; i < game.livesImages.length; i++) { if (game.livesImages[i]) game.livesImages[i].destroy(); } game.livesImages = null; } // Clean up home button itself if (game.homeButton) { game.homeButton.destroy(); game.homeButton = null; } // Stop music and return to menu LK.stopMusic(); // Small delay before playing menu music to ensure clean transition LK.setTimeout(function () { LK.stopMusic(); // Double-stop to ensure cleanup LK.playMusic('Menu1', { loop: true }); }, 100); // Show difficulty menu directly showDifficultyMenu(); }
===================================================================
--- original.js
+++ change.js
@@ -1336,8 +1336,12 @@
// Don't allow home button to work during countdown
if (countdownActive) {
return;
}
+ // Pause the game by setting gameStarted to false
+ gameStarted = false;
+ // Stop music
+ LK.stopMusic();
// Play button sound
var buttonSound = LK.getSound('buton');
if (buttonSound && typeof buttonSound.play === "function") {
buttonSound.play();
@@ -2101,9 +2105,21 @@
if (buttonSound && typeof buttonSound.play === "function") {
buttonSound.play();
}
hideExitConfirmation();
- // Resume game - no additional action needed
+ // Resume game by setting gameStarted to true
+ gameStarted = true;
+ // Resume music
+ var musicChoices;
+ if (difficulty === 'fast') {
+ musicChoices = ['Ph6', 'Ph6', 'Ph6', 'Piano1', 'P2', 'P3', 'P4', 'P5'];
+ } else {
+ musicChoices = ['Piano1', 'P2', 'P3', 'P4', 'P5'];
+ }
+ var selectedMusic = musicChoices[Math.floor(Math.random() * musicChoices.length)];
+ LK.playMusic(selectedMusic, {
+ loop: true
+ });
};
// Add to game
game.addChild(confirmationDialog);
game._exitConfirmation = confirmationDialog;
Make a wallpaper that features small music notes and guns. The image should look good for the game and not appear pixelated.. In-Game asset. 2d. High contrast. No shadows
A rounded rectangle frame with both the inside and the border colored — no text inside. Colors can be yellow, blue, or white.. In-Game asset. 2d. High contrast. No shadows
I want a button box with rounded corners and a colorful design using blue, yellow, and white colors. In-Game asset. There should be no text inside the button.
dörtken şekilde olan üzerinde 🎵 simgesi olan bir nota. In-Game asset. 2d. High contrast. No shadows
Market sepeti sarı renk oyuncak gibi. In-Game asset. 2d. High contrast. No shadows
mavi sarı renkte kenarlaı düz dörtken olan bir kart ve ya çercive. In-Game asset. 2d. High contrast. No shadows
Mavi arka plan üzerinde sarı müzik notası simgeleri ve market arabası simgeleri olsun. In-Game asset. 2d. High contrast. No shadows
beyaz ev simgesi. In-Game asset. 2d. High contrast. No shadows
Yuvarlak altın para ortasında 🎶 müzik notası. In-Game asset. 2d. High contrast. No shadows
sarı dörtgen kenarkarı açık mavi. In-Game asset. 2d. High contrast. No shadows
beyaz bir İ buton görseli. In-Game asset. 2d. High contrast. No shadows
küçük bir kırmızı kalp ve içinde beyaz 🎶 notası. In-Game asset. 2d. High contrast. No shadows