User prompt
Explanation The code uses a helper function ext to wrap calls to Container.expand so that class definitions become shorter. Repeated loops (such as iterating over game.children or updating child objects) are written with concise arrow functions. Comments have been minimized while still noting key functionality. No gameplay functionality is removed—the same spawn, collision, and fade conditions remain intact. This version should preserve the same functionality as your original code while reducing overall line count and redundancy. i want you to do this things
User prompt
enden istediğim bu koddaki hiçbir fonksiyonelliği bozmadan kodu sadeleştirmen yani oynanıştan ve gerekli kodlardan hiçbir şey gitmesin ancak satır sayısı azalsın
User prompt
Below is one approach to “freeze” the game immediately when yesil1 reaches 3 points so that no objects (including the tube) continue moving before the scheduled destruction. In this revision, we immediately override all update functions as soon as the condition is met and then schedule the destruction after 500 milliseconds. For example, change the freeze condition in yesil1.update from: js Kopyala Düzenle // Freeze condition (old) if (yesil1.points >= 3) { console.log("Freeze game triggered because yesil1 points reached: " + yesil1.points); stopSpawn = true; // Stop enemy and flyin enemy spawns // Freeze the character immediately player.update = function () {}; // Start a timer for 0.33 seconds LK.setTimeout(function () { // Destroy character, enemies, flyinEnemies, and coins after 0.5 seconds LK.setTimeout(function () { player.destroy(); for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].destroy(); enemies.splice(i, 1); } for (var i = flyinEnemies.length - 1; i >= 0; i--) { flyinEnemies[i].destroy(); flyinEnemies.splice(i, 1); } for (var i = coins.length - 1; i >= 0; i--) { coins[i].destroy(); coins.splice(i, 1); } }, 500); // Freeze the game, including yesil1, tube, and background2 for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } }, 330); } You can modify it to freeze immediately as follows: js Kopyala Düzenle // Freeze condition (modified) if (yesil1.points >= 3) { console.log("Freeze game triggered because yesil1 points reached: " + yesil1.points); stopSpawn = true; // Stop further spawns immediately // Immediately freeze all game objects (including tubes, backgrounds, etc.) for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } // Schedule destruction of the player, enemies, flyinEnemies, and coins after 500 ms LK.setTimeout(function () { player.destroy(); for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].destroy(); enemies.splice(i, 1); } for (var i = flyinEnemies.length - 1; i >= 0; i--) { flyinEnemies[i].destroy(); flyinEnemies.splice(i, 1); } for (var i = coins.length - 1; i >= 0; i--) { coins[i].destroy(); coins.splice(i, 1); } }, 500); } Explanation Immediate Freeze: As soon as yesil1’s points reach 3, we iterate over all children in the game and override their update functions with an empty function. This stops all motion (including the tube's leftward movement) immediately. Delayed Destruction: After a 500‐millisecond delay, we destroy the player and remove all remaining enemies, flyinEnemies, and coins. Using this modification should prevent any unwanted movement (like the tube sliding left) after the freeze condition is met. Adjust the delay times as needed to achieve your desired visual effect.
User prompt
freeze the character at the time yesil_1 has 3 points
User prompt
when yesil_1 has 3 points or more start a time counter for 0.33 seconds then destroy character ,destroy enemy flyinenemy and coin 0.5 seconds later,freeze the game, yesil_1 and tube_1 and background2 included
User prompt
freeze yesil_1 when yesil_1 has 3 points
User prompt
set velocity of background2 and yesil_1 to 0 when yesil_1 has 3 points
User prompt
set velocity of everything to 0 when yesil_1 has 3 points
User prompt
when yesil_1 has 3 points or more start a time counter for 0.33 seconds then destroy character ,destroy enemy flyinenemy and coin 0.5 seconds later
User prompt
after yesil_1 has 3 points wait for 0.33 seconds then destroy character ,destroy enemy flyinenemy and coin 0.5 seconds later
User prompt
kodumdan pek memnun olmadığım konular var gereksiz bazı oyun fonksiyonunu hiç değiştirmeyen ancak yer kaplayan satırlar var,oyunda var olan fade fonksiyonunun aynısını fade 2 olarak yapmak istiyorum, yesil_1 3 puana ulaştığında control asseti aktifleştiğinde olanların tıpatıp aynısının olamsını istiyorum tek bir farkla ekrana bg3first spawn olacak ekranın en arkasında o olacak onun bir önünde ikinci arkaplan olarak background3 olacak bunlar ekranda 12 saniye kaldıktan sonra sola doğru hareket edecek
User prompt
Please fix the bug: 'Timeout.tick error: Cannot set properties of undefined (setting 'speed')' in or related to this line: 'game.scrollingBg2.speed = 0;' Line Number: 904
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'speed')' in or related to this line: 'var oldScrollingSpeed = game.scrollingBg2.speed;' Line Number: 902
User prompt
yesil_1 3 puan olduktan sonra fade in fade out işlemi oluyor ya fade in sırasında ekranın ortasına ilk baş bg3first ondan 0.00001 saniye sonra background3 spawn olsun ve ekranda 8 saniye kaldıktan sonra sola gitsinler
User prompt
bg3first ve bg3 spawn olmadı olduysa da görmedim ekranın ortasına spawn olsunlar fade in den sonra , 8 saniye dursunlar olduğu yerde sonra sola doğru hareket etsinler,fade in fade out olduğundan emin ol
User prompt
yesil_1 3 puan kazandığında fade in fade out ekrandaki her şeyin silinme ve karakterin yukarıdan spawn olma işlemleri gerçekleşsin ancak tek fark background2 silinince yerine bg3first ve background3 gelsin ekrana
User prompt
Below are several steps and suggestions to help diagnose and resolve why the fade effect isn’t working as expected: Check the Trigger Condition: In your code, the fade2 function is called inside the yesil1.update when its points reach 3. Make sure that the points are actually reaching 3. Add console.log statements right before the condition to verify that yesil1.points is incrementing as expected. Verify the game.controlActive Flag: The fade2 function only runs when game.controlActive is true. Ensure that this flag is being set appropriately in your game logic (for example, during the control event). Temporarily log the value of game.controlActive when you expect fade2 to trigger. Confirm Asset Loading: The fade2 effect depends on the assets overlay, bg3first, and background3. Double-check that these assets are correctly named and available in your project. You can try testing a simple version of fade2 that only displays the overlay to confirm that the asset is loaded and visible. Simplify and Debug the Fade Flow: The current fade2 function uses several steps (fade-out, removal of children, fade-in, etc.). To isolate the issue, simplify the function. For example, first try to only adjust the overlay’s alpha over time without removing game children. Once you see the overlay fade effect, gradually add back the steps (clearing children and adding new assets) and test at each stage. Examine Overlapping Functions: Your code also includes an enhancedFadeEffect function. Make sure that the fade2 and enhancedFadeEffect functions aren’t conflicting or overwriting each other. Verify that only one fade effect is intended to run at a time and that any flags (such as game.isFading and game.fadeCompleted) are reset properly after the fade effect. Use Detailed Logging: Insert console logs in key parts of fade2 to trace its progress (e.g., “fade2: starting fade-out”, “fade2: children cleared”, “fade2: adding new background assets”, etc.). This will help you pinpoint where the function might be stopping or not behaving as expected. By following these steps and carefully verifying each condition, you should be able to identify why the fade2 effect isn’t being executed. Adjust your debugging output based on your findings, and then incrementally restore the full fade effect functionality. Let me know if you need further assistance with any specific part of the debugging process! , yorum satırlarını kaldır
User prompt
fade2 çalışmadı,ekrandaki her şey yok olmadı , bg3first ve background3 ekrana gelmedi
User prompt
fade effect fonksiyonunun kopyasını oluştur adı fade2 olsun, yesil_1 3 puana ulaşınca koddaki fade2 çalışsın,fade in olduğunda ekrandaki her şey yok olsun,ekranın ortasına bg3first gelsin onun üstüne background3 gelsin yani background3 bg3firstin önünde dursun tek bir kodda ver
User prompt
Aşağıdaki kod parçası, mevcut fade effect fonksiyonunun (enhancedFadeEffect) işleyiş mantığını referans alarak yeni bir fade2 fonksiyonu oluşturur. Bu fade2, yesil_1’in puanı 3 veya daha yüksek olduğunda çalışır; fade in başladığında ekran tamamen temizlenir, ortada bg3first oluşturulur ve bunun üstüne background3 eklenir (background3, bg3first’in önünde yer alır). Aşağıdaki kodu, projenizin ilgili kısmına ekleyin; yesil_1’in update fonksiyonunda puan kontrolü yapılarak fade2 tetiklenir: js Kopyala Düzenle /**** Yeni Fade2 Fonksiyonu ****/ function fade2() { if (game.isFading || game.fadeCompleted) { return; } game.isFading = true; var overlay = LK.getAsset('overlay', { anchorX: 0, anchorY: 0 }); overlay.alpha = 0; if (!overlay.parent) { LK.stage.addChild(overlay); } var steps = 20; var duration = 500; var stepTime = duration / steps; var currentStep = 0; // Fade-out (ekran kararıyor) var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); // Ekrandaki tüm objeleri temizle while (game.children.length > 0) { game.removeChild(game.children[0]); } // Ortada bg3first’i oluştur var bg3first = LK.getAsset('bg3first', { anchorX: 0.5, anchorY: 0.5 }); bg3first.x = game.width / 2; bg3first.y = game.height / 2; game.addChild(bg3first); // Üzerine background3’ü ekle (background3, bg3first’in üstünde görünsün) var background3 = LK.getAsset('background3', { anchorX: 0.5, anchorY: 0.5 }); background3.x = game.width / 2; background3.y = game.height / 2; game.addChild(background3); // Fade-in (nesneler görünür hale gelsin) currentStep = 0; var fadeInDuration = 500; var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = 1 - currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; } }, fadeInStepTime); } }, stepTime); } /**** Örnek: yesil_1’in update fonksiyonu içinde puan kontrolü ****/ yesil1.update = function () { yesil1.x -= yesil1.speed; if (yesil1.x < -yesil1.width) { yesil1.destroy(); } // (1) Fade-out bonus (daha önce tetikleniyorsa) if (game.fadeTriggered && !yesil1.fadeBonusApplied) { yesil1.fadeBonusApplied = true; yesil1.points += 1; console.log("Fade bonus applied. Yesil1 points: " + yesil1.points); } // (2) Coin bonus if (coinCounter >= 30 && !yesil1.coinBonusApplied) { yesil1.coinBonusApplied = true; yesil1.points += 1; console.log("Coin bonus applied. Yesil1 points: " + yesil1.points); } // (3) Touch bonus: Eğer yesil1 puanı 3 veya daha yüksekse fade2 çalıştır if (player.intersects(yesil1) && yesil1.points >= 3 && !yesil1.touchBonusApplied) { yesil1.touchBonusApplied = true; yesil1.points += 1; console.log("Touch bonus applied. Yesil1 points: " + yesil1.points); // Fade2 tetikleniyor fade2(); } }; Açıklamalar: fade2 Fonksiyonu: İlk olarak overlay üzerinden ekran karartma (fade-out) uygulanır. Fade-out tamamlandığında, game içerisindeki tüm çocuklar temizlenir. Ardından, ortada bg3first oluşturulup eklenir; hemen üzerine background3 eklenir. Sonrasında overlay, fade-in etkisiyle kaybolur ve ekranda yeni sahne (bg3first ve background3) kalır. yesil1.update İçinde: yesil_1’in puanı 3 veya üzerinde olduğunda ve oyuncu yesil1 ile çakıştığında fade2 fonksiyonu çağrılır. Bu kod parçasını mevcut oyun kodunuzdaki ilgili kısma eklediğinizde, yesil_1’in puanı 3’e ulaştığında veya üzerine temas gerçekleştiğinde fade2 tetiklenecek ve ekran istenen şekilde temizlenip yeni arka planlar yüklenecektir.
User prompt
create the same fade effect elements again with the name of fade2, after character activates yesil_1
User prompt
control aktifleştiğinde yeni enemy ve flyin enemy spawn olmasın yani 5 saniye boyunca spawn dursun,control aktifleştiğinde coin sola hareket hızı 0 olsun 5 saniye sonra normalde dönsün, Set coin velocity to 0 for 4 seconds when yesil_1 is active Stop flyin enemy and enemy spawns when yesil_1 has 3 points
User prompt
Set coin velocity to 0 for 4 seconds when control is active,when yesil_1 has 3 points stop flyin enemy and enemy spawns
User prompt
control aktifleştiğinde yeni spawn olmasın spawn dursun,control aktifleştiğinde coin sola hareket hızı 0 olsun
User prompt
Aşağıdaki örnekte, control bonusu yerine fade-out bonusu, coin bonusu ve dokunma bonusu olacak şekilde kodu düzenledim. Aşağıdaki değişiklikleri yapıyoruz: Fade-out bonusu: Fade-out gerçekleştiğinde (enhancedFadeEffect fonksiyonunda) bir bayrak (game.fadeTriggered) ayarlanıyor. yesil_1.update içinde, eğer game.fadeTriggered aktifse ve henüz fade bonusu uygulanmamışsa, yesil_1’e 1 puan ekleniyor. Coin bonusu: Eğer coinCounter 30 veya üzerindeyse ve coin bonusu henüz uygulanmamışsa, yesil_1’e 1 puan ekleniyor. Dokunma bonusu: Eğer yesil_1 zaten 2 puana ulaşmışsa (yani fade ve/veya coin bonusu sonucu 2 puan varsa) ve oyuncu yesil_1 ile temas ederse, dokunma bonusu (1 puan) veriliyor. Freeze: yesil_1 puanı 3’e ulaştığında, oyundaki tüm update fonksiyonları boş fonksiyona atanarak oyunun hızı sıfırlanıyor. Aşağıda ilgili kısımları içeren düzenlenmiş kod örneğini bulabilirsiniz: js Kopyala Düzenle // ... (Diğer asset ve sınıf tanımlamaları aynı kalıyor) // Tube Spawn kısmında yesil_1 update fonksiyonunu aşağıdaki gibi değiştirin: function spawnTube() { if (stopSpawn) { return; } var tube = new Tube(); tube.x = 2048 + 125; tube.y = 2732 / 2 - 120; game.addChild(tube); var yesil1 = LK.getAsset('yesil_1', { anchorX: 0.5, anchorY: 0.5 }); yesil1.x = tube.x; yesil1.y = tube.y - 170; yesil1.speed = 10; yesil1.points = 0; // Başlangıç puanı // Bonus bayrakları: yesil1.fadeBonusApplied = false; yesil1.coinBonusApplied = false; yesil1.touchBonusApplied = false; yesil1.update = function () { // Yesil_1 sola doğru hareket ediyor: yesil1.x -= yesil1.speed; if (yesil1.x < -yesil1.width) { yesil1.destroy(); } // (1) Fade-out bonusu: enhancedFadeEffect içinde game.fadeTriggered bayrağı ayarlanmalı if (game.fadeTriggered && !yesil1.fadeBonusApplied) { yesil1.fadeBonusApplied = true; yesil1.points += 1; console.log("Fade bonus applied. Yesil1 points: " + yesil1.points); } // (2) Coin bonusu: coinCounter 30 veya üzeriyse if (coinCounter >= 30 && !yesil1.coinBonusApplied) { yesil1.coinBonusApplied = true; yesil1.points += 1; console.log("Coin bonus applied. Yesil1 points: " + yesil1.points); } // (3) Dokunma bonusu: yesil1 zaten 2 veya daha fazla puana ulaştıysa if (player.intersects(yesil1) && yesil1.points >= 2 && !yesil1.touchBonusApplied) { yesil1.touchBonusApplied = true; yesil1.points += 1; console.log("Touch bonus applied. Yesil1 points: " + yesil1.points); console.log("Player intersects yesil1: " + player.intersects(yesil1)); } // Freeze koşulu: yesil1 puanı 3 veya üzerindeyse if (yesil1.points >= 3) { console.log("Freeze game triggered because yesil1 points reached: " + yesil1.points); // Tüm game.children'in update fonksiyonlarını sıfırla (oyunun hızı 0 olsun) for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } } }; game.addChild(yesil1); // Control asseti (kontrol olayını tetiklemek için) var control = LK.getAsset('control', { anchorX: 0.5, anchorY: 0.5 }); control.x = 0; control.y = -177.5; tube.addChild(control); control.update = function () { if (player.intersects(control)) { if (!firstControlTriggered && coinCounter >= 10) { // Bu kısımda artık bonus puan verilmeden sadece kontrol olayını tetikliyoruz game.controlActive = true; control.update = function () {}; // Tek seferlik tetikleme console.log("Control event triggered: coinCounter = " + coinCounter); startNormalEnemy = false; // Diğer düşmanları temizle: LK.setTimeout(function () { for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].destroy(); enemies.splice(i, 1); } for (var i = flyinEnemies.length - 1; i >= 0; i--) { flyinEnemies[i].destroy(); flyinEnemies.splice(i, 1); } }, 400); for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } LK.setTimeout(function () { player.destroy(); }, 330); enhancedFadeEffect(); // Bu fonksiyon içinde game.fadeTriggered ayarlanacak firstControlTriggered = true; } } }; if (!stopSpawn) { LK.setTimeout(spawnTube, 15000); } } spawnTube(); // --- enhancedFadeEffect fonksiyonunu aşağıdaki gibi düzenleyin: function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { return; } game.isFading = true; // Fade-out bonusunun uygulanabilmesi için bayrak: game.fadeTriggered = true; var overlay = LK.getAsset('overlay', { anchorX: 0, anchorY: 0 }); overlay.alpha = 0; if (!overlay.parent) { LK.stage.addChild(overlay); } var steps = 20; var duration = 500; var stepTime = duration / steps; var currentStep = 0; var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); currentStep = 0; stopSpawn = true; while (game.children.length > 0) { game.removeChild(game.children[0]); } var scrollingBg2 = new ScrollingBackground2(); scrollingBg2.alpha = 0; game.scrollingBg2 = scrollingBg2; game.addChild(scrollingBg2); var tube2 = new Tube2(); control_2.x = 0; control_2.y = -177.5; tube2.addChild(control_2); // İki kez control_2 update tanımlaması yapılmış; ihtiyaca göre sadeleştirilebilir. control_2.update = function () { if (player && player.intersects(control_2)) { if (coinCounter >= 30) { console.log("Control_2 event triggered: coinCounter = " + coinCounter); for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } } } }; tube2.x = 2048 / 2 + 140; tube2.y = tube2.height / 2 - 60; game.addChild(tube2); LK.setTimeout(function () { var newPlayer = new Player(); newPlayer.hearts = remainingHearts; newPlayer.x = 2048 / 2 - 30; newPlayer.y = tube2.y; newPlayer.isFalling = true; newPlayer.fallSpeed = 0; newPlayer.fallAcceleration = 0.7; newPlayer.fallTargetY = 2732 / 2 - 7; game.addChild(newPlayer); player = newPlayer; game.weaponEnabled = true; LK.setTimeout(function () { spawnWaveOfFlyinEnemies(); }, 800); LK.setTimeout(function () { startNormalEnemy = true; }, 10500); }, 500); var fadeInDuration = 500; var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { if (game.scrollingBg2) { game.scrollingBg2.alpha = currentStep / steps; } currentStep++; } else { LK.clearInterval(fadeInInterval); if (overlay.parent) { overlay.parent.removeChild(overlay); } var oldScrollingSpeed = game.scrollingBg2.speed; var oldTubeSpeed = tube2.speed; game.scrollingBg2.speed = 0; tube2.speed = 0; LK.setTimeout(function () { game.scrollingBg2.speed = oldScrollingSpeed; tube2.speed = oldTubeSpeed; stopSpawn = false; game.isFading = false; game.fadeCompleted = true; }, 8000); } }, fadeInStepTime); } }, stepTime); } Açıklamalar Yesil_1 Bonusları: Artık control bonusu yok. Fade bonusu, enhancedFadeEffect çalıştığında game.fadeTriggered bayrağı sayesinde yesil_1.update içinde 1 puan ekliyor. Coin bonusu coinCounter >= 30 olduğunda, bir kereye mahsus ek 1 puan veriyor. Dokunma bonusu, yesil_1 zaten 2 puana ulaştığında oyuncu ile temas ederse 1 puan ekliyor. Yesil_1 puanı 3 veya üzeri olduğunda, oyundaki tüm update fonksiyonları boşaltılarak oyun “donduruluyor”. enhancedFadeEffect: Bu fonksiyonda game.fadeTriggered bayrağı aktif hale getiriliyor. Böylece yesil_1 update fonksiyonunda fade bonusu tetikleniyor. Bu düzenlemelerle, istediğiniz senaryonun (fade-out bonusu 1 puan, coin bonusu 1 puan, ve 2 puana ulaşıldıktan sonra dokunma bonusu ile 3 puana ulaşınca oyunun donması) sağlanması amaçlanmıştır. Tarayıcı konsolundaki log mesajları ile bonusların ne zaman uygulandığını kontrol edebilirsiniz.
/**** * Classes ****/ // Coin class var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.velocity = 5; self.zIndex = 15; self.update = function () { if (game.controlActive) { self.velocity = 0; LK.setTimeout(function () { self.velocity = 5; }, 4000); } else { self.x -= self.velocity; } }; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.zIndex = 10; self.canDamage = true; self.update = function () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); // FlyinEnemy class (destek: hem eski (homing false) hem de yeni (homing true)) var FlyinEnemy = Container.expand(function () { var self = Container.call(this); var flyinEnemyGraphics = self.attachAsset('flyin_enemy', { anchorX: 0.5, anchorY: 0 }); self.speed = 5; self.zIndex = 10; self.canDamage = true; self.homing = false; // false: eski davranış, true: oyuncuya yönelik self.vx = 0; self.vy = 0; self.update = function () { if (!self.homing) { self.x -= self.speed; if (self.x < -50) { self.destroy(); } } else { self.x += self.vx; self.y += self.vy; if (self.x < -200 || self.x > 2248 || self.y < -200 || self.y > 2932) { self.destroy(); } } }; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.jumpHeight = 40; self.isJumping = false; self.velocityY = 0; self.isFalling = false; self.fallSpeed = 0; self.fallAcceleration = 0.7; self.fallTargetY = 2732 / 2 - 7; self.zIndex = 20; self.hearts = typeof remainingHearts !== 'undefined' ? remainingHearts : 3; self.update = function () { self.prevY = self.y; if (self.isFalling) { self.y += self.fallSpeed; self.fallSpeed += self.fallAcceleration; if (self.y >= self.fallTargetY) { self.y = self.fallTargetY; self.isFalling = false; self.fallSpeed = 0; game.weaponEnabled = true; } } self.prevY = self.y; if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.7; if (self.y >= 2732 / 2 - 3) { self.y = 2732 / 2 - 9; self.isJumping = false; self.velocityY = 0; } } }; self.invulnerable = false; // Invulnerability flag (initially false) self.hit = function () { if (!self.invulnerable) { self.loseHeart(); self.invulnerable = true; // Make player vulnerable again after 500ms LK.setTimeout(function () { self.invulnerable = false; }, 500); } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.velocityY = -self.jumpHeight; } }; self.loseHeart = function () { self.hearts--; playerDeaths++; if (playerDeaths === 1 && hearts[0]) { hearts[0].destroy(); } else if (playerDeaths === 2 && hearts[1]) { hearts[1].destroy(); } else if (playerDeaths === 3 && hearts[2]) { hearts[2].destroy(); } remainingHearts = self.hearts; // Update global remainingHearts if (hearts.length === 0) { for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].destroy(); enemies.splice(i, 1); } for (var i = flyinEnemies.length - 1; i >= 0; i--) { flyinEnemies[i].destroy(); flyinEnemies.splice(i, 1); } for (var i = coins.length - 1; i >= 0; i--) { coins[i].destroy(); coins.splice(i, 1); } self.destroy(); game.weaponEnabled = false; } }; }); // ScrollingBackground class var ScrollingBackground = Container.expand(function () { var self = Container.call(this); self.bg1 = LK.getAsset('background', { anchorX: 0, anchorY: 0 }); self.bg1.x = 0; self.bg1.y = 0; self.addChild(self.bg1); self.bg2 = LK.getAsset('background', { anchorX: 1, anchorY: 0 }); self.bg2.scaleX = -1; self.bg2.x = self.bg1.width; self.bg2.y = 0; self.addChild(self.bg2); self.speed = 2; self.update = function () { self.bg1.x -= self.speed; self.bg2.x -= self.speed; if (self.bg1.x + self.bg1.width <= 0) { self.bg1.x = self.bg2.x + self.bg2.width; } if (self.bg2.x + self.bg2.width <= 0) { self.bg2.x = self.bg1.x + self.bg1.width; } }; }); // ScrollingBackground2 class var ScrollingBackground2 = Container.expand(function () { var self = Container.call(this); var bg1 = LK.getAsset('background2', { anchorX: 0, anchorY: 0 }); bg1.x = 0; bg1.y = 0; self.addChild(bg1); var bg2 = LK.getAsset('background2', { anchorX: 1, anchorY: 0 }); bg2.scaleX = -1; bg2.x = bg1.width; bg2.y = 0; self.addChild(bg2); self.speed = 2; self.update = function () { bg1.x -= self.speed; bg2.x -= self.speed; if (bg1.x + bg1.width <= 0) { bg1.x = bg2.x + bg2.width; } if (bg2.x + bg2.width <= 0) { bg2.x = bg1.x + bg1.width; } }; }); // Tube class var Tube = Container.expand(function () { var self = Container.call(this); var tubeGraphics = self.attachAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.zIndex = 0; self.update = function () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); // Tube2 class var Tube2 = Container.expand(function () { var self = Container.call(this); var tubeGraphics = self.attachAsset('tube_2', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.zIndex = 2000; // Tube2 her zaman ön planda self.update = function () { self.x -= self.speed; if (self.x < -self.width) { self.destroy(); } }; }); // Weapon class var Weapon = Container.expand(function () { var self = Container.call(this); var weaponGraphics = self.attachAsset('weapon', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 40; self.update = function () { self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; weaponGraphics.rotation += 0.3; if (Math.abs(game.down.x - self.x) < self.speed && Math.abs(game.down.y - self.y) < self.speed) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ width: 2048, height: 2732, backgroundColor: 0x000000 }); /**** * Game Code ****/ var control_2 = LK.getAsset('control_2', { anchorX: 0.5, anchorY: 0.5 }); /**** * Global Variables & Flags ****/ var startNormalEnemy = true; // Normal enemy spawn, başta true; 12 sn sonra true olacak. var coinCounter = 0; var flyinEnemies = []; var playerDeaths = 0; var hearts = []; var remainingHearts = 3; // Global variable to track remaining hearts game.controlActive = false; var coins = []; var firstControlTriggered = false; // Global flag for first control activation var enemies = []; var enemySpawnInterval = Math.floor(Math.random() * 100) + 30; var enemySpawnCounter = 0; var stopSpawn = false; game.weaponEnabled = true; /**** * (A) Eski FlyinEnemy Spawn (sağdan sola, homing false) ****/ function spawnFlyinEnemy() { if (stopSpawn) { return; } var delay = Math.random() * 2000 + 2000; LK.setTimeout(function () { if (stopSpawn) { return; } var fe = new FlyinEnemy(); // Eski davranış: homing false fe.x = 2048; fe.y = 449; fe.zIndex = 10; game.addChild(fe); flyinEnemies.push(fe); spawnFlyinEnemy(); }, delay); } spawnFlyinEnemy(); /**** * (B) Wave şeklinde, homing davranışlı FlyinEnemy Spawn * (Wave enemy'ler Tube2’nin önünde görünmesi için z-index 2100) ****/ function spawnWaveOfFlyinEnemies() { var spawnPoints = [{ x: 0, y: 0 }, { x: 2048, y: 0 }, { x: 0, y: 2732 }, { x: 2048, y: 2732 }, { x: 1024, y: 0 }, { x: 1024, y: 2732 }, { x: 0, y: 1366 }, { x: 2048, y: 1366 }]; for (var i = spawnPoints.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = spawnPoints[i]; spawnPoints[i] = spawnPoints[j]; spawnPoints[j] = temp; } spawnPoints.forEach(function (point, index) { LK.setTimeout(function () { var enemy = new FlyinEnemy(); enemy.homing = true; enemy.wave = true; enemy.x = point.x; enemy.y = point.y; var dx = player.x - enemy.x; var dy = player.y - enemy.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance === 0) { distance = 1; } enemy.vx = dx / distance * enemy.speed; enemy.vy = dy / distance * enemy.speed; enemy.zIndex = 2100; // Tube2 z-index 2000 olduğundan, wave enemy'ler onun önünde görünsün. if (enemy.x < 1024) { enemy.scaleX = -1; } game.addChild(enemy); flyinEnemies.push(enemy); }, index * 800); // 0.8 sn arayla if (index === spawnPoints.length - 1) { LK.setTimeout(function () { spawnFlyinEnemy(); }, 10000); // 10 seconds after wave started } }); } /**** * Normal Enemy Spawn (sağdan sola, homing false) * Sadece startNormalEnemy true olduğunda update içinde spawn ediliyor. ****/ game.update = function () { scrollingBackground.update(); player.update(); if (game.scrollingBg2 && game.scrollingBg2.update) { game.scrollingBg2.update(); } for (var t = 0; t < game.children.length; t++) { var child = game.children[t]; if (child instanceof Tube || child === yesil1) { child.update(); } if (child.children) { for (var c = 0; c < child.children.length; c++) { var subChild = child.children[c]; if (subChild.update) { subChild.update(); } } } } enemySpawnCounter++; if (startNormalEnemy && !stopSpawn && enemySpawnCounter >= enemySpawnInterval && !(LK.ticks >= 876 && LK.ticks <= 936) && !(LK.ticks >= 1776 && LK.ticks <= 1836) && !(LK.ticks >= 2676 && LK.ticks <= 2736) && !(LK.ticks >= 3576 && LK.ticks <= 3636) && !(LK.ticks >= 4476 && LK.ticks <= 4536) && !(LK.ticks >= 5376 && LK.ticks <= 5436) && !(LK.ticks >= 6276 && LK.ticks <= 6336) && !(LK.ticks >= 7776 && LK.ticks <= 7836)) { var canSpawn = true; for (var i = 0; i < enemies.length; i++) { if (enemies[i].x > 1800) { canSpawn = false; break; } } if (canSpawn) { var tubeCollision = false; for (var t = 0; t < game.children.length; t++) { var child = game.children[t]; if (child.asset && child.asset.name === 'tup_1') { var enemyRight = 2048 + 75; var enemyLeft = 2048 - 75; var tubeRight = child.x + 125; var tubeLeft = child.x - 125; if (!(enemyLeft > tubeRight || enemyRight < tubeLeft)) { tubeCollision = true; break; } } } if (!tubeCollision) { LK.setTimeout(function () { if (stopSpawn) { return; } var enemy = new Enemy(); enemy.x = 2048; enemy.y = 2732 / 2 - 13; enemy.zIndex = 10; enemies.push(enemy); game.addChild(enemy); }, 100); } enemySpawnCounter = 0; enemySpawnInterval = Math.floor(Math.random() * 100) + 30; } enemySpawnCounter = 0; enemySpawnInterval = Math.floor(Math.random() * 100) + 30; } game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); // --- Enemy - Player --- for (var j = enemies.length - 1; j >= 0; j--) { if (enemies[j]) { enemies[j].update(); } if (player.intersects(enemies[j]) && enemies[j].canDamage) { enemies[j].canDamage = false; LK.effects.flashScreen(0xff0000, 750, 0.0001); player.hit(); // Use hit() method to trigger damage and invulnerability if (player.hearts <= 0) { LK.showGameOver(); } } for (var k = game.children.length - 1; k >= 0; k--) { var child = game.children[k]; if (child instanceof Weapon && child.intersects(enemies[j])) { var coin = new Coin(); coin.x = enemies[j].x; coin.y = enemies[j].y; coin.velocity = 5; game.addChild(coin); coins.push(coin); var particleEffect = LK.getAsset('particle', { anchorX: 0.5, anchorY: 0.5, color: 0x808080 }); particleEffect.x = enemies[j].x - 15; particleEffect.y = enemies[j].y; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); enemies[j].destroy(); child.destroy(); enemies.splice(j, 1); break; } } } // --- FlyinEnemy - Player --- for (var n = flyinEnemies.length - 1; n >= 0; n--) { if (flyinEnemies[n]) { flyinEnemies[n].update(); } if (player.intersects(flyinEnemies[n]) && flyinEnemies[n].canDamage) { flyinEnemies[n].canDamage = false; LK.effects.flashScreen(0xff0000, 750, 0.0001); player.hit(); // Use hit() method to trigger damage and invulnerability if (player.hearts <= 0) { LK.showGameOver(); } } for (var k = game.children.length - 1; k >= 0; k--) { var child = game.children[k]; if (child instanceof Weapon && child.intersects(flyinEnemies[n])) { if (!flyinEnemies[n].wave) { var coin = new Coin(); coin.x = flyinEnemies[n].x; coin.y = flyinEnemies[n].y + 60; coin.velocity = 5; game.addChild(coin); coins.push(coin); } var particleEffect = LK.getAsset('particle', { anchorX: 0.5, anchorY: 0.5, color: 0x808080 }); particleEffect.x = flyinEnemies[n].x - 30; particleEffect.y = flyinEnemies[n].y + 30; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); flyinEnemies[n].destroy(); child.destroy(); flyinEnemies.splice(n, 1); break; } } if (flyinEnemies[n] && !flyinEnemies[n].homing && flyinEnemies[n].x < -50) { flyinEnemies[n].destroy(); flyinEnemies.splice(n, 1); } } // --- Coin toplanması --- for (var m = coins.length - 1; m >= 0; m--) { var coin = coins[m]; coin.x -= coin.velocity; if (coin.x < -100) { coin.destroy(); coins.splice(m, 1); } else if (player.intersects(coin)) { coinCounter++; scoreText.setText(coinCounter.toString()); if (coinCounter > 9 && !scoreText.movedLeft) { scoreText.x -= 20; scoreText.movedLeft = true; } coin.destroy(); coins.splice(m, 1); } } }; // Dokunma/Kontrol game.down = function (x, y, obj) { if (player.isJumping && game.weaponEnabled) { if (!game.lastWeaponTime || Date.now() - game.lastWeaponTime > 350) { var weapon = new Weapon(); weapon.x = player.x; weapon.y = player.y; var dx = x - weapon.x; var dy = y - weapon.y; var distance = Math.sqrt(dx * dx + dy * dy); weapon.directionX = dx / distance; weapon.directionY = dy / distance; var angle = Math.acos(weapon.directionY / Math.sqrt(weapon.directionX * weapon.directionX + weapon.directionY * weapon.directionY)); var angleInDegrees = angle * (180 / Math.PI); if (angleInDegrees <= 30) { weapon.speed *= 1.3; } game.addChild(weapon); LK.setTimeout(function () { weapon.destroy(); }, 9000); game.lastWeaponTime = Date.now(); } } player.jump(); }; // Oyunu Sahneye Ekle LK.stage.addChild(game); /**** Tube Spawn (her 15 saniyede bir) ****/ function spawnTube() { if (stopSpawn) { return; } var tube = new Tube(); tube.x = 2048 + 125; tube.y = 2732 / 2 - 120; game.addChild(tube); var yesil1 = LK.getAsset('yesil_1', { anchorX: 0.5, anchorY: 0.5 }); yesil1.x = tube.x; yesil1.y = tube.y - 170; yesil1.speed = 10; yesil1.points = 0; // Initialize points for yesil_1 yesil1.fadeBonusApplied = false; // Flag for fade bonus yesil1.coinBonusApplied = false; // Flag for coin bonus yesil1.touchBonusApplied = false; // Flag for touch bonus yesil1.update = function () { yesil1.x -= yesil1.speed; if (yesil1.x < -yesil1.width) { yesil1.destroy(); } // (1) Fade-out bonus if (game.fadeTriggered && !yesil1.fadeBonusApplied) { yesil1.fadeBonusApplied = true; yesil1.points += 1; console.log("Fade bonus applied. Yesil1 points: " + yesil1.points); } // (2) Coin bonus if (coinCounter >= 30 && !yesil1.coinBonusApplied) { yesil1.coinBonusApplied = true; yesil1.points += 1; console.log("Coin bonus applied. Yesil1 points: " + yesil1.points); } // (3) Touch bonus if (player.intersects(yesil1) && yesil1.points >= 2 && !yesil1.touchBonusApplied) { yesil1.touchBonusApplied = true; yesil1.points += 1; console.log("Touch bonus applied. Yesil1 points: " + yesil1.points); console.log("Player intersects yesil1: " + player.intersects(yesil1)); } // Freeze condition if (yesil1.points >= 3) { console.log("Freeze game triggered because yesil1 points reached: " + yesil1.points); stopSpawn = true; // Stop all spawns for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } } }; game.addChild(yesil1); var control = LK.getAsset('control', { anchorX: 0.5, anchorY: 0.5 }); control.x = 0; control.y = -177.5; tube.addChild(control); control.update = function () { if (player.intersects(control)) { // First event: Trigger if coinCounter is 10 or more // First activation: if firstControlTriggered is false and coinCounter >= 10 // First control: If controlStage is 1 and coinCounter is 10 or more if (!firstControlTriggered && coinCounter >= 10) { game.controlActive = true; // Ensure controlActive is set to true control.update = function () {}; // Make control inactive after first use console.log("Control event triggered: coinCounter = " + coinCounter); startNormalEnemy = false; game.controlActive = true; stopSpawn = true; // Stop spawning new enemies when control is active LK.setTimeout(function () { for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].destroy(); enemies.splice(i, 1); } for (var i = flyinEnemies.length - 1; i >= 0; i--) { flyinEnemies[i].destroy(); flyinEnemies.splice(i, 1); } }, 400); for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } LK.setTimeout(function () { player.destroy(); }, 330); enhancedFadeEffect(); firstControlTriggered = true; // Optional: Reset coinCounter if desired // coinCounter = 0; // scoreText.setText(coinCounter.toString()); } } }; if (!stopSpawn) { LK.setTimeout(spawnTube, 15000); } } spawnTube(); /**** Arka Plan ve Oyuncu ****/ var scrollingBackground = new ScrollingBackground(); game.addChild(scrollingBackground); var player = game.addChild(new Player()); player.x = 2048 / 2 - 30; player.y = 2732 / 2 + 3; /**** Skor GUI ve Kalp ****/ var counterBackground = LK.getAsset('counter_background', { anchorX: 0.5, anchorY: 0.5 }); LK.gui.top.addChild(counterBackground); counterBackground.x = LK.gui.top.width / 2 - 62; // Move 3 pixels right counterBackground.y = 45; // Move 5 pixels up var scoreText = new Text2('0', { size: 80, fill: 0xFFFFFF }); LK.gui.top.addChild(scoreText); scoreText.x = LK.gui.top.width / 2 - 85; scoreText.y = 0; for (var i = 0; i < 3; i++) { var heart = LK.getAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); LK.gui.top.addChild(heart); heart.x = 50 + i * 110 + 390; heart.y = 50; hearts.push(heart); } /**** enhancedFadeEffect: Fade-out, clear scene, spawn background2, Tube2, then new player ****/ function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { return; } game.isFading = true; game.fadeTriggered = true; // Set fadeTriggered flag for fade-out bonus var overlay = LK.getAsset('overlay', { anchorX: 0, anchorY: 0 }); overlay.alpha = 0; if (!overlay.parent) { LK.stage.addChild(overlay); } var steps = 20; var duration = 500; var stepTime = duration / steps; var currentStep = 0; var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); currentStep = 0; stopSpawn = true; while (game.children.length > 0) { game.removeChild(game.children[0]); } var scrollingBg2 = new ScrollingBackground2(); scrollingBg2.alpha = 0; game.scrollingBg2 = scrollingBg2; game.addChild(scrollingBg2); var tube2 = new Tube2(); control_2.x = 0; // Centered in tube2 control_2.y = -177.5; // Same position as control tube2.addChild(control_2); control_2.update = function () { if (player && player.intersects(control_2)) { if (coinCounter >= 30) { console.log("Control_2 event triggered: coinCounter = " + coinCounter); for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } } } }; control_2.x = 0; // Centered in tube2 control_2.y = -177.5; // Same position as control tube2.addChild(control_2); control_2.update = function () { if (player && player.intersects(control_2)) { if (coinCounter >= 30) { console.log("Control_2 event triggered: coinCounter = " + coinCounter); for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } } } }; tube2.x = 2048 / 2 + 140; tube2.y = tube2.height / 2 - 60; game.addChild(tube2); LK.setTimeout(function () { var newPlayer = new Player(); newPlayer.hearts = remainingHearts; // Use global remainingHearts for new player newPlayer.x = 2048 / 2 - 30; newPlayer.y = tube2.y; newPlayer.isFalling = true; newPlayer.fallSpeed = 0; newPlayer.fallAcceleration = 0.7; newPlayer.fallTargetY = 2732 / 2 - 7; game.addChild(newPlayer); player = newPlayer; game.weaponEnabled = true; LK.setTimeout(function () { spawnWaveOfFlyinEnemies(); }, 800); LK.setTimeout(function () { startNormalEnemy = true; }, 10500); }, 500); var fadeInDuration = 500; var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { if (game.scrollingBg2) { game.scrollingBg2.alpha = currentStep / steps; } currentStep++; } else { LK.clearInterval(fadeInInterval); if (overlay.parent) { overlay.parent.removeChild(overlay); } var oldScrollingSpeed = game.scrollingBg2.speed; var oldTubeSpeed = tube2.speed; game.scrollingBg2.speed = 0; tube2.speed = 0; LK.setTimeout(function () { game.scrollingBg2.speed = oldScrollingSpeed; tube2.speed = oldTubeSpeed; stopSpawn = false; // Enemy spawn işlemlerine yeniden izin ver. game.isFading = false; game.fadeCompleted = true; }, 8000); } }, fadeInStepTime); } }, stepTime); } /**** Oyun Döngüsü ****/ game.update = function () { scrollingBackground.update(); player.update(); if (game.scrollingBg2 && game.scrollingBg2.update) { game.scrollingBg2.update(); } for (var t = 0; t < game.children.length; t++) { var child = game.children[t]; if (child instanceof Tube) { child.update(); } if (child.children) { for (var c = 0; c < child.children.length; c++) { var subChild = child.children[c]; if (subChild.update) { subChild.update(); } } } } enemySpawnCounter++; if (startNormalEnemy && !stopSpawn && enemySpawnCounter >= enemySpawnInterval && !(LK.ticks >= 876 && LK.ticks <= 936) && !(LK.ticks >= 1776 && LK.ticks <= 1836) && !(LK.ticks >= 2676 && LK.ticks <= 2736) && !(LK.ticks >= 3576 && LK.ticks <= 3636) && !(LK.ticks >= 4476 && LK.ticks <= 4536) && !(LK.ticks >= 5376 && LK.ticks <= 5436) && !(LK.ticks >= 6276 && LK.ticks <= 6336) && !(LK.ticks >= 7776 && LK.ticks <= 7836)) { var canSpawn = true; for (var i = 0; i < enemies.length; i++) { if (enemies[i].x > 1800) { canSpawn = false; break; } } if (canSpawn) { var tubeCollision = false; for (var t = 0; t < game.children.length; t++) { var child = game.children[t]; if (child.asset && child.asset.name === 'tup_1') { var enemyRight = 2048 + 75; var enemyLeft = 2048 - 75; var tubeRight = child.x + 125; var tubeLeft = child.x - 125; if (!(enemyLeft > tubeRight || enemyRight < tubeLeft)) { tubeCollision = true; break; } } } if (!tubeCollision) { LK.setTimeout(function () { if (stopSpawn) { return; } var enemy = new Enemy(); enemy.x = 2048; enemy.y = 2732 / 2 - 13; enemy.zIndex = 10; enemies.push(enemy); game.addChild(enemy); }, 100); } enemySpawnCounter = 0; enemySpawnInterval = Math.floor(Math.random() * 100) + 30; } enemySpawnCounter = 0; enemySpawnInterval = Math.floor(Math.random() * 100) + 30; } game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); // Çarpışma Kontrolleri for (var j = enemies.length - 1; j >= 0; j--) { if (enemies[j]) { enemies[j].update(); } if (player.intersects(enemies[j]) && enemies[j].canDamage) { enemies[j].canDamage = false; LK.effects.flashScreen(0xff0000, 750, 0.0001); player.loseHeart(); if (player.hearts <= 0) { LK.showGameOver(); } } for (var k = game.children.length - 1; k >= 0; k--) { var child = game.children[k]; if (child instanceof Weapon && child.intersects(enemies[j])) { var coin = new Coin(); coin.x = enemies[j].x; coin.y = enemies[j].y; coin.velocity = 5; game.addChild(coin); coins.push(coin); var particleEffect = LK.getAsset('particle', { anchorX: 0.5, anchorY: 0.5, color: 0x808080 }); particleEffect.x = enemies[j].x - 15; particleEffect.y = enemies[j].y; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); enemies[j].destroy(); child.destroy(); enemies.splice(j, 1); break; } } } for (var n = flyinEnemies.length - 1; n >= 0; n--) { if (flyinEnemies[n]) { flyinEnemies[n].update(); } if (player.intersects(flyinEnemies[n]) && flyinEnemies[n].canDamage) { flyinEnemies[n].canDamage = false; LK.effects.flashScreen(0xff0000, 750, 0.0001); player.loseHeart(); if (player.hearts <= 0) { LK.showGameOver(); } } for (var k = game.children.length - 1; k >= 0; k--) { var child = game.children[k]; if (child instanceof Weapon && child.intersects(flyinEnemies[n])) { if (!flyinEnemies[n].wave) { var coin = new Coin(); coin.x = flyinEnemies[n].x; coin.y = flyinEnemies[n].y + 60; coin.velocity = 5; game.addChild(coin); coins.push(coin); } var particleEffect = LK.getAsset('particle', { anchorX: 0.5, anchorY: 0.5, color: 0x808080 }); particleEffect.x = flyinEnemies[n].x - 30; particleEffect.y = flyinEnemies[n].y + 30; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); flyinEnemies[n].destroy(); child.destroy(); flyinEnemies.splice(n, 1); break; } } if (flyinEnemies[n] && !flyinEnemies[n].homing && flyinEnemies[n].x < -50) { flyinEnemies[n].destroy(); flyinEnemies.splice(n, 1); } } for (var m = coins.length - 1; m >= 0; m--) { var coin = coins[m]; coin.x -= coin.velocity; if (coin.x < -100) { coin.destroy(); coins.splice(m, 1); } else if (player.intersects(coin)) { coinCounter++; scoreText.setText(coinCounter.toString()); if (coinCounter > 9 && !scoreText.movedLeft) { scoreText.x -= 20; scoreText.movedLeft = true; } coin.destroy(); coins.splice(m, 1); } } }; // Dokunma/Kontrol game.down = function (x, y, obj) { if (player.isJumping && game.weaponEnabled) { if (!game.lastWeaponTime || Date.now() - game.lastWeaponTime > 350) { var weapon = new Weapon(); weapon.x = player.x; weapon.y = player.y; var dx = x - weapon.x; var dy = y - weapon.y; var distance = Math.sqrt(dx * dx + dy * dy); weapon.directionX = dx / distance; weapon.directionY = dy / distance; var angle = Math.acos(weapon.directionY / Math.sqrt(weapon.directionX * weapon.directionX + weapon.directionY * weapon.directionY)); var angleInDegrees = angle * (180 / Math.PI); if (angleInDegrees <= 30) { weapon.speed *= 1.3; } game.addChild(weapon); LK.setTimeout(function () { weapon.destroy(); }, 9000); game.lastWeaponTime = Date.now(); } } player.jump(); }; // Oyunu Sahneye Ekle LK.stage.addChild(game);
===================================================================
--- original.js
+++ change.js
@@ -10,9 +10,14 @@
});
self.velocity = 5;
self.zIndex = 15;
self.update = function () {
- if (!game.controlActive) {
+ if (game.controlActive) {
+ self.velocity = 0;
+ LK.setTimeout(function () {
+ self.velocity = 5;
+ }, 4000);
+ } else {
self.x -= self.velocity;
}
};
});
@@ -627,8 +632,9 @@
}
// Freeze condition
if (yesil1.points >= 3) {
console.log("Freeze game triggered because yesil1 points reached: " + yesil1.points);
+ stopSpawn = true; // Stop all spawns
for (var i = 0; i < game.children.length; i++) {
var obj = game.children[i];
if (obj.update) {
obj.update = function () {};
Single 2D Mario Character. In-Game asset. 2d. Blank background.
2D Single Monster. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
marionun ingiliz boru anahtarı aleti. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
red heart mario. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
completely black simple counter without sharp edges
sea and sky,pixel,realistic but detailles benzer renkler mavi ve mavi Single Game Texture. In-Game asset. 2d. Blank background. low contrast. No shadows