User prompt
yumurta engellere çarpınca oyun sonlandmıyor
User prompt
önceki değişikliği de geri al
User prompt
son değişikliği geri al
User prompt
- Skor tablosu işlemlerinin başlaması için oyunun bitişinde (game over) bir event tetikle ve bu event içinde skor tablosu ile ilgili UI ve kayıt işlemleri başlat. - Gerekli değişkenler global scope’ta tanımla ve event içinde kullan. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
skor tablosu için gerekenler çıkmadı oyunun sonunda
User prompt
Please fix the bug: 'ReferenceError: storage is not defined' in or related to this line: 'var loaded = storage.get(storageKey);' Line Number: 259
User prompt
oyun bitiminde bir inputbox aç, başlığı isminiz: olsun, girilen isimle birlikte kazanılan puanı skor.txt adlı bir dosya oluştur ve o dosyaya kaydet. dosyada sadece en yüksek puanı alan 5 kişi yüksek puandan az puana doğru sıralanarak yer alsın (skor tablosu). oyun bitiminde en üst kısımda skor tablosunu göster.
User prompt
engeller her satırda %10 daha sık gelsin
User prompt
gelen engel kutucukları sarı, kırmızı, mavi, yeşil, mor, pembe, beyaz, turuncu renklerde olsun
User prompt
3 saniye havada kalırken mouse ile tıkladığım anda serbest kalsın
User prompt
oyun başlarken top 3 saniye havada kalsın
User prompt
hala yeşil renkte geliyorlar, farklı renkte kutucuklar olarak gelsinler
User prompt
engeller renkli olsun
User prompt
engeller hala yeşil renkteler, engellerin renkleri değşsin
User prompt
engelleri renkleri yeşil, her ekranda sürekli farklı reklere sahip olsunlar
User prompt
Please fix the bug: 'ReferenceError: row is not defined' in or related to this line: 'var baseSpeed = row.speedMin + Math.random() * (row.speedMax - row.speedMin);' Line Number: 114
User prompt
engeller 36 farklı renkte gelsin
User prompt
son değişikliği geri al
User prompt
Please fix the bug: 'ReferenceError: row is not defined' in or related to this line: 'var baseSpeed = row.speedMin + Math.random() * (row.speedMax - row.speedMin);' Line Number: 114
User prompt
gelen engellerin toplam renk çeşidi 36 olsun
User prompt
zıplayan topu beyaz ve yuvarlak yap
User prompt
oyunun hızını %40 artır
User prompt
zıplayan top yere düşünce oyun sona ersin
User prompt
engellerin geliş sıklığını %25 artır, hızlarını da %20 artır
User prompt
son değişikliği geri al
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Egg class: the player character var Egg = Container.expand(function () { var self = Container.call(this); var eggAsset = self.attachAsset('egg', { anchorX: 0.5, anchorY: 0.5 }); self.width = eggAsset.width; self.height = eggAsset.height; self.vy = 0; self.gravity = 2.2 * 1.4; self.jumpStrength = -38 * 1.4; self.isAlive = true; self.jump = function () { if (!self.isAlive) return; self.vy = self.jumpStrength; }; self.update = function () { if (!self.isAlive) return; // Prevent movement for 3 seconds at game start if (typeof eggStartFreeze !== "undefined" && eggStartFreeze) { self.vy = 0; return; } self.vy += self.gravity; self.y += self.vy; // Clamp to screen if (self.y < self.height / 2) { self.y = self.height / 2; self.vy = 0; } if (self.y > 2732 - self.height / 2) { self.y = 2732 - self.height / 2; self.vy = 0; if (self.isAlive) { self.die(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } }; self.die = function () { self.isAlive = false; }; return self; }); // Obstacle class: obstacles coming from the right, with 36 unique colors, speeds, and rows var Obstacle = Container.expand(function () { var self = Container.call(this); // 6 possible rows (Y positions) var rowYs = [400, 800, 1200, 1600, 2000, 2400]; // Speed ranges for each row (same as before, mapped to row index) var rowSpeeds = [{ speedMin: 16, speedMax: 22 }, // row 0 { speedMin: 12, speedMax: 18 }, // row 1 { speedMin: 8, speedMax: 14 }, // row 2 { speedMin: 14, speedMax: 20 }, // row 3 { speedMin: 10, speedMax: 16 }, // row 4 { speedMin: 18, speedMax: 24 } // row 5 ]; // Pick a random row for each obstacle var rowIdx = Math.floor(Math.random() * rowYs.length); var rowY = rowYs[rowIdx]; var speedRange = rowSpeeds[rowIdx]; // Each obstacle gets a random color from a fixed palette function randomColor() { // 8 specific colors: yellow, red, blue, green, purple, pink, white, orange var palette = [0xffff00, // yellow 0xff0000, // red 0x0000ff, // blue 0x00ff00, // green 0x800080, // purple 0xff69b4, // pink 0xffffff, // white 0xffa500 // orange ]; return palette[Math.floor(Math.random() * palette.length)]; } var obsColor = randomColor(); // Attach asset with selected color var obsAsset = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5, color: obsColor }); obsAsset.tint = obsColor; // Randomly choose obstacle length: 1x, 2x, 3x, or 4x var possibleLengths = [1, 2, 3, 4]; var lengthMultiplier = possibleLengths[Math.floor(Math.random() * possibleLengths.length)]; self.width = obsAsset.width * lengthMultiplier; self.height = obsAsset.height; // Speed based on row, increased by 5% per level, and increased by 20% overall var currentLevel = typeof level !== "undefined" ? level : 1; var baseSpeed = speedRange.speedMin + Math.random() * (speedRange.speedMax - speedRange.speedMin); self.speed = baseSpeed * 1.2 * 1.4 * Math.pow(1.05, currentLevel - 1); self.x = 2048 + self.width / 2; // Y position based on row, with a little random offset for variety self.y = rowY + (Math.random() - 0.5) * 80; self.update = function () { self.x -= self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // Sky blue }); /**** * Game Code ****/ // Import storage plugin so 'storage' is defined and available // --- Game Code --- // Create the egg and add to game var egg = new Egg(); egg.x = 400; egg.y = 2732 / 2; game.addChild(egg); // --- Egg start freeze logic --- var eggStartFreeze = true; var originalEggGravity = egg.gravity; egg.gravity = 0; egg.vy = 0; // Allow egg to fall after 3 seconds if not already released by user var eggFreezeTimeout = LK.setTimeout(function () { if (eggStartFreeze) { eggStartFreeze = false; egg.gravity = originalEggGravity; } }, 3000); // Obstacles array var obstacles = []; var obstacleTimer = 0; var obstacleInterval = Math.floor(90 / 1.4); // frames between obstacles, 40% faster // Score var score = 0; var level = 1; var scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var levelTxt = new Text2('Seviye: 1', { size: 80, fill: "#fff" }); levelTxt.anchor.set(0.5, 0); levelTxt.y = scoreTxt.height * 0.8; LK.gui.top.addChild(levelTxt); // Touch/mouse jump handler game.down = function (x, y, obj) { if (!egg.isAlive) return; if (typeof eggStartFreeze !== "undefined" && eggStartFreeze) { // Release egg from freeze immediately eggStartFreeze = false; egg.gravity = originalEggGravity; LK.clearTimeout(eggFreezeTimeout); return; } egg.jump(); }; // Main update loop game.update = function () { if (!egg.isAlive) return; // Spawn obstacles obstacleTimer++; if (obstacleTimer >= obstacleInterval) { // Spawn a single obstacle (random row, random length) var obs = new Obstacle(); obstacles.push(obs); game.addChild(obs); obstacleTimer = 0; // Determine row index for this obstacle (to adjust spawn interval) var rowIdx = 0; if (typeof obs !== "undefined" && typeof obs.y !== "undefined") { // Reconstruct row index from y position (since Obstacle uses rowYs) var rowYs = [400, 800, 1200, 1600, 2000, 2400]; var minDist = Math.abs(obs.y - rowYs[0]); rowIdx = 0; for (var ri = 1; ri < rowYs.length; ri++) { var dist = Math.abs(obs.y - rowYs[ri]); if (dist < minDist) { minDist = dist; rowIdx = ri; } } } // 10% more frequent per row (row 0: 1.0, row 1: 0.9, row 2: 0.8, ...) var rowFrequencyMultiplier = 1 - rowIdx * 0.1; if (rowFrequencyMultiplier < 0.1) rowFrequencyMultiplier = 0.1; // Clamp to avoid zero/negative // Randomize next interval a bit, 25% more frequent, then apply row multiplier var baseInterval = Math.floor((70 + Math.floor(Math.random() * 40)) * 0.75); obstacleInterval = Math.floor(baseInterval * rowFrequencyMultiplier); } // Update obstacles and check for collisions var _loop = function _loop() { obs = obstacles[i]; // Remove if off screen if (obs.x < -obs.width) { obs.destroy(); obstacles.splice(i, 1); return 0; // continue } // Collision detection if (egg.intersects(obs)) {} // Score: passed obstacle if (obs.lastX === undefined) obs.lastX = obs.x; if (obs.lastX >= egg.x && obs.x < egg.x) { // Each obstacle gives 1 * (2^(level-1)) points points = Math.pow(2, level - 1); score += points; scoreTxt.setText(score); // Level up every 10 obstacles (counted by total obstacles passed, not points) newLevel = 1 + Math.floor(score / Math.pow(2, level - 1) / 10); if (newLevel > level) { level = newLevel; levelTxt.setText('Seviye: ' + level); } } obs.lastX = obs.x; }, obs, points, newLevel, _ret; for (var i = obstacles.length - 1; i >= 0; i--) { _ret = _loop(); if (_ret === 0) continue; if (_ret) return _ret.v; } }; // --- High Score Table Logic (global scope) --- var inputBox, highScoreTxt, inputLabel, inputBg, inputConfirmBtn, inputName; var highScores = []; var storageKey = "egg_highscores"; // Show high score table and input box at game over LK.on('gameover', function () { // Load high scores from storage var loaded = storage.get(storageKey); if (loaded && Array.isArray(loaded)) { highScores = loaded; } else { highScores = []; } // Remove previous UI if exists if (inputBox) inputBox.destroy(); if (highScoreTxt) highScoreTxt.destroy(); if (inputLabel) inputLabel.destroy(); if (inputBg) inputBg.destroy(); if (inputConfirmBtn) inputConfirmBtn.destroy(); // Show high score table highScoreTxt = new Text2("Skor Tablosu\n" + highScores.map(function (s, i) { return i + 1 + ". " + s.name + ": " + s.score; }).join("\n"), { size: 90, fill: "#fff" }); highScoreTxt.anchor.set(0.5, 0); highScoreTxt.x = 2048 / 2; highScoreTxt.y = 600; game.addChild(highScoreTxt); // Show input for new high score if eligible var isHighScore = highScores.length < 5 || score > (highScores[highScores.length - 1] ? highScores[highScores.length - 1].score : 0); if (isHighScore && score > 0) { // Input background inputBg = LK.getAsset('obstacle', { anchorX: 0.5, anchorY: 0.5, color: 0x000000 }); inputBg.width = 800; inputBg.height = 300; inputBg.alpha = 0.7; inputBg.x = 2048 / 2; inputBg.y = 1500; game.addChild(inputBg); // Label inputLabel = new Text2("İsmini Gir:", { size: 80, fill: "#fff" }); inputLabel.anchor.set(0.5, 0.5); inputLabel.x = 2048 / 2; inputLabel.y = 1450; game.addChild(inputLabel); // Input box (Text2 as fake input) inputName = ""; inputBox = new Text2("_", { size: 100, fill: "#fff" }); inputBox.anchor.set(0.5, 0.5); inputBox.x = 2048 / 2; inputBox.y = 1550; game.addChild(inputBox); // Confirm button inputConfirmBtn = new Text2("Kaydet", { size: 80, fill: "#fff" }); inputConfirmBtn.anchor.set(0.5, 0.5); inputConfirmBtn.x = 2048 / 2; inputConfirmBtn.y = 1650; game.addChild(inputConfirmBtn); // Simulate input: tap to add a letter (A-Z), tap confirm to save inputBox.interactive = true; inputBox.down = function (x, y, obj) { // Cycle through A-Z var nextChar = "A"; if (inputName.length > 0) { var last = inputName.charCodeAt(inputName.length - 1); nextChar = String.fromCharCode(last >= 90 ? 65 : last + 1); } if (inputName.length < 8) { inputName += nextChar; inputBox.setText(inputName + "_"); } }; inputConfirmBtn.interactive = true; inputConfirmBtn.down = function (x, y, obj) { if (inputName.length === 0) return; // Save high score highScores.push({ name: inputName, score: score }); highScores.sort(function (a, b) { return b.score - a.score; }); if (highScores.length > 5) highScores.length = 5; storage.set(storageKey, highScores); // Refresh table if (highScoreTxt) highScoreTxt.setText("Skor Tablosu\n" + highScores.map(function (s, i) { return i + 1 + ". " + s.name + ": " + s.score; }).join("\n")); // Remove input UI if (inputBox) inputBox.destroy(); if (inputLabel) inputLabel.destroy(); if (inputBg) inputBg.destroy(); if (inputConfirmBtn) inputConfirmBtn.destroy(); }; } });
===================================================================
--- original.js
+++ change.js
@@ -259,21 +259,125 @@
}
obs.lastX = obs.x;
},
obs,
- inputBox,
- highScoreTxt,
- inputLabel,
- inputBg,
- inputConfirmBtn,
- inputName,
- highScores,
- storageKey,
points,
newLevel,
_ret;
for (var i = obstacles.length - 1; i >= 0; i--) {
_ret = _loop();
if (_ret === 0) continue;
if (_ret) return _ret.v;
}
-};
\ No newline at end of file
+};
+// --- High Score Table Logic (global scope) ---
+var inputBox, highScoreTxt, inputLabel, inputBg, inputConfirmBtn, inputName;
+var highScores = [];
+var storageKey = "egg_highscores";
+// Show high score table and input box at game over
+LK.on('gameover', function () {
+ // Load high scores from storage
+ var loaded = storage.get(storageKey);
+ if (loaded && Array.isArray(loaded)) {
+ highScores = loaded;
+ } else {
+ highScores = [];
+ }
+ // Remove previous UI if exists
+ if (inputBox) inputBox.destroy();
+ if (highScoreTxt) highScoreTxt.destroy();
+ if (inputLabel) inputLabel.destroy();
+ if (inputBg) inputBg.destroy();
+ if (inputConfirmBtn) inputConfirmBtn.destroy();
+ // Show high score table
+ highScoreTxt = new Text2("Skor Tablosu\n" + highScores.map(function (s, i) {
+ return i + 1 + ". " + s.name + ": " + s.score;
+ }).join("\n"), {
+ size: 90,
+ fill: "#fff"
+ });
+ highScoreTxt.anchor.set(0.5, 0);
+ highScoreTxt.x = 2048 / 2;
+ highScoreTxt.y = 600;
+ game.addChild(highScoreTxt);
+ // Show input for new high score if eligible
+ var isHighScore = highScores.length < 5 || score > (highScores[highScores.length - 1] ? highScores[highScores.length - 1].score : 0);
+ if (isHighScore && score > 0) {
+ // Input background
+ inputBg = LK.getAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ color: 0x000000
+ });
+ inputBg.width = 800;
+ inputBg.height = 300;
+ inputBg.alpha = 0.7;
+ inputBg.x = 2048 / 2;
+ inputBg.y = 1500;
+ game.addChild(inputBg);
+ // Label
+ inputLabel = new Text2("İsmini Gir:", {
+ size: 80,
+ fill: "#fff"
+ });
+ inputLabel.anchor.set(0.5, 0.5);
+ inputLabel.x = 2048 / 2;
+ inputLabel.y = 1450;
+ game.addChild(inputLabel);
+ // Input box (Text2 as fake input)
+ inputName = "";
+ inputBox = new Text2("_", {
+ size: 100,
+ fill: "#fff"
+ });
+ inputBox.anchor.set(0.5, 0.5);
+ inputBox.x = 2048 / 2;
+ inputBox.y = 1550;
+ game.addChild(inputBox);
+ // Confirm button
+ inputConfirmBtn = new Text2("Kaydet", {
+ size: 80,
+ fill: "#fff"
+ });
+ inputConfirmBtn.anchor.set(0.5, 0.5);
+ inputConfirmBtn.x = 2048 / 2;
+ inputConfirmBtn.y = 1650;
+ game.addChild(inputConfirmBtn);
+ // Simulate input: tap to add a letter (A-Z), tap confirm to save
+ inputBox.interactive = true;
+ inputBox.down = function (x, y, obj) {
+ // Cycle through A-Z
+ var nextChar = "A";
+ if (inputName.length > 0) {
+ var last = inputName.charCodeAt(inputName.length - 1);
+ nextChar = String.fromCharCode(last >= 90 ? 65 : last + 1);
+ }
+ if (inputName.length < 8) {
+ inputName += nextChar;
+ inputBox.setText(inputName + "_");
+ }
+ };
+ inputConfirmBtn.interactive = true;
+ inputConfirmBtn.down = function (x, y, obj) {
+ if (inputName.length === 0) return;
+ // Save high score
+ highScores.push({
+ name: inputName,
+ score: score
+ });
+ highScores.sort(function (a, b) {
+ return b.score - a.score;
+ });
+ if (highScores.length > 5) highScores.length = 5;
+ storage.set(storageKey, highScores);
+ // Refresh table
+ if (highScoreTxt) highScoreTxt.setText("Skor Tablosu\n" + highScores.map(function (s, i) {
+ return i + 1 + ". " + s.name + ": " + s.score;
+ }).join("\n"));
+ // Remove input UI
+ if (inputBox) inputBox.destroy();
+ if (inputLabel) inputLabel.destroy();
+ if (inputBg) inputBg.destroy();
+ if (inputConfirmBtn) inputConfirmBtn.destroy();
+ };
+ }
+});
\ No newline at end of file