User prompt
piano butonunu fix
User prompt
Maracastan sonra piano butonuna basınca piano asseti spawn olsun. Spawn olan piyanonun konumuna ekranına gidebilmek için arrow4 asseti de spawn olsun.
User prompt
piano butonuna basınca piano asseti satın alalım
User prompt
10 finger olmadan cymbal butonu hep kilitli kalsın
Code edit (1 edits merged)
Please save this source code
User prompt
piano butonu fixleyelim ve okları fixleyelim
User prompt
pianonun konumunu çok az sağa kaydıralım. Piano satın alındıktan sonra Drumstick buttonu pianist olsun ve 20000 olsun, piano ekranında 10 adet pianist satın alınmadıysa audience kilitli kalsın, en sağdaki buton flute olsun. ve 50 tane audience olmadan flute butonu kilitli kalsın.
User prompt
piano ekranla birlikte kaymasın maracasın sağ tarafında bir konuma sabit kalsın ok işareti ile maracasa geri döndüğümüzde piano sağda kalsın.
User prompt
pianonun konumu maracas ile orantılı uzaklıkta olsun ve konumunu maracas ile belirli mesafede sabitleyelim
User prompt
5 adet maracas shake almadan piano hep kilitli olsun, cymbal ekranında da olsa piano 5 adet maracas shake kontrol yapsın
User prompt
piano assetini sağa doğru kaydıralım ve konumu sabit olsun
User prompt
piano butonu audience kilitliyken kilitli olsun
User prompt
maracas butonu audience kilitli iken kilitli görünsün
User prompt
audience kilitli ise en sağdaki buttonların da kilidi açılmasın.
User prompt
piano asseti görünmüyor
User prompt
pianonun konumu spawn olduğu yerde sabitlensin, panonun konumunu çok az sağa kaydıralım
User prompt
panoya tıklayabilelim ve ses asseti ekleyelim
User prompt
Piano 1 adet asset spawn olsun.
User prompt
Arrowback4 ile geri döndüğümüzde pianomuz konumunda kalsın.
User prompt
pianoyu satın alınca arrow4 ile piano ekranına kayalım.
User prompt
Piano konumunu sağ tarafa doğru kaydıralım ve oraya sabitleyelim. Diğer konumları fixleyelim.
User prompt
Pianonun konumunu sağ tarafa doğru kaydıralım
User prompt
Pianoyu baya sağa kaydıralım.
User prompt
piano konumunu biraz aşağıya alalım maracas ile aynı hizada olsun. Baya sağa kaydıralım.
User prompt
Piano butonu kilitli olsun. Audience 30 olmadan kilidi açılmasın. Kilit açıldıktan sonra piano satın almak 10000 fiyat olsun, butona tıkladığımızda piano asseti oluşsun.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var ArrowButton = Container.expand(function () { var self = Container.call(this); self.arrowShape = null; self.assetType = 'arrow'; // Default asset type self.init = function (assetType) { if (assetType) { self.assetType = assetType; } self.arrowShape = self.attachAsset(self.assetType, { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); }; self.clickHandler = null; self.down = function () { if (self.clickHandler) { self.clickHandler(); } if (self.arrowShape) { tween(self.arrowShape, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, onFinish: function onFinish() { tween(self.arrowShape, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); } }; return self; }); var Audience = Container.expand(function () { var self = Container.call(this); // Select audience asset sequentially var audienceAssets = ['audience1', 'audience2', 'audience3', 'audience4', 'audience5', 'audience6', 'audience7', 'audience8']; var selectedAsset; // If guitar is purchased, use reverse order starting from audience8 if (guitarPurchased) { // Reverse order: audience8, audience7, audience6, etc. selectedAsset = audienceAssets[7 - audienceCounter % audienceAssets.length]; } else { // Normal order for initial audiences selectedAsset = audienceAssets[audienceCounter % audienceAssets.length]; } audienceCounter++; // Increment counter for next audience self.audienceGraphics = self.attachAsset(selectedAsset, { anchorX: 0.5, anchorY: 0.5 }); self.instrument = null; self.multiplier = 1.2; self.update = function () { // Check if this is a clap tick - now every 30 ticks (double speed) if ((LK.ticks + 28) % 30 === 0) { // Determine clap pattern based on cycle (now 16 phases instead of 8) var clapCycle = Math.floor((LK.ticks + 28) / 30) % 16; if (clapCycle === 6 || clapCycle === 7) { // Double clap animation (bigger) tween(self, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); } else if (clapCycle === 14 || clapCycle === 15) { // Four times clap animation (biggest) tween(self, { scaleX: 1.15, scaleY: 1.15 }, { duration: 100, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); } else { // Single clap animation (smaller) tween(self, { scaleX: 1.05, scaleY: 1.05 }, { duration: 100, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); } } }; self.setInstrument = function (type) { if (self.instrument) { self.instrument.destroy(); } self.instrument = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5, x: 30, y: 0 }); }; return self; }); var AutoCymbalstick = Container.expand(function () { var self = Container.call(this); var stickGraphics = self.attachAsset('autocymbalstick', { anchorX: 0.5, anchorY: 0.9 }); self.speed = 60; // 60 CBM (Cymbal Beats per Minute) - synchronized with drum self.income = 10; // 10 gold per hit self.animating = false; self.tickCounter = 0; self.cymbalReference = null; self.update = function () { self.tickCounter++; // Hit every 120 ticks (30 CBM = 30 beats per minute at 60 FPS) - half speed if (self.tickCounter >= 120 && !self.animating) { self.tickCounter = 0; self.animate(); } }; self.animate = function () { if (self.animating) { return; } self.animating = true; tween(stickGraphics, { rotation: 0.3 }, { duration: 300, onFinish: function onFinish() { // Generate gold when hitting var startGold = gold; gold += self.income; // Smooth gold animation tween({ value: displayedGold }, { value: gold }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { displayedGold = gold; } }); var tweenObj = { value: displayedGold }; tween(tweenObj, { value: gold }, { duration: 300, easing: tween.easeOut }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); // Play cymbal sound LK.getSound('cymbalhit').play(); // Visual feedback on cymbal if reference exists if (self.cymbalReference) { var cymbalGraphics = self.cymbalReference.children[0]; tween(cymbalGraphics, { scaleX: 1.1, scaleY: 1.1 }, { duration: 50, onFinish: function onFinish() { tween(cymbalGraphics, { scaleX: 1, scaleY: 1 }, { duration: 50 }); } }); } tween(stickGraphics, { rotation: 0 }, { duration: 200, onFinish: function onFinish() { self.animating = false; } }); } }); }; return self; }); var AutoDrumstick = Container.expand(function () { var self = Container.call(this); var stickGraphics = self.attachAsset('autodrumstick', { anchorX: 0.5, anchorY: 0.9 }); self.speed = 1; self.income = 1; self.animating = false; self.tickCounter = 0; self.drumReference = null; self.update = function () { self.tickCounter++; // Hit every 60 ticks (60 BPM = 1 hit per second at 60 FPS) if (self.tickCounter >= 60 && !self.animating) { self.tickCounter = 0; self.animate(); } }; self.animate = function () { if (self.animating) { return; } self.animating = true; tween(stickGraphics, { rotation: 0.3 }, { duration: 300, onFinish: function onFinish() { // Generate gold when hitting var startGold = gold; gold += self.income; // Smooth gold animation tween({ value: displayedGold }, { value: gold }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { displayedGold = gold; } }); var tweenObj = { value: displayedGold }; tween(tweenObj, { value: gold }, { duration: 300, easing: tween.easeOut }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); // Play drum sound LK.getSound('drumhit').play(); // Visual feedback on drum if reference exists if (self.drumReference) { var drumGraphics = self.drumReference.children[0]; tween(drumGraphics, { scaleX: 1.1, scaleY: 1.1 }, { duration: 50, onFinish: function onFinish() { tween(drumGraphics, { scaleX: 1, scaleY: 1 }, { duration: 50 }); } }); } tween(stickGraphics, { rotation: 0 }, { duration: 200, onFinish: function onFinish() { self.animating = false; } }); } }); }; return self; }); var AutoFinger = Container.expand(function () { var self = Container.call(this); var fingerGraphics = self.attachAsset('finger', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1, rotation: -Math.PI / 2 // Rotate 90 degrees counterclockwise }); self.speed = 1; self.income = 1500; // Higher income than drumstick self.animating = false; self.tickCounter = 0; self.guitarReference = null; self.update = function () { self.tickCounter++; // Click every 360 ticks (10 CBM = 1 click per 6 seconds = 360 ticks at 60 FPS) if (self.tickCounter >= 360 && !self.animating) { self.tickCounter = 0; self.animate(); } }; self.animate = function () { if (self.animating) { return; } self.animating = true; // Vertical strumming motion - move up more tween(self, { y: self.y - 80 // Increased from 50 to 80 for more upward movement }, { duration: 200, onFinish: function onFinish() { // Generate gold when strumming var startGold = gold; gold += self.income; // Smooth gold animation tween({ value: displayedGold }, { value: gold }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { displayedGold = gold; } }); var tweenObj = { value: displayedGold }; tween(tweenObj, { value: gold }, { duration: 300, easing: tween.easeOut }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); // Play guitar sound LK.getSound('guitarhit').play(); // Visual feedback on guitar if reference exists if (self.guitarReference) { var guitarGraphics = self.guitarReference.children[0]; tween(guitarGraphics, { rotation: 0.1 }, { duration: 50, onFinish: function onFinish() { tween(guitarGraphics, { rotation: 0 }, { duration: 50 }); } }); } // Return to original position - move down tween(self, { y: self.y + 80 // Increased from 50 to 80 to match upward movement }, { duration: 200, onFinish: function onFinish() { self.animating = false; } }); } }); }; return self; }); var BuyButton = Container.expand(function () { var self = Container.call(this); var buttonBg = self.attachAsset('buyButton', { anchorX: 0.5, anchorY: 0.5 }); self.titleText = new Text2('', { size: 40, fill: '#ffffff' }); self.titleText.anchor.set(0.5, 0.5); self.titleText.y = -15; self.addChild(self.titleText); self.costText = new Text2('', { size: 30, fill: '#ffffff' }); self.costText.anchor.set(0.5, 0.5); self.costText.y = 15; self.addChild(self.costText); self.countText = new Text2('', { size: 50, fill: '#FFD700' }); self.countText.anchor.set(0.5, 0.5); self.countText.x = -150; self.addChild(self.countText); self.lockIcon = null; self.updateButton = function (title, cost, canAfford, count, isLocked, lockMessage) { self.titleText.setText(title); self.costText.setText('$' + cost); // Show count for items that should display count (not undefined and not zero) if (count !== undefined && count !== 0) { self.countText.setText(count.toString()); self.countText.visible = true; } else { self.countText.visible = false; } if (isLocked) { buttonBg.tint = 0x404040; self.interactive = false; // Hide button text when locked self.titleText.visible = false; self.costText.visible = false; self.countText.visible = false; if (!self.lockIcon) { self.lockIcon = self.attachAsset('lock', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -10 }); } self.lockIcon.visible = true; } else { // Show button text when unlocked self.titleText.visible = true; self.costText.visible = true; if (self.lockIcon) { self.lockIcon.visible = false; } buttonBg.tint = canAfford ? 0x4CAF50 : 0x808080; self.interactive = canAfford; } }; self.down = function () { tween(buttonBg, { scaleX: 0.95, scaleY: 0.95 }, { duration: 100, onFinish: function onFinish() { tween(buttonBg, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); }; return self; }); var Cymbal = Container.expand(function () { var self = Container.call(this); var cymbalGraphics = self.attachAsset('cymbal', { anchorX: 0.5, anchorY: 0.5 }); // Add permanent cymbal stick self.cymbalstick = self.attachAsset('playerCymbalstick', { anchorX: 0.5, anchorY: 0.9, x: 250, y: -50, rotation: -0.3 }); self.canPlay = true; self.lastPlayTime = 0; self.cymbalstickAnimating = false; self.play = function () { if (!self.canPlay || self.cymbalstickAnimating) { return; } var currentTime = Date.now(); var timeSinceLastPlay = currentTime - self.lastPlayTime; self.lastPlayTime = currentTime; // Check for perfect rhythm var perfectTiming = Math.abs(timeSinceLastPlay - 1000) < 100; // Calculate animation speed based on tap speed var tapSpeed = timeSinceLastPlay > 0 ? Math.min(timeSinceLastPlay, 1000) : 1000; var animationSpeed = tapSpeed / 1000; var strikeDuration = Math.max(50, 150 * animationSpeed); var returnDuration = Math.max(100, 200 * animationSpeed); // Set animation state self.cymbalstickAnimating = true; // Animate cymbal stick strike tween(self.cymbalstick, { rotation: -0.6 }, { duration: strikeDuration, easing: tween.easeOut, onFinish: function onFinish() { tween(self.cymbalstick, { rotation: -0.3 }, { duration: returnDuration, easing: tween.easeInOut, onFinish: function onFinish() { self.cymbalstickAnimating = false; } }); } }); // Visual feedback - cymbal scale tween(cymbalGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, onFinish: function onFinish() { tween(cymbalGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); // Calculate reward var reward = perfectTiming ? goldPerTap * 2 : goldPerTap; var startGold = gold; gold += reward; // Smooth gold animation tween({ value: displayedGold }, { value: gold }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { displayedGold = gold; } }); var tweenObj = { value: displayedGold }; tween(tweenObj, { value: gold }, { duration: 300, easing: tween.easeOut }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); // Create light flash effect var lightFlash = self.attachAsset('goldCoin', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, scaleY: 3, alpha: 0.8 }); lightFlash.tint = perfectTiming ? 0xFFD700 : 0xFFFFFF; tween(lightFlash, { scaleX: 5, scaleY: 5, alpha: 0 }, { duration: 300, onFinish: function onFinish() { lightFlash.destroy(); } }); // Create floating text var floatingGold = game.addChild(new FloatingText('+' + reward, perfectTiming ? 0xFFD700 : 0xFFFFFF)); floatingGold.x = self.x; floatingGold.y = self.y - 50; // Play cymbal sound LK.getSound('cymbalhit').play(); // Create music note effect if (perfectTiming) { var note = game.addChild(new MusicNote()); note.x = self.x + (Math.random() - 0.5) * 100; note.y = self.y - 100; } }; self.down = function () { self.play(); }; return self; }); var Drum = Container.expand(function () { var self = Container.call(this); var drumGraphics = self.attachAsset('drum', { anchorX: 0.5, anchorY: 0.5 }); // Add permanent drumstick self.drumstick = self.attachAsset('playerDrumstick', { anchorX: 0.5, anchorY: 0.9, x: 210, y: -220, rotation: -0.3 }); self.canTap = true; self.lastTapTime = 0; self.drumstickAnimating = false; self.tap = function () { if (!self.canTap || self.drumstickAnimating) { return; } var currentTime = Date.now(); var timeSinceLastTap = currentTime - self.lastTapTime; self.lastTapTime = currentTime; // Check for perfect rhythm (60 BPM = 1000ms between beats) var perfectTiming = Math.abs(timeSinceLastTap - 1000) < 100; // Calculate animation speed based on tap speed var tapSpeed = timeSinceLastTap > 0 ? Math.min(timeSinceLastTap, 1000) : 1000; var animationSpeed = tapSpeed / 1000; // Normalize to 0-1 range var strikeDuration = Math.max(50, 150 * animationSpeed); // Faster taps = shorter animation var returnDuration = Math.max(100, 200 * animationSpeed); // Visual feedback - drum scale tween(drumGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, onFinish: function onFinish() { tween(drumGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); // Set animation state self.drumstickAnimating = true; // Animate drumstick strike with dynamic duration - reversed animation tween(self.drumstick, { rotation: -0.6 }, { duration: strikeDuration, easing: tween.easeOut, onFinish: function onFinish() { tween(self.drumstick, { rotation: -0.3 }, { duration: returnDuration, easing: tween.easeInOut, onFinish: function onFinish() { self.drumstickAnimating = false; } }); } }); // Calculate reward var reward = perfectTiming ? goldPerTap * 2 : goldPerTap; var startGold = gold; gold += reward; // Smooth gold animation tween({ value: displayedGold }, { value: gold }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { displayedGold = gold; } }); var tweenObj = { value: displayedGold }; tween(tweenObj, { value: gold }, { duration: 300, easing: tween.easeOut }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); // Create light flash effect var lightFlash = self.attachAsset('goldCoin', { anchorX: 0.5, anchorY: 0.5, scaleX: 10, scaleY: 10, alpha: 0.8 }); lightFlash.tint = perfectTiming ? 0xFFD700 : 0xFFFFFF; tween(lightFlash, { scaleX: 15, scaleY: 15, alpha: 0 }, { duration: 300, onFinish: function onFinish() { lightFlash.destroy(); } }); // Create floating text var floatingGold = game.addChild(new FloatingText('+' + reward, perfectTiming ? 0xFFD700 : 0xFFFFFF)); floatingGold.x = self.x; floatingGold.y = self.y - 50; // Play sound LK.getSound('drumhit').play(); // Create music note effect if (perfectTiming) { var note = game.addChild(new MusicNote()); note.x = self.x + (Math.random() - 0.5) * 100; note.y = self.y - 100; } }; self.down = function () { self.tap(); }; return self; }); var FloatingText = Container.expand(function () { var self = Container.call(this); self.init = function (text, color) { self.textObj = new Text2(text, { size: 60, fill: '#' + color.toString(16).padStart(6, '0') }); self.textObj.anchor.set(0.5, 0.5); self.addChild(self.textObj); tween(self, { y: self.y - 100, alpha: 0 }, { duration: 1000, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); var Guitar = Container.expand(function () { var self = Container.call(this); var guitarGraphics = self.attachAsset('guitar', { anchorX: 0.5, anchorY: 0.5 }); self.canPlay = true; self.lastPlayTime = 0; self.play = function () { if (!self.canPlay) { return; } var currentTime = Date.now(); var timeSinceLastPlay = currentTime - self.lastPlayTime; self.lastPlayTime = currentTime; // Check for perfect rhythm var perfectTiming = Math.abs(timeSinceLastPlay - 1000) < 100; // Visual feedback - guitar scale tween(guitarGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, onFinish: function onFinish() { tween(guitarGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); // Calculate reward var reward = perfectTiming ? goldPerTap * 2 : goldPerTap; var startGold = gold; gold += reward; // Smooth gold animation tween({ value: displayedGold }, { value: gold }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { displayedGold = gold; } }); var tweenObj = { value: displayedGold }; tween(tweenObj, { value: gold }, { duration: 300, easing: tween.easeOut }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); // Create light flash effect var lightFlash = self.attachAsset('goldCoin', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, scaleY: 3, alpha: 0.8 }); lightFlash.tint = perfectTiming ? 0xFFD700 : 0xFFFFFF; tween(lightFlash, { scaleX: 5, scaleY: 5, alpha: 0 }, { duration: 300, onFinish: function onFinish() { lightFlash.destroy(); } }); // Create floating text var floatingGold = game.addChild(new FloatingText('+' + reward, perfectTiming ? 0xFFD700 : 0xFFFFFF)); floatingGold.x = self.x; floatingGold.y = self.y - 50; // Play guitar sound LK.getSound('guitarhit').play(); // Create music note effect if (perfectTiming) { var note = game.addChild(new MusicNote()); note.x = self.x + (Math.random() - 0.5) * 100; note.y = self.y - 100; } }; self.down = function () { self.play(); }; return self; }); var MusicNote = Container.expand(function () { var self = Container.call(this); var noteGraphics = self.attachAsset('musicNote', { anchorX: 0.5, anchorY: 0.5 }); tween(self, { y: self.y - 200, alpha: 0 }, { duration: 1500, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); tween(noteGraphics, { rotation: Math.PI * 2 }, { duration: 1500 }); return self; }); var Piano = Container.expand(function () { var self = Container.call(this); var pianoGraphics = self.attachAsset('piano', { anchorX: 0.5, anchorY: 0.5 }); self.canPlay = true; self.lastPlayTime = 0; self.play = function () { if (!self.canPlay) { return; } var currentTime = Date.now(); var timeSinceLastPlay = currentTime - self.lastPlayTime; self.lastPlayTime = currentTime; // Check for perfect rhythm var perfectTiming = Math.abs(timeSinceLastPlay - 1000) < 100; // Visual feedback - piano scale tween(pianoGraphics, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(pianoGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); // Calculate reward var reward = perfectTiming ? goldPerTap * 2 : goldPerTap; var startGold = gold; gold += reward; // Smooth gold animation tween({ value: displayedGold }, { value: gold }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { displayedGold = gold; } }); var tweenObj = { value: displayedGold }; tween(tweenObj, { value: gold }, { duration: 300, easing: tween.easeOut }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); // Create light flash effect var lightFlash = self.attachAsset('goldCoin', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, scaleY: 3, alpha: 0.8 }); lightFlash.tint = perfectTiming ? 0xFFD700 : 0xFFFFFF; tween(lightFlash, { scaleX: 5, scaleY: 5, alpha: 0 }, { duration: 300, onFinish: function onFinish() { lightFlash.destroy(); } }); // Create floating text var floatingGold = game.addChild(new FloatingText('+' + reward, perfectTiming ? 0xFFD700 : 0xFFFFFF)); floatingGold.x = self.x; floatingGold.y = self.y - 50; // Play piano sound LK.getSound('pianohit').play(); // Create music note effect if (perfectTiming) { var note = game.addChild(new MusicNote()); note.x = self.x + (Math.random() - 0.5) * 100; note.y = self.y - 100; } }; self.down = function () { self.play(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // Game variables var gold = 0; var displayedGold = 0; // Track displayed gold for smooth animation var goldPerTap = 20000; var passiveIncome = 0; var drumsticks = []; var drumsticksPurchased = 0; var musicians = []; var unlockedInstruments = ['drum']; var currentVenue = 0; var currentInstrument = 'drum'; var instrumentSwitchArrow = null; var guitarAsset = null; var cymbalAsset = null; var maracasAsset = null; var arrowBack = null; var arrow2 = null; var arrowBack2 = null; var instrumentsPurchased = 0; var audienceCounter = 0; // Track which audience asset to use next var globalClapCounter = 0; // Track global clap count for double clap pattern var globalClapPhase = 0; // 0-2 = singles, 3 = double, 4-6 = singles, 7 = four times var lastClapTick = -120; // Track last clap tick to prevent multiple claps per cycle var fingers = []; // Track AutoFinger instances var fingersPurchased = 0; // Track fingers purchased var autoCymbalsticks = []; // Track AutoCymbalstick instances // Upgrade costs var drumstickCost = 10; var fingerCost = 300; // Separate cost for fingers var musicianCost = 100; var guitarPurchased = false; // Track if guitar has been purchased var instrumentCosts = { guitar: 500, cymbal: 1000, maracas: 2000 }; // UI Elements var goldText = new Text2('Gold: 0', { size: 80, fill: '#FFD700' }); goldText.anchor.set(0.5, 0); LK.gui.top.addChild(goldText); // Add reset button var resetButton = new Container(); var resetBg = resetButton.attachAsset('buyButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); resetBg.tint = 0xFF0000; var resetText = new Text2('Reset', { size: 30, fill: '#FFFFFF' }); resetText.anchor.set(0.5, 0.5); resetButton.addChild(resetText); resetButton.interactive = true; LK.gui.topRight.addChild(resetButton); resetButton.x = -150; resetButton.y = 50; var incomeText = new Text2('Income: 0/s', { size: 50, fill: '#ffffff' }); incomeText.anchor.set(0.5, 0); incomeText.y = 90; LK.gui.top.addChild(incomeText); // Add background var background = game.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 })); // Main drum var mainDrum = game.addChild(new Drum()); mainDrum.x = 1024; mainDrum.y = 1300; // Stage/Venue display - removed // Buy buttons - Add to GUI layer to ensure they're always on top var buyDrumstickBtn = LK.gui.bottom.addChild(new BuyButton()); buyDrumstickBtn.x = -480; buyDrumstickBtn.y = -532; buyDrumstickBtn.updateButton('Drumstick', drumstickCost, false); var buyMusicianBtn = LK.gui.bottom.addChild(new BuyButton()); buyMusicianBtn.x = 0; buyMusicianBtn.y = -532; buyMusicianBtn.updateButton('Audience', musicianCost, false, 0, true, ''); var buyInstrumentBtn = LK.gui.bottom.addChild(new BuyButton()); buyInstrumentBtn.x = 480; buyInstrumentBtn.y = -532; buyInstrumentBtn.updateButton('Guitar', instrumentCosts.guitar, false, 0, true, '10 Audience'); // Reset button handler resetButton.down = function () { // Visual feedback tween(resetBg, { scaleX: 0.45, scaleY: 0.45 }, { duration: 100, onFinish: function onFinish() { tween(resetBg, { scaleX: 0.5, scaleY: 0.5 }, { duration: 100 }); } }); }; resetButton.up = function () { // Create confirmation dialog var confirmContainer = game.addChild(new Container()); confirmContainer.x = 1024; confirmContainer.y = 1366; // Dark overlay var overlay = confirmContainer.attachAsset('goldCoin', { anchorX: 0.5, anchorY: 0.5, scaleX: 100, scaleY: 100, alpha: 0.7 }); overlay.tint = 0x000000; // Dialog box var dialogBg = confirmContainer.attachAsset('buyButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); // Confirmation text var confirmText = new Text2('Reset All Progress?', { size: 60, fill: '#FFFFFF' }); confirmText.anchor.set(0.5, 0.5); confirmText.y = -50; confirmContainer.addChild(confirmText); // Yes button var yesBtn = confirmContainer.addChild(new Container()); var yesBg = yesBtn.attachAsset('buyButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); yesBg.tint = 0x4CAF50; var yesText = new Text2('Yes', { size: 40, fill: '#FFFFFF' }); yesText.anchor.set(0.5, 0.5); yesBtn.addChild(yesText); yesBtn.x = -150; yesBtn.y = 50; yesBtn.interactive = true; // No button var noBtn = confirmContainer.addChild(new Container()); var noBg = noBtn.attachAsset('buyButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); noBg.tint = 0xFF0000; var noText = new Text2('No', { size: 40, fill: '#FFFFFF' }); noText.anchor.set(0.5, 0.5); noBtn.addChild(noText); noBtn.x = 150; noBtn.y = 50; noBtn.interactive = true; // Yes button handler yesBtn.down = function () { tween(yesBg, { scaleX: 0.7, scaleY: 0.7 }, { duration: 100, onFinish: function onFinish() { tween(yesBg, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100 }); } }); }; yesBtn.up = function () { // Clear storage storage.gold = null; storage.passiveIncome = null; storage.drumstickCount = null; storage.drumsticksPurchased = null; storage.musicianCount = null; storage.unlockedInstruments = null; storage.instrumentsPurchased = null; // Reload game LK.showGameOver(); }; // No button handler noBtn.down = function () { tween(noBg, { scaleX: 0.7, scaleY: 0.7 }, { duration: 100, onFinish: function onFinish() { tween(noBg, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100 }); } }); }; noBtn.up = function () { confirmContainer.destroy(); }; }; // Button handlers buyDrumstickBtn.up = function () { // PIANIST PURCHASE LOGIC if (currentInstrument === 'piano') { if (typeof window.pianistCost === 'undefined') { window.pianistCost = 20000; } if (typeof window.pianistsPurchased === 'undefined') { window.pianistsPurchased = 0; } var pianistCost = window.pianistCost; if (gold >= pianistCost) { gold -= pianistCost; window.pianistsPurchased++; // Play purchase sound LK.getSound('purchase').play(); // Increase cost for next pianist window.pianistCost = Math.floor(window.pianistCost * 1.5); // Update button buyDrumstickBtn.updateButton('Pianist', window.pianistCost, gold >= window.pianistCost, window.pianistsPurchased); } return; } // MARACAS SHAKE PURCHASE LOGIC if (currentInstrument === 'maracas') { if (typeof window.maracasShakeCost === 'undefined') { window.maracasShakeCost = 700; } if (typeof window.maracasShakeCount === 'undefined') { window.maracasShakeCount = 0; } var maracasShakeCost = window.maracasShakeCost; // Allow purchase if player can afford if (gold >= maracasShakeCost) { gold -= maracasShakeCost; window.maracasShakeCount++; // Play maracas sound and animate if (maracasAsset) { // Trigger maracas animation maracasAsset.down(); } LK.getSound('purchase').play(); // Increase cost for next purchase window.maracasShakeCost = Math.floor(window.maracasShakeCost * 1.3); // Update button to show new count and cost buyDrumstickBtn.updateButton('Maracas Shake', window.maracasShakeCost, gold >= window.maracasShakeCost, window.maracasShakeCount); } return; } // CYMBALSTICK PURCHASE LOGIC if (currentInstrument === 'cymbal') { if (typeof window.cymbalsticksPurchased === 'undefined') { window.cymbalsticksPurchased = 0; } if (typeof window.cymbalstickCost === 'undefined') { window.cymbalstickCost = 600; } var cymbalstickCount = window.cymbalsticksPurchased; var cymbalstickCost = window.cymbalstickCost; if (gold >= cymbalstickCost) { gold -= cymbalstickCost; window.cymbalsticksPurchased++; // Create auto cymbal stick if it doesn't exist if (autoCymbalsticks.length === 0) { var newAutoCymbalstick = game.addChild(new AutoCymbalstick()); // Position auto cymbal stick on left side of cymbal if (cymbalAsset) { newAutoCymbalstick.x = cymbalAsset.x - 380; newAutoCymbalstick.y = cymbalAsset.y - 50; } else { // Default position if cymbal doesn't exist newAutoCymbalstick.x = 1024 - 380; newAutoCymbalstick.y = 1220 - 50; } // Set cymbal reference for visual feedback newAutoCymbalstick.cymbalReference = cymbalAsset; autoCymbalsticks.push(newAutoCymbalstick); } passiveIncome += 10; // Auto cymbal stick generates 10 gold per second // Increase cost for next cymbalstick (optional, can be fixed if desired) window.cymbalstickCost = Math.floor(window.cymbalstickCost * 1.3); LK.getSound('purchase').play(); // Update button buyDrumstickBtn.updateButton('Cymbalstick', window.cymbalstickCost, gold >= window.cymbalstickCost, window.cymbalsticksPurchased); } return; } var currentCost = currentInstrument === 'guitar' ? fingerCost : drumstickCost; if (gold >= currentCost) { gold -= currentCost; if (currentInstrument === 'guitar') { fingersPurchased++; // Create finger if it doesn't exist if (fingers.length === 0) { var newFinger = game.addChild(new AutoFinger()); // Position finger on right side of guitar if (guitarAsset) { newFinger.x = guitarAsset.x - 250; // Move significantly more to the left newFinger.y = guitarAsset.y + 50; // Move finger up a bit more (reduced from 80 to 50) } else { // If guitar doesn't exist yet, position at default location newFinger.x = 1024 - 250; newFinger.y = 1220 + 50; } // Set guitar reference for visual feedback newFinger.guitarReference = guitarAsset; fingers.push(newFinger); } passiveIncome += 4; // Fingers generate 4 gold per second fingerCost = Math.floor(fingerCost * 1.3); } else { drumsticksPurchased++; // Create drumstick if it doesn't exist if (drumsticks.length === 0) { var newStick = game.addChild(new AutoDrumstick()); // Position drumstick on left side of drum newStick.x = mainDrum.x - 350; newStick.y = mainDrum.y - 200; // Rotate drumstick to point towards the drum newStick.rotation = 0; // Set drum reference for visual feedback newStick.drumReference = mainDrum; drumsticks.push(newStick); } passiveIncome += 1; drumstickCost = Math.floor(drumstickCost * 1.3); } LK.getSound('purchase').play(); // Force update button to refresh count display var buttonText = currentInstrument === 'guitar' ? 'Finger' : 'Drumstick'; var purchaseCount = currentInstrument === 'guitar' ? fingersPurchased : drumsticksPurchased; var nextCost = currentInstrument === 'guitar' ? fingerCost : drumstickCost; buyDrumstickBtn.updateButton(buttonText, nextCost, gold >= nextCost, purchaseCount); } }; buyMusicianBtn.up = function () { var requiredFingers = guitarPurchased ? 10 : 0; var canPurchase = guitarPurchased ? fingersPurchased >= requiredFingers : drumsticksPurchased >= 10; if (canPurchase && gold >= musicianCost) { gold -= musicianCost; var newAudience = game.addChild(new Audience()); // Random spawn position at bottom of screen newAudience.x = 200 + Math.random() * 1648; // Random x between 200 and 1848 newAudience.y = 2400; // Fixed y position for horizontal alignment // Only set instruments if guitar is not purchased if (!guitarPurchased && unlockedInstruments.length > 1) { var randomInstrument = unlockedInstruments[Math.floor(Math.random() * (unlockedInstruments.length - 1)) + 1]; newAudience.setInstrument(randomInstrument); } musicians.push(newAudience); goldPerTap = Math.floor(goldPerTap * newAudience.multiplier); passiveIncome += 4; // Each audience generates 4 gold per second // Increase cost by 1.3x before guitar, 1.3x (30%) after guitar musicianCost = Math.floor(musicianCost * 1.3); LK.getSound('purchase').play(); // Force update button to refresh count display var isLocked = guitarPurchased ? fingersPurchased < 10 : drumsticksPurchased < 10; var lockMessage = guitarPurchased ? '10 Fingers' : '10 Drumsticks'; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isLocked, musicians.length, isLocked, lockMessage); } }; buyInstrumentBtn.up = function () { var nextInstrument = null; var cost = 0; if (!unlockedInstruments.includes('guitar')) { nextInstrument = 'guitar'; cost = instrumentCosts.guitar; } else if (!unlockedInstruments.includes('cymbal')) { nextInstrument = 'cymbal'; cost = instrumentCosts.cymbal; } else if (!unlockedInstruments.includes('maracas')) { nextInstrument = 'maracas'; cost = instrumentCosts.maracas; } // Check if Piano button was clicked var maracasShakeCount = typeof window.maracasShakeCount !== 'undefined' ? window.maracasShakeCount : 0; var isPianoButton = buyInstrumentBtn.titleText.text === 'Piano'; if (isPianoButton && !window.pianoAsset && gold >= 10000) { // Check if piano purchase requirements are met var canPurchasePiano = unlockedInstruments.includes('maracas') && musicians.length >= 30 && maracasShakeCount >= 5; if (canPurchasePiano) { // Purchase piano gold -= 10000; // Create piano asset var pianoAsset = game.addChild(new Piano()); pianoAsset.scaleX = 2; pianoAsset.scaleY = 2; // Position piano at fixed distance from maracas var PIANO_MARACAS_DISTANCE = 850; // Fixed distance between piano and maracas (increased from 800) // Always position piano relative to maracas' default position pianoAsset.x = 2800 + PIANO_MARACAS_DISTANCE; // Fixed position pianoAsset.y = 1220; // Same height as maracas pianoAsset.interactive = true; // Make piano interactive window.pianoAsset = pianoAsset; // Store reference globally // Mark piano as purchased window.pianoPurchased = true; // Create arrow4 if we're on maracas view if (currentInstrument === 'maracas' && !window.arrow4) { window.arrow4 = game.addChild(new ArrowButton()); window.arrow4.init('arrow4'); window.arrow4.x = 1024 + 850; window.arrow4.y = 1220; window.arrow4.visible = true; window.arrow4.clickHandler = function () { // Switch to piano view var pianoCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move maracas to the left tween(maracasAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move piano to center if (window.pianoAsset) { tween(window.pianoAsset, { x: pianoCenterX }, { duration: 500, easing: tween.easeInOut }); } // Move cymbal further left tween(cymbalAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar even further left tween(guitarAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum out of view tween(mainDrum, { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow4 and arrowback3, create/show arrowback4 window.arrow4.visible = false; if (window.arrowBack3) { window.arrowBack3.visible = false; } if (!window.arrowBack4) { window.arrowBack4 = game.addChild(new ArrowButton()); window.arrowBack4.init('arrowback4'); window.arrowBack4.y = 1220; window.arrowBack4.clickHandler = function () { // Switch back to maracas from piano var maracasCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move piano back to fixed position off-screen if (window.pianoAsset) { tween(window.pianoAsset, { x: 2800 + 850 // Back to fixed position (updated to match new distance) }, { duration: 500, easing: tween.easeInOut }); } // Move maracas back to center tween(maracasAsset, { x: maracasCenterX }, { duration: 500, easing: tween.easeInOut }); // Move cymbal back tween(cymbalAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar back tween(guitarAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum back tween(mainDrum, { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowback4 and show arrow4 and arrowback3 window.arrowBack4.visible = false; window.arrow4.x = maracasCenterX + 850; window.arrow4.visible = true; if (window.arrowBack3) { window.arrowBack3.x = maracasCenterX - 850; window.arrowBack3.visible = true; } currentInstrument = 'maracas'; // Update maracas shake button if (typeof window.maracasShakeCost === 'undefined') { window.maracasShakeCost = 700; } if (typeof window.maracasShakeCount === 'undefined') { window.maracasShakeCount = 0; } buyDrumstickBtn.updateButton('Maracas Shake', window.maracasShakeCost, gold >= window.maracasShakeCost, window.maracasShakeCount); }; } window.arrowBack4.x = pianoCenterX - 850; window.arrowBack4.visible = true; currentInstrument = 'piano'; // Update button to Pianist when switching to piano if (typeof window.pianistCost === 'undefined') { window.pianistCost = 20000; } if (typeof window.pianistsPurchased === 'undefined') { window.pianistsPurchased = 0; } buyDrumstickBtn.updateButton('Pianist', window.pianistCost, gold >= window.pianistCost, window.pianistsPurchased); // Update audience button for piano view var isAudienceLocked = window.pianistsPurchased < 10; var audienceLockMessage = isAudienceLocked ? '10 Pianists' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); // Show flute button when on piano view var isFluteLocked = musicians.length < 50 || isAudienceLocked; var fluteLockMessage = isAudienceLocked ? audienceLockMessage : musicians.length < 50 ? '50 Audience' : ''; buyInstrumentBtn.updateButton('Flute', 50000, gold >= 50000 && !isFluteLocked, undefined, isFluteLocked, fluteLockMessage); buyInstrumentBtn.visible = true; }; } LK.getSound('purchase').play(); // Update button to show piano was purchased buyInstrumentBtn.updateButton('Piano', 10000, false, undefined, true, 'Purchased'); buyInstrumentBtn.visible = true; // Always keep pianoPurchased flag in sync window.pianoPurchased = true; return; } } // Check if Flute button was clicked (when on piano view) var pianistsPurchased = typeof window.pianistsPurchased !== 'undefined' ? window.pianistsPurchased : 0; if (currentInstrument === 'piano' && musicians.length >= 50 && pianistsPurchased >= 10 && gold >= 50000) { // Purchase flute gold -= 50000; // Create flute asset (placeholder using guitar asset) if (!window.fluteAsset) { var fluteAsset = game.addChild(new Container()); var fluteGraphics = fluteAsset.attachAsset('guitar', { anchorX: 0.5, anchorY: 0.5 }); fluteAsset.scaleX = 2.5; fluteAsset.scaleY = 2.5; // Position flute far to the right fluteAsset.x = 4800; // Fixed position far right fluteAsset.y = 1220; fluteAsset.interactive = true; window.fluteAsset = fluteAsset; } LK.getSound('purchase').play(); // Update button to show flute was purchased buyInstrumentBtn.updateButton('Flute', 50000, false, undefined, true, 'Purchased'); buyInstrumentBtn.visible = true; // Create arrow5 if we're on piano view if (!window.arrow5) { window.arrow5 = game.addChild(new ArrowButton()); window.arrow5.init('arrow4'); // Reuse arrow4 asset window.arrow5.x = 1024 + 850; window.arrow5.y = 1220; window.arrow5.visible = true; window.arrow5.clickHandler = function () { // Switch to flute view var fluteCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move all instruments left if (window.pianoAsset) { tween(window.pianoAsset, { x: fluteCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); } tween(maracasAsset, { x: fluteCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); tween(cymbalAsset, { x: fluteCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: fluteCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } tween(guitarAsset, { x: fluteCenterX - INSTRUMENT_DISTANCE * 4 - 1600 }, { duration: 500, easing: tween.easeInOut }); if (fingers.length > 0) { tween(fingers[0], { x: fluteCenterX - INSTRUMENT_DISTANCE * 4 - 1600 - 250 }, { duration: 500, easing: tween.easeInOut }); } tween(mainDrum, { x: fluteCenterX - INSTRUMENT_DISTANCE * 5 - 2000 }, { duration: 500, easing: tween.easeInOut }); if (drumsticks.length > 0) { tween(drumsticks[0], { x: fluteCenterX - INSTRUMENT_DISTANCE * 5 - 2000 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Move flute to center if (window.fluteAsset) { tween(window.fluteAsset, { x: fluteCenterX }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow5 and show arrowback5 window.arrow5.visible = false; if (window.arrowBack4) { window.arrowBack4.visible = false; } if (!window.arrowBack5) { window.arrowBack5 = game.addChild(new ArrowButton()); window.arrowBack5.init('arrowback4'); window.arrowBack5.y = 1220; window.arrowBack5.clickHandler = function () { // Switch back to piano from flute var pianoCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move flute back if (window.fluteAsset) { tween(window.fluteAsset, { x: 4800 }, { duration: 500, easing: tween.easeInOut }); } // Move piano back to center if (window.pianoAsset) { tween(window.pianoAsset, { x: pianoCenterX }, { duration: 500, easing: tween.easeInOut }); } // Move other instruments back tween(maracasAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); tween(cymbalAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } tween(guitarAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); if (fingers.length > 0) { tween(fingers[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 250 }, { duration: 500, easing: tween.easeInOut }); } tween(mainDrum, { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 }, { duration: 500, easing: tween.easeInOut }); if (drumsticks.length > 0) { tween(drumsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowback5 and show arrow5 and arrowback4 window.arrowBack5.visible = false; window.arrow5.x = pianoCenterX + 850; window.arrow5.visible = true; if (window.arrowBack4) { window.arrowBack4.x = pianoCenterX - 850; window.arrowBack4.visible = true; } currentInstrument = 'piano'; }; } window.arrowBack5.x = fluteCenterX - 850; window.arrowBack5.visible = true; currentInstrument = 'flute'; // Update buttons for flute view buyDrumstickBtn.updateButton('Flutist', 100000, false, 0); buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost, musicians.length); buyInstrumentBtn.visible = false; }; } // Create arrow4 when piano is purchased and we're on maracas view if (window.pianoAsset && currentInstrument === 'maracas' && !window.arrow4) { window.arrow4 = game.addChild(new ArrowButton()); window.arrow4.init('arrow4'); window.arrow4.x = 1024 + 850; window.arrow4.y = 1220; window.arrow4.visible = true; window.pianoPurchased = true; window.arrow4.clickHandler = function () { // Switch to piano view var pianoCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move maracas to the left tween(maracasAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move piano to center if (window.pianoAsset) { tween(window.pianoAsset, { x: pianoCenterX }, { duration: 500, easing: tween.easeInOut }); } // Move cymbal further left tween(cymbalAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar even further left tween(guitarAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum out of view tween(mainDrum, { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow4 and arrowback3, create/show arrowback4 window.arrow4.visible = false; if (window.arrowBack3) { window.arrowBack3.visible = false; } if (!window.arrowBack4) { window.arrowBack4 = game.addChild(new ArrowButton()); window.arrowBack4.init('arrowback4'); window.arrowBack4.y = 1220; window.arrowBack4.clickHandler = function () { // Switch back to maracas from piano var maracasCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move piano back to fixed position off-screen if (window.pianoAsset) { tween(window.pianoAsset, { x: 2800 + 850 // Back to fixed position (updated to match new distance) }, { duration: 500, easing: tween.easeInOut }); } // Move maracas back to center tween(maracasAsset, { x: maracasCenterX }, { duration: 500, easing: tween.easeInOut }); // Move cymbal back tween(cymbalAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar back tween(guitarAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum back tween(mainDrum, { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowback4 and show arrow4 and arrowback3 window.arrowBack4.visible = false; window.arrow4.x = maracasCenterX + 850; window.arrow4.visible = true; if (window.arrowBack3) { window.arrowBack3.x = maracasCenterX - 850; window.arrowBack3.visible = true; } currentInstrument = 'maracas'; // Update maracas shake button if (typeof window.maracasShakeCost === 'undefined') { window.maracasShakeCost = 700; } if (typeof window.maracasShakeCount === 'undefined') { window.maracasShakeCount = 0; } buyDrumstickBtn.updateButton('Maracas Shake', window.maracasShakeCost, gold >= window.maracasShakeCost, window.maracasShakeCount); }; } window.arrowBack4.x = pianoCenterX - 850; window.arrowBack4.visible = true; currentInstrument = 'piano'; // Update button to Pianist when switching to piano if (typeof window.pianistCost === 'undefined') { window.pianistCost = 20000; } if (typeof window.pianistsPurchased === 'undefined') { window.pianistsPurchased = 0; } buyDrumstickBtn.updateButton('Pianist', window.pianistCost, gold >= window.pianistCost, window.pianistsPurchased); // Update audience button for piano view var isAudienceLocked = window.pianistsPurchased < 10; var audienceLockMessage = isAudienceLocked ? '10 Pianists' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); // Show flute button when on piano view var isFluteLocked = musicians.length < 50 || isAudienceLocked; var fluteLockMessage = isAudienceLocked ? audienceLockMessage : musicians.length < 50 ? '50 Audience' : ''; buyInstrumentBtn.updateButton('Flute', 50000, gold >= 50000 && !isFluteLocked, undefined, isFluteLocked, fluteLockMessage); buyInstrumentBtn.visible = true; }; } // Also check if arrow4 should be visible after piano purchase if (window.pianoAsset && currentInstrument === 'maracas' && window.arrow4) { window.arrow4.visible = true; } return; } if (nextInstrument && gold >= cost && (nextInstrument !== 'guitar' || musicians.length >= 10) && (nextInstrument !== 'cymbal' || musicians.length >= 15 && fingersPurchased >= 10) && (nextInstrument !== 'maracas' || typeof window.cymbalsticksPurchased !== 'undefined' && window.cymbalsticksPurchased >= 10)) { gold -= cost; unlockedInstruments.push(nextInstrument); instrumentsPurchased++; // Set guitar purchased flag and update musician cost to 2000 if (nextInstrument === 'guitar') { guitarPurchased = true; musicianCost = 2000; } else if (nextInstrument === 'cymbal') { // Create cymbal to the right of guitar if (!cymbalAsset) { cymbalAsset = game.addChild(new Cymbal()); cymbalAsset.scaleX = 2; cymbalAsset.scaleY = 2; // Position cymbal to the right of guitar if (guitarAsset) { cymbalAsset.x = guitarAsset.x + 2400; cymbalAsset.y = guitarAsset.y; } else { // Default position if guitar doesn't exist cymbalAsset.x = 3424; cymbalAsset.y = 1220; } // Show arrow2 if we're currently on guitar view if (currentInstrument === 'guitar' && !arrow2) { arrow2 = game.addChild(new ArrowButton()); arrow2.init('arrow2'); arrow2.x = 1024 + 850; arrow2.y = 1220; // Align with guitar height arrow2.visible = true; arrow2.clickHandler = function () { // Switch to cymbal view var cymbalCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move guitar to the left tween(guitarAsset, { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move cymbal to center tween(cymbalAsset, { x: cymbalCenterX }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: cymbalCenterX - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move drum further left tween(mainDrum, { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Move maracas if it exists if (maracasAsset) { tween(maracasAsset, { x: cymbalCenterX + 1776 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow2 and arrowBack, create/show arrowback2 arrow2.visible = false; arrowBack.visible = false; if (!arrowBack2) { arrowBack2 = game.addChild(new ArrowButton()); arrowBack2.init('arrowback2'); arrowBack2.y = 1220; // Align with guitar height } arrowBack2.x = cymbalCenterX - 850; arrowBack2.visible = true; arrowBack2.clickHandler = function () { // Switch back to guitar from cymbal var guitarCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move cymbal to the right tween(cymbalAsset, { x: guitarCenterX + 2400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: guitarCenterX + 2400 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move maracas if it exists if (maracasAsset) { tween(maracasAsset, { x: guitarCenterX + 4000 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar back to center tween(guitarAsset, { x: guitarCenterX }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: guitarCenterX - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum to the left tween(mainDrum, { x: guitarCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: guitarCenterX - INSTRUMENT_DISTANCE - 400 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowback2 and arrow3, show arrow2 and arrowBack arrowBack2.visible = false; if (window.arrow3) { window.arrow3.visible = false; } arrow2.x = guitarCenterX + 850; arrow2.visible = true; if (arrowBack) { arrowBack.x = guitarCenterX - 850; arrowBack.visible = true; } currentInstrument = 'guitar'; // Update button back to Finger buyDrumstickBtn.updateButton('Finger', fingerCost, gold >= fingerCost, fingersPurchased); }; // Update button to Cymbalstick if (typeof window.cymbalstickCost === 'undefined') { window.cymbalstickCost = 600; } if (typeof window.cymbalsticksPurchased === 'undefined') { window.cymbalsticksPurchased = 0; } buyDrumstickBtn.updateButton('Cymbalstick', window.cymbalstickCost, gold >= window.cymbalstickCost, window.cymbalsticksPurchased); // Show arrow3 if maracas is unlocked if (unlockedInstruments.includes('maracas') && !window.arrow3) { window.arrow3 = game.addChild(new ArrowButton()); window.arrow3.init('arrow3'); window.arrow3.x = cymbalCenterX + 850; window.arrow3.y = 1220; window.arrow3.visible = true; window.arrow3.clickHandler = function () { // Switch to maracas view var maracasCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move cymbal to the left tween(cymbalAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move maracas to center tween(maracasAsset, { x: maracasCenterX }, { duration: 500, easing: tween.easeInOut }); // Move guitar further left tween(guitarAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum even further left tween(mainDrum, { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow3 and arrowback2, create/show arrowback3 window.arrow3.visible = false; arrowBack2.visible = false; if (!window.arrowBack3) { window.arrowBack3 = game.addChild(new ArrowButton()); window.arrowBack3.init('arrowback3'); window.arrowBack3.y = 1220; window.arrowBack3.clickHandler = function () { // Switch back to cymbal from maracas var cymbalCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move maracas to the right tween(maracasAsset, { x: cymbalCenterX + 1600 }, { duration: 500, easing: tween.easeInOut }); // Move cymbal back to center tween(cymbalAsset, { x: cymbalCenterX }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: cymbalCenterX - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar back tween(guitarAsset, { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum back tween(mainDrum, { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowback3 and show arrow3 and arrowback2 window.arrowBack3.visible = false; window.arrow3.x = cymbalCenterX + 850; window.arrow3.visible = true; if (arrowBack2) { arrowBack2.x = cymbalCenterX - 850; arrowBack2.visible = true; } currentInstrument = 'cymbal'; // Update button back to Cymbalstick if (typeof window.cymbalstickCost === 'undefined') { window.cymbalstickCost = 600; } if (typeof window.cymbalsticksPurchased === 'undefined') { window.cymbalsticksPurchased = 0; } buyDrumstickBtn.updateButton('Cymbalstick', window.cymbalstickCost, gold >= window.cymbalstickCost, window.cymbalsticksPurchased); // Update audience button for cymbal view var isAudienceLocked = window.cymbalsticksPurchased < 10; var audienceLockMessage = isAudienceLocked ? '10 Cymbalstick' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); }; } window.arrowBack3.x = maracasCenterX - 850; window.arrowBack3.visible = true; // Update button to Maracas Shake if (typeof window.maracasShakeCost === 'undefined') { window.maracasShakeCost = 700; } if (typeof window.maracasShakeCount === 'undefined') { window.maracasShakeCount = 0; } buyDrumstickBtn.updateButton('Maracas Shake', window.maracasShakeCost, gold >= window.maracasShakeCost, window.maracasShakeCount); currentInstrument = 'maracas'; // Update audience button for maracas view var isAudienceLocked = window.maracasShakeCount < 5; var audienceLockMessage = isAudienceLocked ? '5 Maracas Shake' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); // Show piano button if piano is purchased var isPianoLocked = musicians.length < 30 || isAudienceLocked || window.maracasShakeCount < 5; var pianoLockMessage = window.maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? '5 Maracas Shake' : musicians.length < 30 ? '30 Audience' : ''; buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked && !window.pianoPurchased, undefined, isPianoLocked || !!window.pianoPurchased, window.pianoPurchased ? 'Purchased' : pianoLockMessage); buyInstrumentBtn.visible = true; // Create arrow4 if piano exists if (window.pianoAsset && !window.arrow4) { window.arrow4 = game.addChild(new ArrowButton()); window.arrow4.init('arrow4'); window.arrow4.x = maracasCenterX + 850; window.arrow4.y = 1220; window.arrow4.visible = true; window.pianoPurchased = true; window.arrow4.clickHandler = function () { // Switch to piano view var pianoCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move maracas to the left tween(maracasAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move piano to center if (window.pianoAsset) { tween(window.pianoAsset, { x: pianoCenterX }, { duration: 500, easing: tween.easeInOut }); } // Move cymbal further left tween(cymbalAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar even further left tween(guitarAsset, { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum out of view tween(mainDrum, { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: pianoCenterX - INSTRUMENT_DISTANCE * 4 - 1600 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow4 and arrowback3, create/show arrowback4 window.arrow4.visible = false; if (window.arrowBack3) { window.arrowBack3.visible = false; } if (!window.arrowBack4) { window.arrowBack4 = game.addChild(new ArrowButton()); window.arrowBack4.init('arrowback4'); window.arrowBack4.y = 1220; window.arrowBack4.clickHandler = function () { // Switch back to maracas from piano var maracasCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move piano back to fixed position off-screen if (window.pianoAsset) { tween(window.pianoAsset, { x: 2800 + 850 }, { duration: 500, easing: tween.easeInOut }); } // Move maracas back to center tween(maracasAsset, { x: maracasCenterX }, { duration: 500, easing: tween.easeInOut }); // Move cymbal back tween(cymbalAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar back tween(guitarAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum back tween(mainDrum, { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowback4 and show arrow4 and arrowback3 window.arrowBack4.visible = false; window.arrow4.x = maracasCenterX + 850; window.arrow4.visible = true; if (window.arrowBack3) { window.arrowBack3.x = maracasCenterX - 850; window.arrowBack3.visible = true; } currentInstrument = 'maracas'; // Update maracas shake button if (typeof window.maracasShakeCost === 'undefined') { window.maracasShakeCost = 700; } if (typeof window.maracasShakeCount === 'undefined') { window.maracasShakeCount = 0; } buyDrumstickBtn.updateButton('Maracas Shake', window.maracasShakeCost, gold >= window.maracasShakeCost, window.maracasShakeCount); }; } window.arrowBack4.x = pianoCenterX - 850; window.arrowBack4.visible = true; currentInstrument = 'piano'; // Update button to Pianist when switching to piano if (typeof window.pianistCost === 'undefined') { window.pianistCost = 20000; } if (typeof window.pianistsPurchased === 'undefined') { window.pianistsPurchased = 0; } buyDrumstickBtn.updateButton('Pianist', window.pianistCost, gold >= window.pianistCost, window.pianistsPurchased); // Update audience button for piano view var isAudienceLocked = window.pianistsPurchased < 10; var audienceLockMessage = isAudienceLocked ? '10 Pianists' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); // Show flute button when on piano view var isFluteLocked = musicians.length < 50 || isAudienceLocked; var fluteLockMessage = isAudienceLocked ? audienceLockMessage : musicians.length < 50 ? '50 Audience' : ''; buyInstrumentBtn.updateButton('Flute', 50000, gold >= 50000 && !isFluteLocked, undefined, isFluteLocked, fluteLockMessage); buyInstrumentBtn.visible = true; }; } else if (window.arrow4) { window.arrow4.visible = true; window.pianoPurchased = true; window.pianoPurchased = true; } }; } else if (window.arrow3) { window.arrow3.visible = true; } window.pianoPurchased = !!window.pianoAsset; window.pianoPurchased = !!window.pianoAsset; currentInstrument = 'cymbal'; }; } } } else if (nextInstrument === 'maracas') { // Create maracas to the right of cymbal if (!maracasAsset) { maracasAsset = game.addChild(new Container()); var maracasGraphics = maracasAsset.attachAsset('maracas', { anchorX: 0.5, anchorY: 0.5 }); maracasAsset.scaleX = 2; maracasAsset.scaleY = 2; // Position maracas to the right of cymbal if (cymbalAsset) { maracasAsset.x = cymbalAsset.x + 1600; // Moved significantly further right maracasAsset.y = cymbalAsset.y; } else { // Default position if cymbal doesn't exist maracasAsset.x = 2800; // Fixed position further right maracasAsset.y = 1220; } // Make maracas interactive and play animation/sound on tap maracasAsset.interactive = true; maracasAsset.down = function () { // Prevent spamming animation if (maracasAsset._animating) { return; } maracasAsset._animating = true; // Animate maracas: scale up and back tween(maracasAsset, { scaleX: 2.3, scaleY: 2.3 }, { duration: 100, onFinish: function onFinish() { tween(maracasAsset, { scaleX: 2, scaleY: 2 }, { duration: 100, onFinish: function onFinish() { maracasAsset._animating = false; } }); } }); // Play maracas sound LK.getSound('maracashit').play(); // Optionally, create a floating text or effect var floatingGold = game.addChild(new FloatingText('+0', 0x00FF00)); floatingGold.x = maracasAsset.x; floatingGold.y = maracasAsset.y - 100; }; // Add arrow3 when on cymbal view to navigate to maracas if (currentInstrument === 'cymbal' && !window.arrow3) { window.arrow3 = game.addChild(new ArrowButton()); window.arrow3.init('arrow3'); window.arrow3.x = 1024 + 850; window.arrow3.y = 1220; window.arrow3.visible = true; window.arrow3.clickHandler = function () { // Switch to maracas view var maracasCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move cymbal to the left tween(cymbalAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE - 400 - 350, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move maracas to center tween(maracasAsset, { x: maracasCenterX }, { duration: 500, easing: tween.easeInOut }); // Move guitar further left tween(guitarAsset, { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum even further left tween(mainDrum, { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: maracasCenterX - INSTRUMENT_DISTANCE * 3 - 1200 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow3 and create/show arrowback3 window.arrow3.visible = false; if (!window.arrowBack3) { window.arrowBack3 = game.addChild(new ArrowButton()); window.arrowBack3.init('arrowback3'); window.arrowBack3.y = 1220; } window.arrowBack3.x = maracasCenterX - 850; window.arrowBack3.visible = true; window.arrowBack3.clickHandler = function () { // Switch back to cymbal from maracas var cymbalCenterX = 1024; // Move maracas to the right tween(maracasAsset, { x: cymbalCenterX + 1776 }, { duration: 500, easing: tween.easeInOut }); // Move cymbal back to center tween(cymbalAsset, { x: cymbalCenterX }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: cymbalCenterX - 350, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar back tween(guitarAsset, { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move drum back tween(mainDrum, { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowback3 and show arrow3 and arrowback2 window.arrowBack3.visible = false; window.arrow3.x = cymbalCenterX + 850; window.arrow3.visible = true; if (arrowBack2) { arrowBack2.x = cymbalCenterX - 850; arrowBack2.visible = true; } currentInstrument = 'cymbal'; }; currentInstrument = 'maracas'; }; } } } LK.getSound('purchase').play(); // Show arrow button when guitar is purchased if (nextInstrument === 'guitar' && !instrumentSwitchArrow) { instrumentSwitchArrow = game.addChild(new ArrowButton()); instrumentSwitchArrow.init('arrow'); instrumentSwitchArrow.x = mainDrum.x + 700; instrumentSwitchArrow.y = 1220; // Align with guitar height instrumentSwitchArrow.clickHandler = function () { // Fixed distance between instruments to maintain var INSTRUMENT_DISTANCE = 1200; // Increased distance to ensure they never get close // Only allow transition from drum to guitar if (currentInstrument === 'drum' && unlockedInstruments.includes('guitar')) { var guitarCenterX = 1024; // Center of screen // Calculate drum's new position to maintain distance var drumNewX = guitarCenterX - INSTRUMENT_DISTANCE - 400; // Move drum 400px more to the left // Move drum to the left while maintaining distance tween(mainDrum, { x: drumNewX }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if it exists if (drumsticks.length > 0) { tween(drumsticks[0], { x: drumNewX - 350 }, { duration: 500, easing: tween.easeInOut }); } // Create and bring in guitar from right to center if (!guitarAsset) { guitarAsset = game.addChild(new Guitar()); guitarAsset.scaleX = 3; guitarAsset.scaleY = 3; guitarAsset.x = 2048 + 500; // Start off-screen to the right guitarAsset.y = 1220; guitarAsset.x = guitarAsset.x + 50; // Move slightly to the right } // Create finger if purchased but not created yet if (fingersPurchased > 0 && fingers.length === 0) { var newFinger = game.addChild(new AutoFinger()); // Position finger on guitar (which is off-screen) newFinger.x = guitarAsset.x - 250; newFinger.y = guitarAsset.y + 50; newFinger.guitarReference = guitarAsset; fingers.push(newFinger); } tween(guitarAsset, { x: guitarCenterX // Move to center }, { duration: 500, easing: tween.easeInOut }); // Move cymbal with guitar if it exists if (cymbalAsset) { tween(cymbalAsset, { x: guitarCenterX + 2400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: guitarCenterX + 2400 - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } } // Move maracas if it exists if (maracasAsset) { tween(maracasAsset, { x: guitarCenterX + 4000 }, { duration: 500, easing: tween.easeInOut }); } // Move finger with guitar if it exists if (fingers.length > 0) { tween(fingers[0], { x: guitarCenterX - 250 }, { duration: 500, easing: tween.easeInOut }); } // Hide the right arrow instrumentSwitchArrow.visible = false; // Create and show left arrow if it doesn't exist if (!arrowBack) { arrowBack = game.addChild(new ArrowButton()); arrowBack.init('arrowback'); arrowBack.y = 1220; // Align with guitar height arrowBack.clickHandler = function () { // Switch back to drum view var drumCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move drum back to center tween(mainDrum, { x: drumCenterX }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: drumCenterX - 350 }, { duration: 500, easing: tween.easeInOut }); } // Move guitar to the right tween(guitarAsset, { x: drumCenterX + INSTRUMENT_DISTANCE + 400 }, { duration: 500, easing: tween.easeInOut }); // Move cymbal with guitar if it exists if (cymbalAsset) { tween(cymbalAsset, { x: drumCenterX + INSTRUMENT_DISTANCE + 400 + 2400 }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: drumCenterX + INSTRUMENT_DISTANCE + 400 + 2400 - 350, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } } // Move maracas if it exists if (maracasAsset) { tween(maracasAsset, { x: drumCenterX + INSTRUMENT_DISTANCE + 400 + 4000 }, { duration: 500, easing: tween.easeInOut }); } // Move finger with guitar if it exists if (fingers.length > 0) { tween(fingers[0], { x: drumCenterX + INSTRUMENT_DISTANCE + 400 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrowBack and arrow2, show instrumentSwitchArrow arrowBack.visible = false; if (arrow2) { arrow2.visible = false; } instrumentSwitchArrow.visible = true; instrumentSwitchArrow.x = drumCenterX + 700; currentInstrument = 'drum'; // Update button back to Drumstick buyDrumstickBtn.updateButton('Drumstick', drumstickCost, gold >= drumstickCost, drumsticksPurchased); }; } arrowBack.x = guitarCenterX - 850; arrowBack.visible = true; currentInstrument = 'guitar'; // Update finger position when on guitar view if (fingers.length > 0) { // Update finger position to be relative to guitar's new position fingers[0].x = guitarCenterX - 250; fingers[0].y = guitarAsset.y + 50; // Updated vertical offset to match new position } // Create and show arrow2 if cymbal exists if (cymbalAsset && !arrow2) { arrow2 = game.addChild(new ArrowButton()); arrow2.init('arrow2'); arrow2.y = 1220; // Align with guitar height arrow2.clickHandler = function () { // Switch to cymbal view var cymbalCenterX = 1024; var INSTRUMENT_DISTANCE = 1200; // Move guitar to the left tween(guitarAsset, { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 }, { duration: 500, easing: tween.easeInOut }); // Move finger with guitar if (fingers.length > 0) { tween(fingers[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE - 400 - 250 }, { duration: 500, easing: tween.easeInOut }); } // Move cymbal to center tween(cymbalAsset, { x: cymbalCenterX }, { duration: 500, easing: tween.easeInOut }); // Move auto cymbal stick with cymbal if (autoCymbalsticks.length > 0) { tween(autoCymbalsticks[0], { x: cymbalCenterX - 380, y: cymbalAsset.y - 50 }, { duration: 500, easing: tween.easeInOut }); } // Move drum further left tween(mainDrum, { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 }, { duration: 500, easing: tween.easeInOut }); // Move drumstick with drum if (drumsticks.length > 0) { tween(drumsticks[0], { x: cymbalCenterX - INSTRUMENT_DISTANCE * 2 - 800 - 350 }, { duration: 500, easing: tween.easeInOut }); } // Move maracas if it exists if (maracasAsset) { tween(maracasAsset, { x: cymbalCenterX + 1600 }, { duration: 500, easing: tween.easeInOut }); } // Hide arrow2 and arrowBack, create/show arrowback2 arrow2.visible = false; arrowBack.visible = false; if (!arrowBack2) { arrowBack2 = game.addChild(new ArrowButton()); arrowBack2.init('arrowback2'); arrowBack2.y = 1220; // Align with guitar height } arrowBack2.x = cymbalCenterX - 850; arrowBack2.visible = true; // Update button to Cymbalstick buyDrumstickBtn.updateButton('Cymbalstick', window.cymbalstickCost || 600, gold >= (window.cymbalstickCost || 600), window.cymbalsticksPurchased || 0); // Show arrow3 if maracas is unlocked if (unlockedInstruments.includes('maracas') && !window.arrow3) { window.arrow3 = game.addChild(new ArrowButton()); window.arrow3.init('arrow3'); window.arrow3.x = cymbalCenterX + 850; window.arrow3.y = 1220; window.arrow3.visible = true; } else if (window.arrow3) { window.arrow3.visible = true; } currentInstrument = 'cymbal'; }; } if (arrow2) { arrow2.x = guitarCenterX + 850; arrow2.visible = cymbalAsset ? true : false; } // Change drumstick button to Finger buyDrumstickBtn.updateButton('Finger', fingerCost, gold >= fingerCost, fingersPurchased); } }; } // Update button for next instrument if (nextInstrument === 'guitar') { buyInstrumentBtn.updateButton('Cymbal', instrumentCosts.cymbal, gold >= instrumentCosts.cymbal, undefined); } else if (nextInstrument === 'cymbal') { buyInstrumentBtn.updateButton('Maracas', instrumentCosts.maracas, gold >= instrumentCosts.maracas, undefined); } else if (nextInstrument === 'maracas') { // Show Piano button after maracas purchase var isAudienceLocked = guitarPurchased ? fingersPurchased < 10 : drumsticksPurchased < 10; var maracasShakeCount = typeof window.maracasShakeCount !== 'undefined' ? window.maracasShakeCount : 0; var isPianoLocked = musicians.length < 30 || isAudienceLocked || maracasShakeCount < 5; var pianoLockMessage = maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? guitarPurchased ? '10 Fingers' : '10 Drumsticks' : musicians.length < 30 ? '30 Audience' : ''; buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked, undefined, isPianoLocked, pianoLockMessage); buyInstrumentBtn.visible = true; } else { // Show Piano button if all instruments purchased var isAudienceLocked = guitarPurchased ? fingersPurchased < 10 : drumsticksPurchased < 10; var maracasShakeCount = typeof window.maracasShakeCount !== 'undefined' ? window.maracasShakeCount : 0; var isPianoLocked = musicians.length < 30 || isAudienceLocked || maracasShakeCount < 5; var pianoLockMessage = maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? guitarPurchased ? '10 Fingers' : '10 Drumsticks' : musicians.length < 30 ? '30 Audience' : ''; buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked, undefined, isPianoLocked, pianoLockMessage); buyInstrumentBtn.visible = true; } } }; // Passive income timer var incomeTimer = 0; // Main game loop game.update = function () { // Check if all instruments are purchased (guitar, cymbal, maracas) var allInstrumentsPurchased = unlockedInstruments.includes('guitar') && unlockedInstruments.includes('cymbal') && unlockedInstruments.includes('maracas'); // Synchronize all automatic players to drum hit (60 BPM = every 60 ticks) if (allInstrumentsPurchased && LK.ticks % 60 === 0) { // Force all automatic players to hit at the same time if (drumsticks.length > 0) { drumsticks[0].tickCounter = 60; // Force drumstick to hit } if (fingers.length > 0) { // Adjust finger to hit every 6 drum beats (360 ticks) if (LK.ticks % 360 === 0) { fingers[0].tickCounter = 360; // Force finger to hit } } if (autoCymbalsticks.length > 0) { // Adjust cymbalstick to hit at 30 BPM (120 ticks) - half speed if (LK.ticks % 120 === 0) { autoCymbalsticks[0].tickCounter = 120; // Force cymbalstick to hit } } } // Global clap synchronization - clap twice as fast (every 30 ticks) // Drum hits every 60 ticks, audience claps every 30 ticks (double speed) if ((LK.ticks + 28) % 30 === 0 && musicians.length > 0) { // Determine clap pattern based on global counter (now counting every 30 ticks) var clapCycle = Math.floor((LK.ticks + 28) / 30) % 16; globalClapPhase = clapCycle; if (clapCycle === 6 || clapCycle === 7) { // Double clap (7th and 8th in pattern) - faster with rapid clap-clap LK.getSound('clap').play(); LK.setTimeout(function () { LK.getSound('clap').play(); }, 100); // Faster delay for rapid double clap effect } else if (clapCycle === 14 || clapCycle === 15) { // Four times clap (15th and 16th in pattern) - slightly slower rapid clap-clap LK.getSound('clap').play(); LK.setTimeout(function () { LK.getSound('clap').play(); }, 80); // Slightly slower for controlled rapid clap-clap LK.setTimeout(function () { LK.getSound('clap').play(); }, 160); LK.setTimeout(function () { LK.getSound('clap').play(); }, 240); } else { // Single clap (other phases) LK.getSound('clap').play(); } } // Maracas automatic shake at 120 BPM (every 30 ticks = 0.5 seconds) if (typeof window.maracasShakeCount !== 'undefined' && window.maracasShakeCount > 0 && maracasAsset) { if (LK.ticks % 30 === 0) { // Trigger maracas animation and sound maracasAsset.down(); } } // Update UI goldText.setText('Gold: ' + Math.floor(displayedGold)); incomeText.setText('Income: ' + passiveIncome + '/s'); // Update button states // MARACAS LOGIC if (currentInstrument === 'maracas') { // Initialize maracas shake cost and count if (typeof window.maracasShakeCost === 'undefined') { window.maracasShakeCost = 700; } if (typeof window.maracasShakeCount === 'undefined') { window.maracasShakeCount = 0; } var maracasShakeCost = window.maracasShakeCost; var canAffordMaracasShake = gold >= maracasShakeCost; // Update buyDrumstickBtn for maracas shake - always show count and allow purchase if can afford buyDrumstickBtn.updateButton('Maracas Shake', maracasShakeCost, canAffordMaracasShake, window.maracasShakeCount); // Update audience button - unlock when maracas shake count reaches 5 var isAudienceLocked = window.maracasShakeCount < 5; var audienceLockMessage = isAudienceLocked ? '5 Maracas Shake' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); // Show Piano button - unlock when audience reaches 30 var isAudienceLocked = window.maracasShakeCount < 5; var isPianoLocked = musicians.length < 30 || isAudienceLocked || window.maracasShakeCount < 5; var pianoLockMessage = window.maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? '5 Maracas Shake' : musicians.length < 30 ? '30 Audience' : ''; buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked && !window.pianoPurchased, undefined, isPianoLocked || !!window.pianoPurchased, window.pianoPurchased ? 'Purchased' : pianoLockMessage); buyInstrumentBtn.visible = true; } else if (currentInstrument === 'piano') { // Initialize pianist cost and count if (typeof window.pianistCost === 'undefined') { window.pianistCost = 20000; } if (typeof window.pianistsPurchased === 'undefined') { window.pianistsPurchased = 0; } var pianistCost = window.pianistCost; var canAffordPianist = gold >= pianistCost; // Update buyDrumstickBtn for pianist buyDrumstickBtn.updateButton('Pianist', pianistCost, canAffordPianist, window.pianistsPurchased); // Update audience button - lock until 10 pianists are purchased var isAudienceLocked = window.pianistsPurchased < 10; var audienceLockMessage = isAudienceLocked ? '10 Pianists' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); // Show Flute button - unlock when audience reaches 50 var isFluteLocked = musicians.length < 50 || isAudienceLocked; var fluteLockMessage = isAudienceLocked ? audienceLockMessage : musicians.length < 50 ? '50 Audience' : ''; buyInstrumentBtn.updateButton('Flute', 50000, gold >= 50000 && !isFluteLocked, undefined, isFluteLocked, fluteLockMessage); buyInstrumentBtn.visible = true; } else if (currentInstrument === 'cymbal') { // Track cymbalstick purchases if (typeof window.cymbalsticksPurchased === 'undefined') { window.cymbalsticksPurchased = 0; } if (typeof window.cymbalstickCost === 'undefined') { window.cymbalstickCost = 600; } var cymbalstickCount = window.cymbalsticksPurchased; var cymbalstickCost = window.cymbalstickCost; var canAffordCymbalstick = gold >= cymbalstickCost; var cymbalstickLocked = fingersPurchased < 10; // Update buyDrumstickBtn for cymbalstick buyDrumstickBtn.updateButton('Cymbalstick', cymbalstickCost, canAffordCymbalstick && !cymbalstickLocked, window.cymbalsticksPurchased, cymbalstickLocked, cymbalstickLocked ? '10 Fingers' : ''); // Update audience button - lock until 10 cymbalsticks are purchased var isAudienceLocked = cymbalstickCount < 10 || fingersPurchased < 10; var audienceLockMessage = fingersPurchased < 10 ? '10 Fingers' : isAudienceLocked ? '10 Cymbalstick' : ''; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage); // Update maracas button - lock until 20 audience members are purchased OR if audience is locked var isMaracasLocked = musicians.length < 20 || isAudienceLocked; var maracasLockMessage = isAudienceLocked ? audienceLockMessage : musicians.length < 20 ? '20 Audience' : ''; // Check if maracas is already unlocked to determine if button should be visible if (unlockedInstruments.includes('maracas')) { // Show Piano button - unlock when audience reaches 30 var maracasShakeCount = typeof window.maracasShakeCount !== 'undefined' ? window.maracasShakeCount : 0; var isPianoLocked = musicians.length < 30 || isAudienceLocked || maracasShakeCount < 5; var pianoLockMessage = maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? audienceLockMessage : musicians.length < 30 ? '30 Audience' : ''; buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked, undefined, isPianoLocked, pianoLockMessage); buyInstrumentBtn.visible = true; } else { buyInstrumentBtn.updateButton('Maracas', 2000, gold >= 2000 && !isMaracasLocked, undefined, isMaracasLocked, maracasLockMessage); buyInstrumentBtn.visible = true; } } else { var buttonText = currentInstrument === 'guitar' ? 'Finger' : 'Drumstick'; var purchaseCount = currentInstrument === 'guitar' ? fingersPurchased : drumsticksPurchased; var currentCost = currentInstrument === 'guitar' ? fingerCost : drumstickCost; buyDrumstickBtn.updateButton(buttonText, currentCost, gold >= currentCost, purchaseCount); var isAudienceLocked = guitarPurchased ? fingersPurchased < 10 : drumsticksPurchased < 10; var lockMessage = guitarPurchased ? '10 Fingers' : '10 Drumsticks'; buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, isAudienceLocked ? lockMessage : ''); } // Update instrument button based on current view if (currentInstrument === 'drum' || currentInstrument === 'guitar') { // Check if audience is locked first var isAudienceLocked = guitarPurchased ? fingersPurchased < 10 : drumsticksPurchased < 10; var nextInstrument = null; var cost = 0; if (!unlockedInstruments.includes('guitar')) { nextInstrument = 'guitar'; cost = instrumentCosts.guitar; } else if (!unlockedInstruments.includes('cymbal')) { nextInstrument = 'cymbal'; cost = instrumentCosts.cymbal; } else if (!unlockedInstruments.includes('maracas')) { nextInstrument = 'maracas'; cost = instrumentCosts.maracas; } if (nextInstrument) { var isGuitarLocked = nextInstrument === 'guitar' && (musicians.length < 10 || isAudienceLocked); var isCymbalLocked = nextInstrument === 'cymbal' && (musicians.length < 15 || fingersPurchased < 10); var isMaracasLocked = nextInstrument === 'maracas' && (typeof window.cymbalsticksPurchased === 'undefined' || window.cymbalsticksPurchased < 10); var isLocked = isGuitarLocked || isCymbalLocked || isMaracasLocked; var lockMessage = ''; if (nextInstrument === 'guitar' && isAudienceLocked) { lockMessage = guitarPurchased ? '10 Fingers' : '10 Drumsticks'; } else if (isGuitarLocked) { lockMessage = '10 Audience'; } else if (isCymbalLocked) { lockMessage = fingersPurchased < 10 ? '10 Fingers' : '15 Audience'; } else if (isMaracasLocked) { lockMessage = '10 Cymbalstick'; } buyInstrumentBtn.updateButton(nextInstrument.charAt(0).toUpperCase() + nextInstrument.slice(1), cost, gold >= cost && !isLocked, undefined, isLocked, lockMessage); buyInstrumentBtn.visible = true; } else if (unlockedInstruments.includes('maracas')) { // If all instruments are unlocked, show Piano button - unlock when audience reaches 30 var maracasShakeCount = typeof window.maracasShakeCount !== 'undefined' ? window.maracasShakeCount : 0; var isPianoLocked = musicians.length < 30 || isAudienceLocked || maracasShakeCount < 5; var pianoLockMessage = maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? guitarPurchased ? '10 Fingers' : '10 Drumsticks' : musicians.length < 30 ? '30 Audience' : ''; buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked, undefined, isPianoLocked, pianoLockMessage); buyInstrumentBtn.visible = true; } } // Smooth passive income animation if (passiveIncome > 0 && Math.abs(gold - displayedGold) < 0.1) { // Start a new tween for the next second of income var targetGold = gold + passiveIncome; gold = targetGold; // Update actual gold value tween({ value: displayedGold }, { value: targetGold }, { duration: 1000, onFinish: function onFinish() { displayedGold = targetGold; } }); // Update displayedGold during tween var tweenObj = { value: displayedGold }; tween(tweenObj, { value: targetGold }, { duration: 1000, easing: tween.linear, onFinish: function onFinish() { displayedGold = tweenObj.value; } }); Object.defineProperty(tweenObj, 'value', { get: function get() { return displayedGold; }, set: function set(v) { displayedGold = v; } }); } // Save functionality removed - game resets on reload }; // Load functionality removed - game starts fresh on each reload // Play background music LK.playMusic('ambientMusic', { fade: { start: 0, end: 0.3, duration: 2000 } });
===================================================================
--- original.js
+++ change.js
@@ -1655,8 +1655,10 @@
LK.getSound('purchase').play();
// Update button to show piano was purchased
buyInstrumentBtn.updateButton('Piano', 10000, false, undefined, true, 'Purchased');
buyInstrumentBtn.visible = true;
+ // Always keep pianoPurchased flag in sync
+ window.pianoPurchased = true;
return;
}
}
// Check if Flute button was clicked (when on piano view)
@@ -1868,8 +1870,9 @@
window.arrow4.init('arrow4');
window.arrow4.x = 1024 + 850;
window.arrow4.y = 1220;
window.arrow4.visible = true;
+ window.pianoPurchased = true;
window.arrow4.clickHandler = function () {
// Switch to piano view
var pianoCenterX = 1024;
var INSTRUMENT_DISTANCE = 1200;
@@ -2424,17 +2427,18 @@
buyMusicianBtn.updateButton('Audience', musicianCost, gold >= musicianCost && !isAudienceLocked, musicians.length, isAudienceLocked, audienceLockMessage);
// Show piano button if piano is purchased
var isPianoLocked = musicians.length < 30 || isAudienceLocked || window.maracasShakeCount < 5;
var pianoLockMessage = window.maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? '5 Maracas Shake' : musicians.length < 30 ? '30 Audience' : '';
- buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked, undefined, isPianoLocked, pianoLockMessage);
+ buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked && !window.pianoPurchased, undefined, isPianoLocked || !!window.pianoPurchased, window.pianoPurchased ? 'Purchased' : pianoLockMessage);
buyInstrumentBtn.visible = true;
// Create arrow4 if piano exists
if (window.pianoAsset && !window.arrow4) {
window.arrow4 = game.addChild(new ArrowButton());
window.arrow4.init('arrow4');
window.arrow4.x = maracasCenterX + 850;
window.arrow4.y = 1220;
window.arrow4.visible = true;
+ window.pianoPurchased = true;
window.arrow4.clickHandler = function () {
// Switch to piano view
var pianoCenterX = 1024;
var INSTRUMENT_DISTANCE = 1200;
@@ -2622,13 +2626,17 @@
buyInstrumentBtn.visible = true;
};
} else if (window.arrow4) {
window.arrow4.visible = true;
+ window.pianoPurchased = true;
+ window.pianoPurchased = true;
}
};
} else if (window.arrow3) {
window.arrow3.visible = true;
}
+ window.pianoPurchased = !!window.pianoAsset;
+ window.pianoPurchased = !!window.pianoAsset;
currentInstrument = 'cymbal';
};
}
}
@@ -3228,9 +3236,9 @@
// Show Piano button - unlock when audience reaches 30
var isAudienceLocked = window.maracasShakeCount < 5;
var isPianoLocked = musicians.length < 30 || isAudienceLocked || window.maracasShakeCount < 5;
var pianoLockMessage = window.maracasShakeCount < 5 ? '5 Maracas Shake' : isAudienceLocked ? '5 Maracas Shake' : musicians.length < 30 ? '30 Audience' : '';
- buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked, undefined, isPianoLocked, pianoLockMessage);
+ buyInstrumentBtn.updateButton('Piano', 10000, gold >= 10000 && !isPianoLocked && !window.pianoPurchased, undefined, isPianoLocked || !!window.pianoPurchased, window.pianoPurchased ? 'Purchased' : pianoLockMessage);
buyInstrumentBtn.visible = true;
} else if (currentInstrument === 'piano') {
// Initialize pianist cost and count
if (typeof window.pianistCost === 'undefined') {
Horizontal drumstick for drum 2d pixelart. In-Game asset. 2d. High contrast. No shadows
Drum 2d pixelart. In-Game asset. 2d. no drums
detailed brunette woman from behind pixel art 2d. In-Game asset. 2d. High contrast. No shadows
man pixel art with different clothes
brown yellow haired man pixel art
yellow plus brown haired man pixel art with different colors of clothing
guitar pixel art 2d horizontal. In-Game asset. 2d. High contrast. No shadows
lock pixel art. In-Game asset. 2d. High contrast. No shadows
cymbal instrument pixel art 2d. In-Game asset. 2d. High contrast. No shadows
straight stick pixel art horizontal 2d. In-Game asset. 2d. High contrast. No shadows
maracas instrument pixelart vertical 2d. In-Game asset. 2d. High contrast. No shadows
piano pixelart 2d. In-Game asset. 2d. High contrast. No shadows
pianist man with hat from behind standing in chair without piano pixel art 2d
flute pixel art 2d vertical. In-Game asset. 2d. High contrast. No shadows
disco ball pixel art 2d. In-Game asset. 2d. High contrast. No shadows
Pixel art style
Confetti stick, 2d pixel art vertical. no papers only stick. In-Game asset. 2d. High contrast. No shadows
disco ball pixel art 2d. In-Game asset. 2d. High contrast. No shadows
Make different variations this pixel art change clothes, change hairstyle
make different variations of this pixel art change hairstyle, clothing
make different hairstyle and clothing, you can use cap etc.
make different hairstyle and clothing
make different hairstyle and clothing
make different hairstyle and clothing, you can make punk
make different clothing, you can make it blonde
make different hairstyle and clothing, you can make man wearing hoodie
One Confetti paper pixelart 2d. In-Game asset. 2d. High contrast. No shadows
Remove band clicker write, make drum in the middle
Make it red
Make it green
Make it blue
make it white
make it purple
#F3D296 colour small arrow pixel art. In-Game asset. 2d. High contrast. No shadows
Change writing to the ''MENU''
Make empty pixel art game card. #f3d296 color. In-Game asset. 2d. High quality. No shadows
Remove ball,
Remove stick, left ball alone
Change writing to the ''BPM OPTIONS'' pixel art
Make audio's lines dark black, audio color dark gray. Make x's lines black and inside color red.
Remove audio, left x
Make it brown
Can you make it lighter
make it #7d522e
Money gun pixel art. Without money, horizontal. In-Game asset. 2d. High contrast. No shadows
Make it red box
Make it resd