User prompt
game.controlActive’in Doğru Ayarlanması: Control asset tetiklendiğinde game.controlActive’in gerçekten true olduğundan emin olun. Eğer bu bayrak hiç aktif hale gelmiyorsa, bonus kodu çalışmaz. Çarpışma (intersects) Kontrolü: Oyuncunun yesil_1 ile gerçekten temas ettiğinden emin olun. Konum, boyut ve anchor ayarlarını kontrol edin. Eğer yesil_1 veya oyuncunun pozisyonu beklenen şekilde güncellenmiyorsa, intersects fonksiyonu false dönebilir. Update Fonksiyonlarının Çalışması: yesil_1’in update fonksiyonunun her frame çağrıldığından emin olun. Bazen başka bir kod parçası update fonksiyonlarını değiştirebilir veya sıfırlayabilir. Log Mesajlarını Kontrol Edin: Kodunuzdaki console.log ifadeleri, bonusların ne zaman uygulandığını görmek için yardımcı olur. Tarayıcı konsolunda "Control bonus applied", "Touch bonus applied" ve "Freeze game triggered" mesajlarının çıktısını kontrol edin. Bonus Bayrakları (controlBonusApplied ve touchBonusApplied): Bu bayrakların doğru şekilde sıfırlandığından veya hiç yanlışlıkla erken true’a set edilmediğinden emin olun. Örneğin, bonus uygulandıktan sonra bayrağın true olması isteniyor, fakat eğer başka bir yerde bayraklar resetleniyorsa sorun yaşanabilir. Özetle, mantıksal olarak kodunuz isteneni yapacak şekilde düzenlenmiş görünüyor. Sorun çalışmıyorsa, muhtemelen yukarıdaki alanlardan biri (game.controlActive’in doğru tetiklenmemesi, intersects kontrolü, ya da update fonksiyonlarının çakışması) devreye giriyor. Adım adım bu noktaları debug edip, log mesajlarıyla kontrol etmeniz sorunu çözmenize yardımcı olacaktır. Eğer kontrol bayrağı (game.controlActive) beklenen şekilde aktif hale gelmiyorsa, control assetinin update fonksiyonundaki koşulların doğru tetiklendiğinden emin olun. Aynı şekilde, oyuncu yesil_1 ile gerçekten çarpışıyor mu, konumlar doğru mu, bunları gözden geçirmeniz faydalı olacaktır.
User prompt
create a heart middle of the screen when yesil_1 gain 1 point
User prompt
create heart middle of the screen when a score taken
User prompt
when yesil_1 gain point create a white flash on the screen
User prompt
Sorunlar ve Öneriler Tek Seferlik Bonus Uygulaması: Hem kontrol bonusu hem de dokunma bonusu için bir seferlik tetikleme bayrağı kullanmanız doğru. Fakat, bonusları verirken hem konsolda (log) hem de güncelleme fonksiyonunda koşulların çalışıp çalışmadığını kontrol etmek iyi olur. Örneğin, kontrol bonusu verildikten sonra game.controlActive’in hemen false’a çekilmesi, bonusun sürekli verilmemesini sağlar. Çarpışma Koşulunun Doğru Çalışması: Kodunuzda if (player.intersects(yesil1) && yesil1.points >= 2 && !yesil1.touchBonusApplied) koşuluyla dokunma bonusu veriyorsunuz. Eğer oyuncu nesnesi veya yesil_1’in konumları beklenen şekilde güncellenmiyorsa, çarpışma gerçekleşmeyebilir. Bu durumda konumların doğru olduğundan ve intersects fonksiyonunun doğru çalıştığından emin olun. Freeze (Oyun Dondurma) Mantığı: Yesil_1 puan değeri 3 veya daha yüksek olduğunda tüm game.children’in update fonksiyonlarını boş bir fonksiyon ile değiştirerek oyunu dondurmayı hedefliyorsunuz. Ancak, dondurma koşulunun doğru tetiklenip tetiklenmediğini görmek için ek log mesajları ekleyebilirsiniz. Debug Log’lar Ekleyin: Hangi aşamada koşulların tetiklendiğini görmek için bonus uygulama ve freeze koşullarına console.log ifadeleri eklemek, sorunun neden gerçekleşmediğini anlamanıza yardımcı olur. Düzeltilmiş Yesil_1 Güncelleme Fonksiyonu Aşağıda, yukarıdaki noktalara göre düzenlenmiş örnek bir yesil1.update fonksiyonu bulabilirsiniz: js Kopyala Düzenle yesil1.update = function () { // Yesil_1’i sola doğru hareket ettir yesil1.x -= yesil1.speed; if (yesil1.x < -yesil1.width) { yesil1.destroy(); return; } // Kontrol bonusu: Eğer game.controlActive aktifse ve henüz uygulanmadıysa if (game.controlActive && !yesil1.controlBonusApplied) { game.controlActive = false; // Kontrolü hemen pasif yap yesil1.controlBonusApplied = true; // Bonusun verildiğini işaretle yesil1.points += 1; // 1 puan ekle if (coinCounter >= 30) { yesil1.points += 1; // Ekstra puan ekle } console.log("Control bonus applied. Yesil1 points: " + yesil1.points); } // Dokunma bonusu: Oyuncu yesil1 ile temas ederse ve puan 2 veya üzeriyse if (player.intersects(yesil1)) { if (yesil1.points >= 2 && !yesil1.touchBonusApplied) { yesil1.touchBonusApplied = true; yesil1.points += 1; console.log("Touch bonus applied. Yesil1 points: " + yesil1.points); } } // Eğer yesil1 puanı 3 veya üzerindeyse, oyunu dondur if (yesil1.points >= 3) { console.log("Freeze game triggered because yesil1 points reached: " + yesil1.points); // Tüm game.children’in update fonksiyonlarını boş fonksiyon yaparak oyunu dondur for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } } }; Ek Tavsiyeler Konum ve Ölçek Ayarlarını Gözden Geçirin: Hem oyuncu hem de yesil_1’in konumları, boyutları ve anchor ayarlarının doğru olduğundan emin olun. Böylece intersects kontrolü doğru çalışır. Debug Loglarını İzleyin: Tarayıcı konsolunda log mesajlarına bakarak hangi bonusların verildiğini ve freeze koşulunun tetiklenip tetiklenmediğini takip edin. Test Senaryoları: Kontrol bonusunun verilip verilmeyeceğini (örneğin, coinCounter değeri 10’dan büyük olduğunda) kontrol edin. Oyuncunun yesil_1 ile temas ettiği anda bonusun uygulanıp uygulanmadığını test edin. Bu düzenlemelerle bonus uygulama ve oyun dondurma mantığının doğru çalışması gerekir. Kodunuzda diğer bölümlerin de doğru çalıştığından emin olun; özellikle kontrol nesnesi (control) ile game.controlActive bayrağının ayarlanma anına dikkat edin. Umarım yardımcı olur!
User prompt
Sorunun kaynağı, yesil_1’in update fonksiyonunda puan artırma mantığının her frame’de (yani sürekli) tetiklenmesinden kaynaklanıyor. Şu durumlar göz önünde bulundurulmalı: game.controlActive kontrolü: js Kopyala Düzenle if (game.controlActive) { game.controlActive = false; yesil1.points += 1; if (coinCounter >= 30) { yesil1.points += 1; } } Burada game.controlActive true olduğunda yesil_1’e 1 (ve gerekiyorsa ekstra 1) puan veriliyor. Ancak update fonksiyonu sürekli çalıştığından, game.controlActive başka bir yerde (örneğin dokunma/çarpışma sonucu) true yapıldıysa, bir sonraki frame’de yine bu kontrol tetiklenebilir. Yani, bonus puan yalnızca bir kerelik verilmek isteniyorsa, bu durum için bir “alreadyAwarded” (örneğin, controlBonusApplied) bayrağı ekleyip, bonus verildikten sonra bu bayrağı true yaparak kontrolü sağlamak gerekir. Oyuncu ile temas kontrolü: js Kopyala Düzenle if (player.intersects(yesil1) && yesil1.points >= 2) { yesil1.points += 1; } Bu koşul da oyuncu yesil_1 ile temas ettiği sürece her frame tetiklenip puan artışı sağlayabilir. Eğer oyuncu yesil_1’e dokunduğunda sadece tek seferlik bir bonus verilmek isteniyorsa, bu durumu da bir bayrakla kontrol etmek gerekiyor. Oyunun dondurulması: Son olarak, yesil_1.points değeri 3’e ulaştığında tüm game.children’in update fonksiyonu boş fonksiyona çevriliyor. Bu kısım mantıksal olarak doğru çalışsa da, yukarıdaki puan artışlarının gereğinden fazla tetiklenmesi sonucu beklenenden erken dondurma meydana gelebilir. Önerilen Düzeltme Adımları: Bonus Puanlar için Bayraklar Ekleyin: Örneğin, yesil_1 nesnesine controlBonusApplied ve touchBonusApplied adında iki bayrak ekleyin. Böylece: game.controlActive kontrolü gerçekleştiğinde, eğer yesil1.controlBonusApplied false ise bonus puanı verip bayrağı true yapın. Benzer şekilde, oyuncunun dokunuşuyla bonus verilirken touchBonusApplied bayrağı kullanılabilir. Örnek: js Kopyala Düzenle // yesil1 oluşturulurken yesil1.points = 0; yesil1.controlBonusApplied = false; yesil1.touchBonusApplied = false; yesil1.update = function () { yesil1.x -= yesil1.speed; if (yesil1.x < -yesil1.width) { yesil1.destroy(); } if (game.controlActive && !yesil1.controlBonusApplied) { yesil1.controlBonusApplied = true; // Sadece bir kerelik bonus yesil1.points += 1; if (coinCounter >= 30) { yesil1.points += 1; } } if (player.intersects(yesil1) && yesil1.points >= 2 && !yesil1.touchBonusApplied) { yesil1.touchBonusApplied = true; // Sadece bir kerelik bonus yesil1.points += 1; } if (yesil1.points >= 3) { // Freeze the game and stop every asset for (var i = 0; i < game.children.length; i++) { var obj = game.children[i]; if (obj.update) { obj.update = function () {}; } } } }; Kontrollerin Tekrarlanmasını Engelleyin: Yukarıdaki bayraklar, puanların her frame artmasını engelleyerek istenilen davranışı sağlayacaktır. game.controlActive’in Doğru Yönetimi: Kontrol nesnesinin update fonksiyonunda game.controlActive true yapıldığında, bonus verildikten sonra kontrolün resetlenmesi (örneğin sadece bir kez tetiklenmesi) önemlidir. Bu yüzden, kontrol nesnesi de update fonksiyonunda sadece bir kere game.controlActive’i aktif hale getirmeli. Bu değişikliklerle, bonus puanlar yalnızca istenilen bir kerelik tetiklenecek ve yesil_1 puanı doğru şekilde artacaktır. Ardından yesil_1 puanı 3’e ulaştığında oyun dondurulacaktır. Böylece mantıksal akış sağlanmış olur. Umarım yardımcı olmuştur!
User prompt
if control activated then turns into inactivated give yesil_1 1 point and if score is equal or greater than 30 give yesil_1 1 more point and if yesil_1 has touched by character after 2 points give yesil_1 1 more point and if yesil_1 has 3 points freeze the game stop every asset
User prompt
make yesil_1 functional when control become uselles and score greater than 30 make yesil_1 active and if character touches activated yesil make everythings velocity 0 nothing can move
User prompt
make control inactive after 1 use make it useless after 1 use
User prompt
make yesil_1 touchable when score is greater than 30 and if character touches it make a second fade in fade out same as the first as the one fade afect now used in the code
User prompt
make yesil_1 touchable when score is greater than 30 and if character touches it make a second fade in fade out same as the first ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Move yesil_1 spawn point 20 pixels down
User prompt
Move yesil_1 spawn point 40 pixels down
User prompt
Move yesil_1 190 pixels up
User prompt
move yesil_1 spawn point 90 pixels up
User prompt
move yesil_1 spawn point 130 pixels up
User prompt
move yesil_1 spawn point 100 pixels up
User prompt
move yesil_1 spawn point 90 pixels up
User prompt
move yesil_1 spawn point 60 pixel up
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in or related to this line: 'control_2.x = yesil1.x; // Move to the location of yesil_1' Line Number: 740
User prompt
Please fix the bug: 'Timeout.tick error: yesil1 is not defined' in or related to this line: 'control_2.x = yesil1.x; // Move to the location of yesil_1' Line Number: 739
User prompt
move control_2 to location where yesil_1
User prompt
make yesil_1 move faster
User prompt
make yesil go right to left as well
User prompt
spawn yesil_1 at the same position of the tube_1
/**** * 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 () { 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.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 - 130; yesil1.speed = 10; yesil1.update = function () { yesil1.x -= yesil1.speed; if (yesil1.x < -yesil1.width) { yesil1.destroy(); } }; 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) { console.log("Control event triggered: coinCounter = " + coinCounter); startNormalEnemy = false; game.controlActive = true; 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; 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
@@ -592,9 +592,9 @@
anchorX: 0.5,
anchorY: 0.5
});
yesil1.x = tube.x;
- yesil1.y = tube.y - 100;
+ yesil1.y = tube.y - 130;
yesil1.speed = 10;
yesil1.update = function () {
yesil1.x -= yesil1.speed;
if (yesil1.x < -yesil1.width) {
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