User prompt
en küçük engeller 200 px olsun, daha büyük engeller de rastgele gelsin
User prompt
width 200px yap
User prompt
width 120px olsun height 70px
User prompt
120 px olsun
User prompt
70 px olsun
User prompt
20 px olsun
User prompt
engeller 5 px daha uzun ola bilir
User prompt
engeller bazen büyük bazen küçük rastgele olsun
User prompt
engelle çarptığında rokete bir çarpma animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
roket engelle çarptığında hemen yanmasın, yakıtından %10 kaybetsin
User prompt
best score komple kaldır
User prompt
game over olduğunda best score ekranda yazsın
User prompt
best score hala düzgün çalışmiyor hep 0
User prompt
best score hep 0 m gösteriyor
User prompt
best score ekranda kalmasını sağla
User prompt
engeller ve yakıtlar, ekranın ortasından belirmeye başlıyorlar, ekranın en üstünden yukarısdan gözüksünler
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'height')' in or related to this line: 'bestTxt.y = distanceTxt.height + fuelTxt.height + 30;' Line Number: 114
User prompt
best scrore ekranda kalmıyor, birde oyun yazıları ingizce olacak
User prompt
yakıt %20 artsın
User prompt
yakıt %10 artsın
User prompt
NAN% çıkıyor ekranda bunu düzelt
User prompt
yakıt artışı %50 doldursun, her zaman tam doldurmasın
User prompt
şimdi her 200 metrede, roket hızlansın, ve yakıt göstergesi, metre göstergesininin altında yer alsın
User prompt
roket ilerlemesi lazım, roket şuan sabit kalıyor, arka plan sabit kalıyor, yanı roketin yukarıya ucarmış gibi bir animasyon eklenem gerekir
User prompt
arka plan aşağıya doğru kayması gerek
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { best: 0 }); /**** * Classes ****/ // Fuel class var Fuel = Container.expand(function () { var self = Container.call(this); var fuelGfx = self.attachAsset('fuel', { anchorX: 0.5, anchorY: 0.5 }); self.width = fuelGfx.width; self.height = fuelGfx.height; self.update = function () { // Movement handled in game.update }; return self; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obsGfx = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.width = obsGfx.width; self.height = obsGfx.height; self.update = function () { // Movement handled in game.update }; return self; }); // Rocket class var Rocket = Container.expand(function () { var self = Container.call(this); var rocketGfx = self.attachAsset('rocket', { anchorX: 0.5, anchorY: 0.5 }); self.width = rocketGfx.width; self.height = rocketGfx.height; self.fuel = 100; // percent self.alive = true; self.update = function () { // Nothing here, movement handled in game.update }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Explosion effect (for flash) // Obstacle // Fuel // Rocket (player) // --- Global variables --- var rocket; var fuels = []; var obstacles = []; var dragStartX = null; var dragRocketStartX = null; var isDragging = false; var fuelTimer = 0; var obstacleTimer = 0; var distance = 0; // var best = typeof storage.best === "number" && storage.best > 0 ? storage.best : 0; var fuelDepleteRate = 0.18; // per tick var rocketSpeed = 8; // px per tick (vertical) var fuelSpawnInterval = 90; // ticks var obstacleSpawnInterval = 110; // ticks var minX = 100, maxX = 2048 - 100; var minY = 200, maxY = 2732 - 200; var fuelMax = 100; var fuelAmount = fuelMax * 0.2; // Yakıt toplandığında %20 doldurur var gameStarted = false; // --- UI --- var distanceTxt = new Text2('0 m', { size: 90, fill: 0xFFFFFF }); distanceTxt.anchor.set(0.5, 0); LK.gui.top.addChild(distanceTxt); // Best score UI removed // Fuel bar (simple text) var fuelTxt = new Text2('Yakıt: 100%', { size: 60, fill: 0x44DDEE }); fuelTxt.anchor.set(0.5, 0); // Place fuelTxt below distanceTxt (metre göstergesinin altında) LK.gui.top.addChild(fuelTxt); fuelTxt.y = distanceTxt.height + 10; // (bestTxt positioning removed) // --- Helper functions --- function resetGame() { // Remove old objects if (rocket) rocket.destroy(); for (var i = 0; i < fuels.length; ++i) fuels[i].destroy(); for (var i = 0; i < obstacles.length; ++i) obstacles[i].destroy(); fuels = []; obstacles = []; // Reset variables distance = 0; fuelTimer = 0; obstacleTimer = 0; // (best score logic removed) // Create rocket rocket = new Rocket(); rocket.x = 2048 / 2; rocket.y = 2732 - 350; game.addChild(rocket); rocket.fuel = 100; rocket.alive = true; gameStarted = true; updateUI(); } function updateUI() { distanceTxt.setText(Math.floor(distance) + ' m'); fuelTxt.setText('Fuel: ' + Math.max(0, Math.floor(rocket ? rocket.fuel : 0)) + '%'); } // --- Input (drag to move rocket) --- game.down = function (x, y, obj) { if (!rocket || !rocket.alive) return; isDragging = true; dragStartX = x; dragRocketStartX = rocket.x; }; game.move = function (x, y, obj) { if (!rocket || !rocket.alive) return; if (isDragging) { var dx = x - dragStartX; rocket.x = Math.max(minX, Math.min(maxX, dragRocketStartX + dx)); } }; game.up = function (x, y, obj) { isDragging = false; }; // --- Main game loop --- game.update = function () { if (!rocket || !rocket.alive) return; // Move rocket up (rocket stays at same y, background moves down) // (Handled by moving all objects up, not down!) // Distance increases as if rocket is moving up distance += rocketSpeed / 6; // scale to meters // Speed up every 200 meters if (!rocket.lastSpeedupDistance) rocket.lastSpeedupDistance = 0; if (Math.floor(distance / 200) > Math.floor(rocket.lastSpeedupDistance / 200)) { rocketSpeed += 1.5; rocket.lastSpeedupDistance = distance; } updateUI(); // Deplete fuel rocket.fuel -= fuelDepleteRate; if (rocket.fuel <= 0) { rocket.fuel = 0; rocket.alive = false; LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); return; } // Move fuels and check collision for (var i = fuels.length - 1; i >= 0; --i) { var f = fuels[i]; f.y += rocketSpeed; // move up relative to rocket (background moves down) if (f.y > maxY + 200) { f.destroy(); fuels.splice(i, 1); continue; } if (rocket.intersects(f)) { rocket.fuel = Math.min(fuelMax, rocket.fuel + fuelAmount); f.destroy(); fuels.splice(i, 1); // Small flash effect LK.effects.flashObject(rocket, 0x44ddee, 300); updateUI(); } } // Move obstacles and check collision for (var i = obstacles.length - 1; i >= 0; --i) { var o = obstacles[i]; o.y += rocketSpeed; // move up relative to rocket (background moves down) if (o.y > maxY + 200) { o.destroy(); obstacles.splice(i, 1); continue; } if (rocket.intersects(o)) { // Only lose 10% fuel, don't die instantly var lostFuel = fuelMax * 0.10; rocket.fuel = Math.max(0, rocket.fuel - lostFuel); LK.effects.flashObject(rocket, 0xff4444, 400); // --- Rocket collision animation: shake horizontally --- // Stop any previous tweens on rocket.x tween.stop(rocket, { x: true }); var originalX = rocket.x; // Animate shake: left, right, center tween(rocket, { x: originalX - 40 }, { duration: 60, easing: tween.cubicOut, onFinish: function onFinish() { tween(rocket, { x: originalX + 40 }, { duration: 90, easing: tween.cubicInOut, onFinish: function onFinish() { tween(rocket, { x: originalX }, { duration: 70, easing: tween.cubicIn }); } }); } }); // --- End rocket collision animation --- obstacles.splice(i, 1); o.destroy(); updateUI(); // If fuel is now 0, trigger game over as normal if (rocket.fuel <= 0) { rocket.fuel = 0; rocket.alive = false; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } continue; } } // Spawn fuel fuelTimer++; if (fuelTimer >= fuelSpawnInterval) { fuelTimer = 0; var f = new Fuel(); f.x = Math.floor(minX + Math.random() * (maxX - minX)); // Spawn above the visible screen, so they fall into view from the top f.y = rocket.y - 2732 / 2 - 200 - Math.random() * 300; game.addChild(f); fuels.push(f); } // Spawn obstacle obstacleTimer++; if (obstacleTimer >= obstacleSpawnInterval) { obstacleTimer = 0; var o = new Obstacle(); o.x = Math.floor(minX + Math.random() * (maxX - minX)); // Spawn above the visible screen, so they fall into view from the top o.y = rocket.y - 2732 / 2 - 400 - Math.random() * 400; game.addChild(o); obstacles.push(o); } }; // --- Game over / win handling --- LK.on('gameover', function () { gameStarted = false; updateUI(); // (best score display removed) LK.setTimeout(function () { resetGame(); }, 1200); }); // --- Start game --- resetGame();
===================================================================
--- original.js
+++ change.js