User prompt
Aşağıdaki örnekte, orijinal freeze kodunun oyun içindeki tüm objelerin update fonksiyonlarını kapatmasından dolayı background2 ve rotated tube’un güncellenip sola doğru hareket etmediği görülüyor. Freeze efektinin yalnızca gameplay kısmını dondurmasını ve fade‐out başladığı anda (yani overlay animasyonu başladığında) bu dondurmanın kaldırılmasını sağlamak için; Freeze İşlemini kontrol tetiklendiğinde uygulamak yerine, fade‐out başladığında game container’ı temizleyerek (yani freeze efektini sonlandırarak) background2 ve rotated tube’u sahneye (LK.stage) ekleyin. Böylece onların update fonksiyonları normal çalışmaya devam eder. Background2 ve Rotated Tube’yu game container’dan ziyade doğrudan LK.stage’e ekleyin, böylece game.children içindeki freeze etkisinden bağımsız olurlar. Aşağıdaki kod örneğinde freeze efektinin kaldırıldığı, fade‐out başladığı anda game.children temizlendiği ve ardından background2 ile rotated tube normal güncelleme döngüsünde sola doğru hareket eder hale getirildiği gösterilmiştir: js Kopyala Düzenle function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { return; // Birden fazla fade efektini önle } 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; // 500ms fade out/in süresi var stepTime = duration / steps; var currentStep = 0; // Fade-Out Aşaması: Overlay'nin alfa değeri artıyor var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); currentStep = 0; // Freeze efektini burada kaldırmak için game container içindeki tüm objeleri temizleyin. // Böylece artık oyun objelerinin update fonksiyonları dondurulmuş olmaz. while (game.children.length > 0) { game.removeChild(game.children[0]); } // Background2'yi oluşturup LK.stage'e ekleyin (doğrudan stage'de olduğundan update/dönüş animasyonu devam eder) var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); background2.x = 2048 / 2; background2.y = 2732 / 2; background2.width = 2048; background2.height = 2732; background2.alpha = 0; if (!background2.parent) { LK.stage.addChild(background2); } // Rotated tube'u oluşturup stage'e ekleyin rotatedTube = new Container(); var rotatedTubeGraphics = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); rotatedTubeGraphics.rotation = Math.PI; // 180° döndür rotatedTube.addChild(rotatedTubeGraphics); rotatedTube.x = 2048 / 2; rotatedTube.y = 100; rotatedTube.speed = 2; // background2 hızıyla uyumlu rotatedTube.zIndex = 1000; LK.stage.addChild(rotatedTube); // Rotated tube update fonksiyonu, stage update döngüsünde çağrılmalı rotatedTube.update = function () { this.x -= this.speed; }; // Fade-In Aşaması: Background2'nin alfa değeri 0'dan 1'e çıkarılıyor var fadeInDuration = 500; var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { background2.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); // Fade-In tamamlandıktan sonra overlay kaldırılıyor if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; // Artık ekranda sadece background2 ve sola hareket eden rotated tube var. } }, fadeInStepTime); } }, stepTime); } Açıklamalar Freeze Etkisini Kaldırma: Önceden kontrol tetiklenince tüm game.children objelerinin update fonksiyonu boşaltılıyordu. Bu yöntem background2 ve rotated tube gibi objelerin hareketini de engelliyordu. Yukarıdaki örnekte fade‐out başladığında game container tamamen temizlenerek freeze etkisi kaldırılır. Stage’e Eklenen Objeler: Background2 ve rotated tube, artık doğrudan LK.stage’e ekleniyor. Böylece game container’ın freeze etkisinden bağımsız olarak kendi update fonksiyonlarıyla sola doğru hareket edebiliyor.
User prompt
Please fix the bug: 'Timeout.tick error: Cannot set properties of undefined (setting 'update')' in or related to this line: 'game.rotatedTube.update = function () {' Line Number: 290
User prompt
Aşağıdaki örnekte, fade effect tamamlandığında (fade‐in bittiğinde) oyun içindeki tüm nesneler (player, enemy, coin, vs.) siliniyor; ekranda yalnızca background2 ve fade‐out sırasında oluşturulan sola hareket eden rotated tube kalıyor. Aşağıdaki kod parçası, mevcut enhancedFadeEffect fonksiyonunu bu işlevselliğe göre nasıl değiştirebileceğinizi gösteriyor: js Kopyala Düzenle function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { return; // Birden fazla fade etkisini önle } 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; // 500ms fade out/in süresi var stepTime = duration / steps; var currentStep = 0; // Fade-Out: overlay'nin alfa değerini 0'dan 1'e çıkarıyoruz var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); currentStep = 0; // Fade-out tamamlandığında: oyun alanındaki (game container) tüm nesneleri temizle // (Bu sayede fade-in'den sonra ekranda sadece background2 ve rotated tube kalacak) while (game.children.length > 0) { game.removeChild(game.children[0]); } // background2'yi oluşturup sahneye ekleyelim (ilk başta alfa 0) var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); background2.x = 2048 / 2; background2.y = 2732 / 2; background2.width = 2048; background2.height = 2732; background2.alpha = 0; if (!background2.parent) { LK.stage.addChild(background2); } // Fade-out sırasında sola doğru hareket edecek rotated tube'u spawn et var rotatedTube = new Container(); var rotatedTubeGraphics = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); rotatedTubeGraphics.rotation = Math.PI; // 180° döndür rotatedTube.addChild(rotatedTubeGraphics); rotatedTube.x = 2048 / 2; rotatedTube.y = 100; rotatedTube.speed = 2; // background2 hızı ile uyumlu rotatedTube.zIndex = 1000; // Rotated tube'u sahneye ekleyelim, böylece game container temizlense bile kalır LK.stage.addChild(rotatedTube); rotatedTube.update = function () { this.x -= this.speed; // Ekranın solundan çıkarsa buraya ekstra silme mantığı ekleyebilirsiniz }; // Fade-In: background2'nin alfa değerini 0'dan 1'e çıkarıyoruz var fadeInDuration = 500; var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { background2.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; // Artık fade effect tamamlanmış; ekranda yalnızca background2 ve sola hareket eden rotated tube var. // Yeni sahneye ait başka işlemler yapılacaksa buraya ekleyebilirsiniz. } }, fadeInStepTime); } }, stepTime); } Açıklama Fade-Out Aşaması: Overlay (karartma efekti) alfa değeri 0'dan 1'e yükselirken, fade-out tamamlanır tamamlanmaz game container içindeki tüm nesneler while (game.children.length > 0) { ... } döngüsü ile temizleniyor. Bu sayede, fade‐in başladığında ekranda yalnızca background2 ve rotated tube kalıyor. Rotated Tube: Fade-out sırasında spawn edilen rotated tube, sahneye (LK.stage) ekleniyor ve update fonksiyonu ile sola doğru hareket ediyor. Fade-In Aşaması: Ardından background2'nin alfa değeri 0'dan 1'e çıkarılıyor. Fade effect tamamlandığında overlay kaldırılıyor ve yeni sahnede yalnızca background2 (ve devam eden rotated tube) görünüyor. Bu düzenleme, normal oyunda ekranda görünen tüm unsurların fade-in sonrası temizlenip yalnızca arka planla (background2) ve fade-out sırasında spawn edilen rotated tube ile devam etmesini sağlar.
User prompt
Rotated tube’ün ekranda sürekli kalmasını sağlamak için şu noktalara dikkat etmelisiniz: Doğru Container Seçimi: Rotated tube’ü doğrudan LK.stage yerine game container’ına ekleyin. Böylece oyun içi sıralama (z-index) ve update çağrıları game.update döngüsünde gerçekleşir. Freeze Mantığından Hariç Tutma: Fade effect tetiklendiğinde diğer oyun objelerinin update fonksiyonlarını dondururken rotated tube’ü hariç tutun, böylece onun update fonksiyonu sürekli çalışır. Yok Olma Kontrolünü Kaldırın: Rotated tube’ün update fonksiyonunda yok olma koşulu (örneğin, x < -50 kontrolü) bulunmamalıdır; böylece tüp ekran dışına çıkana kadar görünür kalır. Aşağıda, bu noktalara göre rotated tube’ün fade effect sırasında game container’ına eklenmesi ve freeze döngüsünden hariç tutulması örneği verilmiştir: javascript Kopyala Düzenle // Fade effect fonksiyonunda rotated tube oluşturma kısmı: function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { 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; // 500ms 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; var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); background2.x = 2048 / 2; background2.y = 2732 / 2; background2.width = 2048; background2.height = 2732; background2.alpha = 0; if (!background2.parent) { LK.stage.addChild(background2); } // Rotated tube oluşturuluyor: game.rotatedTube = new Container(); var rotatedTubeGraphics = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); rotatedTubeGraphics.rotation = Math.PI; // 180 derece game.rotatedTube.addChild(rotatedTubeGraphics); game.rotatedTube.x = 2048 / 2; game.rotatedTube.y = 100; game.rotatedTube.speed = 2; // background2 hızıyla uyumlu game.rotatedTube.zIndex = 1000; // Yüksek z-index veriyoruz // Rotated tube'ü stage yerine game container'ına ekleyin: game.addChild(game.rotatedTube); // Rotated tube update fonksiyonu; yok olma kontrolü yok game.rotatedTube.update = function () { this.x -= this.speed; }; // Fade-in işlemi: var fadeInDuration = 500; var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { background2.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; createScrollingBackground2(); } }, fadeInStepTime); } }, stepTime); } Ve freeze (dondurma) mantığında rotated tube’ü hariç tutmayı unutmayın: javascript Kopyala Düzenle // Örneğin, kontrol tetiklenirken: for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj !== game.rotatedTube && obj.update) { obj.update = function () {}; } }
User prompt
Z-index ve Container Yerleşimi: Eğer rotated tube (dönmüş tüp) LK.stage üzerinde başka bir background (background2) gibi objeyle aynı seviyede ya da onun arkasında ekleniyorsa görünmeyebilir. Rotated tube’ü doğrudan stage’e ekleyip, çok yüksek bir z-index (örneğin 1000) atamak, diğer objelerin üstünde görünmesini sağlar. Freeze (Dondurma) İşlemi: Fade effect sırasında oyundaki tüm objelerin update fonksiyonları donduruluyor. Bu döngüde rotated tube’ü hariç tutmanız gerekir, aksi halde tüp update edilmez ve hareketi durur veya görünürlüğü etkilenir. Update ve Yok Olma Koşulları: Eğer tüpün update fonksiyonunda “yok olma” kontrolü varsa (örneğin ekran dışına çıktığında destroy ediliyorsa), tüp kısa sürede yok olabilir. Rotated tube için yok olma kontrolünü kaldırıp, sadece soldan sola hareket etmesini sağlayın. Aşağıdaki örnek kod, bu noktalara göre güncellendi: javascript Kopyala Düzenle // Fade effect içinde rotated tube oluşturma kısmı: function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { 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; // 500ms 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; var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); background2.x = 2048 / 2; background2.y = 2732 / 2; background2.width = 2048; background2.height = 2732; background2.alpha = 0; if (!background2.parent) { LK.stage.addChild(background2); } // Rotated tube oluşturuluyor: game.rotatedTube = new Container(); var rotatedTubeGraphics = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); rotatedTubeGraphics.rotation = Math.PI; // 180 derece game.rotatedTube.addChild(rotatedTubeGraphics); game.rotatedTube.x = 2048 / 2; game.rotatedTube.y = 100; game.rotatedTube.speed = 2; // Rotated tube'ü doğrudan stage'e ekleyip yüksek z-index veriyoruz: game.rotatedTube.zIndex = 1000; LK.stage.addChild(game.rotatedTube); // Rotated tube için yok olma kontrolü yok, update fonksiyonu sadece sola hareket edecek: game.rotatedTube.update = function () { this.x -= this.speed; }; // Fade-in kısmı: var fadeInDuration = 500; var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { background2.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; createScrollingBackground2(); } }, fadeInStepTime); } }, stepTime); } Ayrıca, dondurma (freeze) kısmında rotated tube dışındaki objeleri dondurun: javascript Kopyala Düzenle // Örneğin, kontrol objesi tetiklendiğinde: for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; // Rotated tube dışındakileri dondur: if (obj !== game.rotatedTube && obj.update) { obj.update = function () {}; } } Bu değişikliklerle: Rotated tube, fade effect sırasında stage’e eklenir ve yüksek z-index ile background2’nin üstünde kalır. Rotated tube’ün update fonksiyonu, dondurma döngüsünden hariç tutulduğundan sürekli sola hareket eder. Yok olma (destroy) kontrolü eklenmediği için, tüp ekran dışına çıkana kadar görünür kalır.
User prompt
rotated tube 1 saniyeliğine görünür oldu ardından hemen yok oldu ekrandan çıkana kadar görünür olması lazımdı çözümü şu Sorunu, kontrol etkinleştirilirken oyundaki tüm update fonksiyonlarını dondururken rotated tube’ü de kapsaması ve/veya rotated tube’ün yanlış container’a eklenmesi oluşturuyor. Eğer rotated tube’ü diğer oyun objelerinden ayırmazsak, kontrol tetiklendiğinde onun update fonksiyonu da boşaltılıp hareket etmez veya görünürlüğü etkilenir. Aşağıdaki çözüm önerisini deneyebilirsiniz: Rotated Tube’ü Oyun Container’ına Ekleyin: Böylece, oyun güncellemesinde (game.update) rotated tube için özel bir update çağrısı yapabilirsiniz. Kontrol Dondurma Döngüsünden Rotated Tube’ü Çıkarın: Kontrol etkinleştirilirken oyundaki tüm çocukların update fonksiyonunu dondururken rotated tube dışında bırakın. Örnek Değişiklikler: Kontrol Dondurma Kısmında: Bulunduğu yerde, javascript Kopyala Düzenle for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } şeklinde tüm objelerin update fonksiyonunu boşaltıyordunuz. Bunun yerine rotated tube dışındakileri dondurun: javascript Kopyala Düzenle for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; // Eğer obje rotated tube değilse update fonksiyonunu dondur if (obj !== game.rotatedTube && obj.update) { obj.update = function () {}; } } Rotated Tube’ü Oyun Container’ına Eklemek: Enhanced fade effect içerisinde rotated tube’ü doğrudan LK.stage yerine game container’ına ekleyin: javascript Kopyala Düzenle // Create a persistent rotated tube instead of using a temporary asset game.rotatedTube = new Container(); // Create a container for the tube var rotatedTubeGraphics = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); rotatedTubeGraphics.rotation = Math.PI; // Rotate 180 degrees game.rotatedTube.addChild(rotatedTubeGraphics); game.rotatedTube.x = 2048 / 2; game.rotatedTube.y = 100; game.rotatedTube.speed = 2; // Match background2 speed game.rotatedTube.zIndex = 1000; // Assign a high z-index value // Add the rotated tube to the game container game.addChild(game.rotatedTube); // Define a custom update function for the rotated tube game.rotatedTube.update = function () { this.x -= this.speed; // (İstediğiniz gibi, yok olma kontrolü ekleyebilirsiniz) }; Game Update İçerisinde Rotated Tube Güncellemesini Çağırın: Game döngünüzün uygun bir yerinde rotated tube’ün update fonksiyonunu çağırın (örneğin, diğer güncellemelerin hemen öncesinde): javascript Kopyala Düzenle if (game.rotatedTube && game.rotatedTube.update) { game.rotatedTube.update(); } Bu değişikliklerle, kontrol tetiklenip diğer oyun objeleri dondurulsa bile, rotated tube oyun container’ı içinde kalacak ve update fonksiyonu çalışmaya devam edecektir. Böylece rotated tube ekran dışına çıkana kadar görünür kalacaktır.
User prompt
Örnek Değişiklik: Mevcut kodunuzda enhancedFadeEffect fonksiyonunda rotated tube'ü eklediğiniz kısımda şu satırı: javascript Kopyala Düzenle game.addChild(game.rotatedTube); yerine, rotated tube'ü stage'e ekleyin: javascript Kopyala Düzenle game.rotatedTube.zIndex = 1000; // Yüksek bir z-index değeri atayın LK.stage.addChild(game.rotatedTube); Bu değişiklik, rotated tube'ün background2'nin üzerinde görünmesini sağlamalıdır. Eğer yine görünmezse, background2'nin eklenme sırasını ve alpha değerlerini de kontrol etmenizi öneririm.
User prompt
function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { return; // Prevent multiple fade effects and ensure single run } 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; // 500ms fade out/in duration var stepTime = duration / steps; var currentStep = 0; // Fade-Out: Alpha 0 -> 1 var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); currentStep = 0; // Fade-out complete: add center background with alpha 0 var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); background2.x = 2048 / 2; background2.y = 2732 / 2; background2.width = 2048; background2.height = 2732; background2.alpha = 0; if (!background2.parent) { LK.stage.addChild(background2); } // Create a persistent rotated tube instead of using a temporary asset game.rotatedTube = new Container(); // Create a container for the tube var rotatedTubeGraphics = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); rotatedTubeGraphics.rotation = Math.PI; // Rotate 180 degrees game.rotatedTube.addChild(rotatedTubeGraphics); game.rotatedTube.x = 2048 / 2; game.rotatedTube.y = 100; game.rotatedTube.speed = 2; // Match background2 speed game.rotatedTube.zIndex = 20; // Ensure it's visible above other elements // Add the rotated tube to the game game.addChild(game.rotatedTube); // Define a custom update function for the rotated tube game.rotatedTube.update = function() { this.x -= this.speed; // No destruction logic here }; // Fade-In for background2: Alpha 0 -> 1 var fadeInDuration = 500; // 500ms fade-in duration var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { background2.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); // Remove overlay after fade-in is complete if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; // Fade effect complete, ensure it doesn't repeat // Add scrolling and mirror effect to background2 createScrollingBackground2(); } }, fadeInStepTime); } }, stepTime); } // Modify the game.update function to ensure our rotated tube is updated // Add this code to the game.update function, anywhere before the end game.update = function() { // Keep all existing code... // Near the end of the function, add this check for the rotated tube if (game.rotatedTube && game.rotatedTube.update) { game.rotatedTube.update(); } // Rest of the existing code... };
User prompt
/**** * Assets ****/ LK.init.shape('overlay', {width:2048, height:2732, color:0x000000, shape:'box'}) LK.init.image('background', {width:2048, height:2732.07, id:'6758971de1c6df8afc3f801b'}) LK.init.image('background2', {width:2048, height:2850, id:'67d87d2ced4e4720c972d0f7'}) LK.init.image('coin', {width:150, height:150, id:'67d58381540f369ec40716a5'}) LK.init.image('control', {width:300, height:10, id:'67d757ae885017473a98979d'}) LK.init.image('counter_background', {width:135, height:135, id:'67d757ae885017473a98979c'}) LK.init.image('enemy', {width:150, height:150, id:'67589498e1c6df8afc3f7fdf', flipX:1}) LK.init.image('flyin_enemy', {width:150, height:165, id:'67d6cc20228891638f6d62af', flipX:1}) LK.init.image('heart', {width:100, height:100, id:'67d966dd24ccde20f6adb0eb'}) LK.init.image('particle', {width:100, height:100, id:'67d62caff0905a2251a97ad1'}) LK.init.image('player', {width:150, height:150, id:'67589443e1c6df8afc3f7fd5'}) LK.init.image('tup_1', {width:250, height:375, id:'67d76073885017473a989801'}) LK.init.image('weapon', {width:120, height:120, id:'67d579ab540f369ec4071660'}) /**** * Classes ****/ // Coin sınıfı 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 () { self.x -= self.velocity; }; }); // Düşman sınıfı 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; // Enemy ilk başta oyuncuya zarar verebilir self.update = function () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); // Uçan düşman sınıfı 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; // FlyinEnemy de oyuncuya zarar verebilir self.update = function () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); // Oyuncu sınıfı 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.zIndex = 20; self.hearts = 3; // Add hearts to the player self.update = function () { // Önce mevcut y değeri korunuyor (collision kontrolü için önceki frame değeri) self.prevY = self.y; if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.7; // Yerçekimi if (self.y >= 2732 / 2 - 3) { self.y = 2732 / 2 - 9; self.isJumping = false; self.velocityY = 0; } } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.velocityY = -self.jumpHeight; } }; self.loseHeart = function () { self.hearts--; playerDeaths++; // Increment player death count // Destroy hearts based on the number of player deaths 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(); } if (self.hearts <= 0) { self.destroy(); } }; }); // Arka plan sınıfı 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; } }; }); var ScrollingBackground2 = Container.expand(function () { var self = Container.call(this); // First background2 piece (normal) var bg1 = LK.getAsset('background2', { anchorX: 0, anchorY: 0 }); bg1.x = 0; bg1.y = 0; self.addChild(bg1); // Second background2 piece (mirror) 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; } }; }); // Tüp sınıfı 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(); } }; }); // Silah sınıfı 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 // Set backgroundColor to black }); /**** * Game Code ****/ // Global flag to prevent multiple fade effects game.isFading = false; game.fadeCompleted = false; // Ensure fade effect runs only once var flashActive = false; // Global flag to control flash effect activation /**** * Fade Effect Function (Without Tween plugin) * This function darkens the screen using the overlay asset over 0.5 seconds, then restores it over another 0.5 seconds. ****/ function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { return; // Prevent multiple fade effects and ensure single run } 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; // 500ms fade out/in duration var stepTime = duration / steps; var currentStep = 0; // Fade-Out: Alpha 0 -> 1 var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); currentStep = 0; // Fade-out complete: add center background with alpha 0 var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); background2.x = 2048 / 2; background2.y = 2732 / 2; background2.width = 2048; background2.height = 2732; background2.alpha = 0; if (!background2.parent) { LK.stage.addChild(background2); } // Add tube asset rotated 180 degrees to the center top var tube = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); tube.x = 2048 / 2; tube.y = 100; // Position at the top center tube.rotation = Math.PI; // Rotate 180 degrees tube.speed = 5; // Set speed to match enemy's velocity tube.update = function () { tube.x -= tube.speed; if (tube.x + tube.width < 0) { tube.destroy(); } }; if (!tube.parent) { LK.stage.addChild(tube); } // Fade-In for background2: Alpha 0 -> 1 var fadeInDuration = 500; // 500ms fade-in duration var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { background2.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); // Remove overlay after fade-in is complete if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; // Fade effect complete, ensure it doesn't repeat // Add scrolling and mirror effect to background2 createScrollingBackground2(); } }, fadeInStepTime); } }, stepTime); } /**** * Global Variables ****/ var coinCounter = 0; var flyinEnemies = []; var playerDeaths = 0; // Track the number of times the player has died var hearts = []; // Store heart assets for easy access game.controlActive = false; // Flag to ensure fade effect only triggers after control interaction var coins = []; var enemies = []; var enemySpawnInterval = Math.floor(Math.random() * 100) + 30; var enemySpawnCounter = 0; var clearTriggered = false; var stopSpawn = false; // 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); // Kontrol asset'ini tüpün child'ı olarak ekleyin. var control = LK.getAsset('control', { anchorX: 0.5, anchorY: 0.5 }); // Kontrolün tüp içindeki konumu, tüpün üst kenarına denk gelecek şekilde ayarlanıyor. control.x = 0; // Tüpün merkezine göre control.y = -177.5; // Tüp yüksekliğinin yarısı kadar yukarı tube.addChild(control); // Activate control if score is 1 or greater control.update = function () { if (coinCounter >= 1 && player.intersects(control)) { // Set controlActive flag game.controlActive = true; // Freeze game for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } // Character disappears after 0.33 seconds (330ms) LK.setTimeout(function () { player.destroy(); }, 330); // Call the enhanced fade effect enhancedFadeEffect(); } }; 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 - 7; /* Skor GUI */ var counterBackground = LK.getAsset('counter_background', { anchorX: 0.5, anchorY: 0.5 }); LK.gui.top.addChild(counterBackground); counterBackground.x = LK.gui.top.width / 2 - 60; counterBackground.y = 40; var scoreText = new Text2('0', { size: 80, fill: 0xFFFFFF }); LK.gui.top.addChild(scoreText); scoreText.x = LK.gui.top.width / 2 - 83; scoreText.y = 0; // Add three heart assets to the top-left corner 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 + 380; // Move hearts 100 pixels to the left from previous position heart.y = 55; // Move hearts 5 pixels up from previous position hearts.push(heart); // Store heart in the array } /* Uçan düşmanları oluştur */ function spawnFlyinEnemy() { var delay = Math.random() * 2000 + 2000; if (!stopSpawn) { LK.setTimeout(function () { if (stopSpawn) { return; } var flyinEnemy = new FlyinEnemy(); flyinEnemy.x = 2048; flyinEnemy.y = 449; flyinEnemy.zIndex = 10; game.addChild(flyinEnemy); flyinEnemies.push(flyinEnemy); spawnFlyinEnemy(); }, delay); } } spawnFlyinEnemy(); /* Oyun döngüsü */ game.update = function () { // Arka plan ve oyuncu güncellemesi scrollingBackground.update(); player.update(); // Update scrolling background2 if it exists if (game.scrollingBg2 && game.scrollingBg2.update) { game.scrollingBg2.update(); } // Tube güncellemesi ve z-index sıralaması for (var t = 0; t < game.children.length; t++) { var child = game.children[t]; if (child instanceof Tube) { child.update(); // Removed sorting from inside the loop } // Check for control activation if (child.children) { for (var c = 0; c < child.children.length; c++) { var subChild = child.children[c]; if (subChild.update) { subChild.update(); } } } } // Düşman spawn işlemleri enemySpawnCounter++; if (!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; } // Sort game children by zIndex once per frame after all updates game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); // Normal düşman güncelleme & çarpışma kontrolü for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (player.intersects(enemies[j]) && enemies[j].canDamage) { enemies[j].canDamage = false; // Bu enemy artık oyuncuya zarar veremez LK.effects.flashScreen(0xff0000, 750, 0.0001); // 750ms süren kırmızı flash 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; particleEffect.y = enemies[j].y; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); enemies[j].destroy(); child.destroy(); enemies.splice(j, 1); break; } } } // Uçan düşman güncelleme & çarpışma kontrolü for (var n = flyinEnemies.length - 1; n >= 0; n--) { flyinEnemies[n].update(); if (player.intersects(flyinEnemies[n]) && flyinEnemies[n].canDamage) { flyinEnemies[n].canDamage = false; LK.effects.flashScreen(0xff0000, 750, 0.0001); // 750ms süren kırmızı flash 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])) { var coin = new Coin(); coin.x = flyinEnemies[n].x + 60; coin.y = flyinEnemies[n].y + 130; 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 + 60; particleEffect.y = flyinEnemies[n].y + 130; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); flyinEnemies[n].destroy(); child.destroy(); flyinEnemies.splice(n, 1); break; } } if (flyinEnemies[n] && flyinEnemies[n].x < -50) { flyinEnemies[n].destroy(); flyinEnemies.splice(n, 1); } } // Coin güncelleme & çarpışma kontrolü 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); } } // --- Yeni Özellik --- // Eğer coinCounter 1'den fazla ise ve oyuncunun alt kenarı tüpün üst kenarıyla neredeyse hizalanıyorsa, // (player.y + 75) tüpün üst kenarı (tube.y - 187.5) ile arası 20 piksel veya daha azsa, // ve oyuncu ile tüp yatayda iyi hizalı (mesafe < 115) ise tetiklenecek. if (coinCounter > 1 && !clearTriggered) { for (var t = 0; t < game.children.length; t++) { var tube = game.children[t]; if (tube instanceof Tube) { var tubeTop = tube.y - 187.5; var playerBottom = player.y + 75; var horizontalDistance = Math.abs(player.x - tube.x); if (playerBottom >= tubeTop && playerBottom <= tubeTop + 20 && horizontalDistance < 115) { clearTriggered = true; stopSpawn = true; // Tüm oyun objelerini dondur 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(); }, 400); break; } } } } }; // Dokunma/Mouse event: jump + weapon game.down = function (x, y, obj) { if (player.isJumping) { 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(); }; LK.stage.addChild(game); function createScrollingBackground2() { var scrollingBg2 = new ScrollingBackground2(); LK.stage.addChild(scrollingBg2); game.scrollingBg2 = scrollingBg2; }
User prompt
move character 30 pixel left
User prompt
move character 100 pixel right
User prompt
move character 100 pixel right
User prompt
destroy the heart on the most left when character dies for the first time destroy the heart in the middle if character dies for 2. time if character dies for 3. time destroy the last heart
User prompt
move hearts 100 pixel left 5 pixel up
User prompt
move hearts 400 pixel right
User prompt
move hearts 600 pixel right
User prompt
move hearts 10 pixel down 30 pixel right
User prompt
move hearts 50 pixel right
User prompt
move hearts 100 pixel left
User prompt
move hearts 300 pixel left
User prompt
move heart 400 pixel left
User prompt
move hearts 400 pixel left
User prompt
move hearts 1200 pixel right
User prompt
move hearts to 600 pixel left
User prompt
heart asseti sol üste ve onun yanında bir tane yanındakinin yanına bir tane daha heart koy yani 3 tane hear yan yana sol üstte dursun
/**** * Classes ****/ // Coin sınıfı 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 () { self.x -= self.velocity; }; }); // Düşman sınıfı 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; // Enemy ilk başta oyuncuya zarar verebilir self.update = function () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); // Uçan düşman sınıfı 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; // FlyinEnemy de oyuncuya zarar verebilir self.update = function () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); // Oyuncu sınıfı 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.zIndex = 20; self.hearts = 3; // Add hearts to the player self.update = function () { // Önce mevcut y değeri korunuyor (collision kontrolü için önceki frame değeri) self.prevY = self.y; if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.7; // Yerçekimi if (self.y >= 2732 / 2 - 3) { self.y = 2732 / 2 - 9; self.isJumping = false; self.velocityY = 0; } } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.velocityY = -self.jumpHeight; } }; self.loseHeart = function () { self.hearts--; if (self.hearts <= 0) { self.destroy(); } }; }); // Arka plan sınıfı 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; } }; }); var ScrollingBackground2 = Container.expand(function () { var self = Container.call(this); // First background2 piece (normal) var bg1 = LK.getAsset('background2', { anchorX: 0, anchorY: 0 }); bg1.x = 0; bg1.y = 0; self.addChild(bg1); // Second background2 piece (mirror) 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; } }; }); // Tüp sınıfı 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(); } }; }); // Silah sınıfı 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 // Set backgroundColor to black }); /**** * Game Code ****/ // Global flag to prevent multiple fade effects game.isFading = false; game.fadeCompleted = false; // Ensure fade effect runs only once var flashActive = false; // Global flag to control flash effect activation /**** * Fade Effect Function (Without Tween plugin) * This function darkens the screen using the overlay asset over 0.5 seconds, then restores it over another 0.5 seconds. ****/ function enhancedFadeEffect() { if (game.isFading || game.fadeCompleted || !game.controlActive) { return; // Prevent multiple fade effects and ensure single run } 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; // 500ms fade out/in duration var stepTime = duration / steps; var currentStep = 0; // Fade-Out: Alpha 0 -> 1 var fadeOutInterval = LK.setInterval(function () { if (currentStep < steps) { overlay.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeOutInterval); currentStep = 0; // Fade-out complete: add center background with alpha 0 var background2 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5 }); background2.x = 2048 / 2; background2.y = 2732 / 2; background2.width = 2048; background2.height = 2732; background2.alpha = 0; if (!background2.parent) { LK.stage.addChild(background2); } // Add tube asset rotated 180 degrees to the center top var tube = LK.getAsset('tup_1', { anchorX: 0.5, anchorY: 0.5 }); tube.x = 2048 / 2; tube.y = 100; // Position at the top center tube.rotation = Math.PI; // Rotate 180 degrees tube.speed = 5; // Set speed to match enemy's velocity tube.update = function () { tube.x -= tube.speed; if (tube.x + tube.width < 0) { tube.destroy(); } }; if (!tube.parent) { LK.stage.addChild(tube); } // Fade-In for background2: Alpha 0 -> 1 var fadeInDuration = 500; // 500ms fade-in duration var fadeInStepTime = fadeInDuration / steps; var fadeInInterval = LK.setInterval(function () { if (currentStep < steps) { background2.alpha = currentStep / steps; currentStep++; } else { LK.clearInterval(fadeInInterval); // Remove overlay after fade-in is complete if (overlay.parent) { overlay.parent.removeChild(overlay); } game.isFading = false; game.fadeCompleted = true; // Fade effect complete, ensure it doesn't repeat // Add scrolling and mirror effect to background2 createScrollingBackground2(); } }, fadeInStepTime); } }, stepTime); } /**** * Global Variables ****/ var coinCounter = 0; var flyinEnemies = []; game.controlActive = false; // Flag to ensure fade effect only triggers after control interaction var coins = []; var enemies = []; var enemySpawnInterval = Math.floor(Math.random() * 100) + 30; var enemySpawnCounter = 0; var clearTriggered = false; var stopSpawn = false; // 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); // Kontrol asset'ini tüpün child'ı olarak ekleyin. var control = LK.getAsset('control', { anchorX: 0.5, anchorY: 0.5 }); // Kontrolün tüp içindeki konumu, tüpün üst kenarına denk gelecek şekilde ayarlanıyor. control.x = 0; // Tüpün merkezine göre control.y = -177.5; // Tüp yüksekliğinin yarısı kadar yukarı tube.addChild(control); // Activate control if score is 1 or greater control.update = function () { if (coinCounter >= 1 && player.intersects(control)) { // Set controlActive flag game.controlActive = true; // Freeze game for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } // Character disappears after 0.33 seconds (330ms) LK.setTimeout(function () { player.destroy(); }, 330); // Call the enhanced fade effect enhancedFadeEffect(); } }; 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 - 200; player.y = 2732 / 2 - 7; /* Skor GUI */ var counterBackground = LK.getAsset('counter_background', { anchorX: 0.5, anchorY: 0.5 }); LK.gui.top.addChild(counterBackground); counterBackground.x = LK.gui.top.width / 2 - 60; counterBackground.y = 40; var scoreText = new Text2('0', { size: 80, fill: 0xFFFFFF }); LK.gui.top.addChild(scoreText); scoreText.x = LK.gui.top.width / 2 - 83; scoreText.y = 0; // Add three heart assets to the top-left corner 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 - 550; // Move hearts 50 pixels to the right heart.y = 50; } /* Uçan düşmanları oluştur */ function spawnFlyinEnemy() { var delay = Math.random() * 2000 + 2000; if (!stopSpawn) { LK.setTimeout(function () { if (stopSpawn) { return; } var flyinEnemy = new FlyinEnemy(); flyinEnemy.x = 2048; flyinEnemy.y = 449; flyinEnemy.zIndex = 10; game.addChild(flyinEnemy); flyinEnemies.push(flyinEnemy); spawnFlyinEnemy(); }, delay); } } spawnFlyinEnemy(); /* Oyun döngüsü */ game.update = function () { // Arka plan ve oyuncu güncellemesi scrollingBackground.update(); player.update(); // Update scrolling background2 if it exists if (game.scrollingBg2 && game.scrollingBg2.update) { game.scrollingBg2.update(); } // Tube güncellemesi ve z-index sıralaması for (var t = 0; t < game.children.length; t++) { var child = game.children[t]; if (child instanceof Tube) { child.update(); // Removed sorting from inside the loop } // Check for control activation if (child.children) { for (var c = 0; c < child.children.length; c++) { var subChild = child.children[c]; if (subChild.update) { subChild.update(); } } } } // Düşman spawn işlemleri enemySpawnCounter++; if (!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; } // Sort game children by zIndex once per frame after all updates game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); // Normal düşman güncelleme & çarpışma kontrolü for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (player.intersects(enemies[j]) && enemies[j].canDamage) { enemies[j].canDamage = false; // Bu enemy artık oyuncuya zarar veremez LK.effects.flashScreen(0xff0000, 750, 0.0001); // 750ms süren kırmızı flash 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; particleEffect.y = enemies[j].y; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); enemies[j].destroy(); child.destroy(); enemies.splice(j, 1); break; } } } // Uçan düşman güncelleme & çarpışma kontrolü for (var n = flyinEnemies.length - 1; n >= 0; n--) { flyinEnemies[n].update(); if (player.intersects(flyinEnemies[n]) && flyinEnemies[n].canDamage) { flyinEnemies[n].canDamage = false; LK.effects.flashScreen(0xff0000, 750, 0.0001); // 750ms süren kırmızı flash 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])) { var coin = new Coin(); coin.x = flyinEnemies[n].x + 60; coin.y = flyinEnemies[n].y + 130; 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 + 60; particleEffect.y = flyinEnemies[n].y + 130; game.addChild(particleEffect); LK.setTimeout(function () { particleEffect.destroy(); }, 150); flyinEnemies[n].destroy(); child.destroy(); flyinEnemies.splice(n, 1); break; } } if (flyinEnemies[n] && flyinEnemies[n].x < -50) { flyinEnemies[n].destroy(); flyinEnemies.splice(n, 1); } } // Coin güncelleme & çarpışma kontrolü 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); } } // --- Yeni Özellik --- // Eğer coinCounter 1'den fazla ise ve oyuncunun alt kenarı tüpün üst kenarıyla neredeyse hizalanıyorsa, // (player.y + 75) tüpün üst kenarı (tube.y - 187.5) ile arası 20 piksel veya daha azsa, // ve oyuncu ile tüp yatayda iyi hizalı (mesafe < 115) ise tetiklenecek. if (coinCounter > 1 && !clearTriggered) { for (var t = 0; t < game.children.length; t++) { var tube = game.children[t]; if (tube instanceof Tube) { var tubeTop = tube.y - 187.5; var playerBottom = player.y + 75; var horizontalDistance = Math.abs(player.x - tube.x); if (playerBottom >= tubeTop && playerBottom <= tubeTop + 20 && horizontalDistance < 115) { clearTriggered = true; stopSpawn = true; // Tüm oyun objelerini dondur 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(); }, 400); break; } } } } }; // Dokunma/Mouse event: jump + weapon game.down = function (x, y, obj) { if (player.isJumping) { 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(); }; LK.stage.addChild(game); function createScrollingBackground2() { var scrollingBg2 = new ScrollingBackground2(); LK.stage.addChild(scrollingBg2); game.scrollingBg2 = scrollingBg2; }
===================================================================
--- original.js
+++ change.js
@@ -362,9 +362,9 @@
anchorX: 0.5,
anchorY: 0.5
});
LK.gui.top.addChild(heart);
- heart.x = 50 + i * 110 - 600; // Move hearts 100 pixels to the left
+ heart.x = 50 + i * 110 - 550; // Move hearts 50 pixels to the right
heart.y = 50;
}
/* Uçan düşmanları oluştur */
function spawnFlyinEnemy() {
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