User prompt
move play 5 pixel left move volume 20 pixel left credits 22 pixel left records 22 pixel left
User prompt
move all texts 25 pixel left
User prompt
move play text middle of play button do the same for credits vloume and records text to their button
User prompt
move play putton 6 pixel up 5 pixel right move volume button 5 pixel up 5 pixel right move credits 4 pixel up 5 pixel right move records 5 pixel right
User prompt
keep texts location the same move play button 25 pixel up move volume 10 pixel up move credits 5 pixel up move records 7 pixel down
User prompt
move texts 10 pixel left
User prompt
move play text 20 pixel up move volume text 20 pixel up move credits 15 pixel up move records 13 pixel up
User prompt
movem them 30 pixel down
User prompt
move them 15 pixel left
User prompt
move them 30 pixel down
User prompt
move them 30 pixel left
User prompt
move them left 10 pixel
User prompt
10 pixel more
User prompt
50 pixel more
User prompt
50 pixel more
User prompt
50 pixel more
User prompt
50 pixel more
User prompt
50 pixel more
User prompt
move play volume credits and records button down
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'LK.Container is not a constructor' in or related to this line: 'var menuContainer = new LK.Container();' Line Number: 227
Code edit (1 edits merged)
Please save this source code
User prompt
when touched play unfreez the game
User prompt
oyun başladığı anda oyunu dondur bir menüye yönlensin, 4 seçenek ilk seçenek play ikinci seçenek volume , 3. seçenek credits yapan kişi hakkında, 4. records en iyi 5 skoru ekranda yazar countu yani, make game unplayable if menu is opened when touched to button play close everything about menu and when game over lead to menu again when touched play make everything return to the first time game opened except records,
/**** * Classes ****/ // Skor sayacı // Character: Dokunulduğunda zıplar. var Character = Container.expand(function () { var self = Container.call(this); self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); self.zIndex = 4; self.velocityY = 0; self.gravity = 0.3; self.jumpStrength = -12; self.width = 350; self.height = 300; self.update = function () { if (gameStarted && !gameOver) { self.velocityY += self.gravity; self.y += self.velocityY; if (self.y > groundY - 100) { self.y = groundY - 100; self.velocityY = 0; gameOver = true; endGame(); } var characterLeft = self.x - self.width / 2; var characterRight = self.x + self.width / 2; var characterTop = self.y - self.height / 2; var characterBottom = self.y + self.height / 2; var screenLeft = 0; var screenTop = 0; var screenBottom = groundY; if (characterLeft + self.width / 2 < screenLeft || characterRight - self.width / 2 > screenRight || characterTop + self.height / 2 < screenTop || characterBottom - self.height / 2 > screenBottom) { gameOver = true; endGame(); } // Çarpışma kontrolü: Tube ve Tree game.children.forEach(function (child) { if (child instanceof Tube) { var tubeLeft = child.x - child.bottomTube.width / 2; var tubeRight = child.x + child.bottomTube.width / 2; var safeGapLowerEdge = child.y - child.bottomTube.height; var safeGapUpperEdge = -gapOffset + child.topTube.height; if (self.x + self.width / 2 > tubeLeft && self.x - self.width / 2 < tubeRight) { if (self.y < safeGapUpperEdge || self.y > safeGapLowerEdge) { gameOver = true; endGame(); } } } else if (child instanceof Tree) { var treeLeft = child.x - child.bottomTree.width / 2; var treeRight = child.x + child.bottomTree.width / 2; var safeGapLowerEdge = child.y - child.bottomTree.height; var safeGapUpperEdge = -gapOffset + child.topTree.height; if (self.x + self.width / 2 > treeLeft && self.x - self.width / 2 < treeRight) { if (self.y < safeGapUpperEdge || self.y > safeGapLowerEdge) { gameOver = true; endGame(); } } } }); } }; self.jump = function () { if (!gameOver) { self.velocityY = self.jumpStrength; } }; }); // GameOverText class var GameOverText = Container.expand(function () { var self = Container.call(this); self.text = new Text2("GAME OVER", { fontFamily: "Arial", fontSize: 2250, fill: 0xFF0000, align: "center", fontWeight: "bold" }); self.text.anchorX = 0.5; self.text.anchorY = 0.5; self.addChild(self.text); self.zIndex = 100; return self; }); // Tree class: Üst ve alt ağaç oluşturma var Tree = Container.expand(function () { var self = Container.call(this); var bottomUnit = Math.floor(Math.random() * 8) + 1; var topUnit = 9 - bottomUnit; var unitSize = groundY / totalUnits; var bottomHeight = bottomUnit * unitSize; var topHeight = topUnit * unitSize; self.y = groundY; self.bottomTree = self.attachAsset('tree', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: false }); self.topTree = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0.5, width: 300, height: topHeight, flipY: false }); self.topTree.rotation = Math.PI; self.topTree.y = -groundY - gapOffset + topHeight / 2; self.zIndex = 1; self.x = 2048 + 800; self.velocityX = -3.6; self.spawned = false; self.prevX = self.x; self.update = function () { if (gameStarted && !gameOver) { self.x += self.velocityX; if (!self.spawned && self.prevX > treeSpawnThreshold && self.x <= treeSpawnThreshold) { self.spawned = true; var newTube = new Tube(); newTube.x = 2048 + 800; game.addChild(newTube); lastSpawner = newTube; } self.prevX = self.x; if (!self.passed && character.x > self.x + self.bottomTree.width / 2) { self.passed = true; passCounter += 1; counterText.setText(passCounter); } } }; }); // Tube class: Üst ve alt boru oluşturma var Tube = Container.expand(function () { var self = Container.call(this); var bottomUnit = Math.floor(Math.random() * 8) + 1; var topUnit = 9 - bottomUnit; var unitSize = groundY / totalUnits; var bottomHeight = bottomUnit * unitSize; var topHeight = topUnit * unitSize; self.y = groundY; self.bottomTube = self.attachAsset('tube', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: false }); self.topTube = self.attachAsset('tube', { anchorX: 0.5, anchorY: 0.5, width: 300, height: topHeight, flipY: false }); self.topTube.rotation = Math.PI; self.topTube.y = -groundY - gapOffset + topHeight / 2; self.zIndex = 1; self.x = 2048 + 800; self.velocityX = -3.6; self.spawned = false; self.prevX = self.x; self.update = function () { if (gameStarted && !gameOver) { self.x += self.velocityX; if (!self.spawned && self.prevX > tubeSpawnThreshold && self.x <= tubeSpawnThreshold) { self.spawned = true; var newTree = new Tree(); newTree.x = 2048 + 800; game.addChild(newTree); lastSpawner = newTree; } self.prevX = self.x; if (!self.passed && character.x > self.x + self.bottomTube.width / 2) { self.passed = true; passCounter += 1; counterText.setText(passCounter); } } }; }); /**** * Initialize Game ****/ /**** * Game Initialization ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // groundY, diğer hesaplamalarda kullanmak üzere önceden tanımlanmalı /**** * Global Variables ****/ // Skor sayacı var groundY = 2732; var menuOpen = true; var volumeOn = true; var records = []; // En iyi 5 skoru saklar // Menü konteyneri (LK.Container yerine Container kullanıyoruz) var menuContainer = new Container(); menuContainer.zIndex = 200; // En üstte // Yardımcı fonksiyonlar: Merkez koordinatları function centerX() { return 2048 / 2; } function centerY() { return groundY / 2; } // Menü arka planı var menuBackground = LK.getAsset('menu_background', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: centerY() }); menuContainer.addChild(menuBackground); // PLAY Butonu var playButton = LK.getAsset('button_play', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: centerY() - 150 }); menuContainer.addChild(playButton); var playLabel = new Text2("PLAY", { fontFamily: "Arial", fontSize: 50, fill: 0xffffff }); playLabel.anchorX = 0.5; playLabel.anchorY = 0.5; playLabel.x = playButton.x; playLabel.y = playButton.y; menuContainer.addChild(playLabel); // VOLUME Butonu var volumeButton = LK.getAsset('button_volume', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: centerY() - 50 }); menuContainer.addChild(volumeButton); var volumeLabel = new Text2("VOLUME", { fontFamily: "Arial", fontSize: 50, fill: 0xffffff }); volumeLabel.anchorX = 0.5; volumeLabel.anchorY = 0.5; volumeLabel.x = volumeButton.x; volumeLabel.y = volumeButton.y; menuContainer.addChild(volumeLabel); // CREDITS Butonu var creditsButton = LK.getAsset('button_credits', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: centerY() + 50 }); menuContainer.addChild(creditsButton); var creditsLabel = new Text2("CREDITS", { fontFamily: "Arial", fontSize: 50, fill: 0xffffff }); creditsLabel.anchorX = 0.5; creditsLabel.anchorY = 0.5; creditsLabel.x = creditsButton.x; creditsLabel.y = creditsButton.y; menuContainer.addChild(creditsLabel); // RECORDS Butonu var recordsButton = LK.getAsset('button_records', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: centerY() + 150 }); menuContainer.addChild(recordsButton); var recordsLabel = new Text2("RECORDS", { fontFamily: "Arial", fontSize: 50, fill: 0xffffff }); recordsLabel.anchorX = 0.5; recordsLabel.anchorY = 0.5; recordsLabel.x = recordsButton.x; recordsLabel.y = recordsButton.y; menuContainer.addChild(recordsLabel); /**** * Diğer Global Oyun Değişkenleri ****/ var gapOffset = 400; var gameStarted = false; var gameOver = false; var screenRight = 2048; var tubeSpawnThreshold = centerX() + (screenRight - centerX()) / 2; var treeSpawnThreshold = centerX() + 3 * (screenRight - centerX()) / 4; var totalUnits = 10; var lastSpawner = null; var gameOverText = null; var passCounter = 0; var counterText = new Text2('0', { size: 100, fill: 0xFFFFFF }); counterText.anchor.set(0, 0); counterText.x = 1320; counterText.y = 20; LK.gui.topLeft.addChild(counterText); // Arka plan var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: groundY / 2 }); background.zIndex = 0; game.addChild(background); // Gökyüzü (Sky) var sky = LK.getAsset('sky', { anchorX: 0.5, anchorY: 0, x: centerX(), y: 0 }); sky.zIndex = 2; game.addChild(sky); // Zemin (Ground) var groundAsset = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: groundY - -25 }); groundAsset.zIndex = 4.1; game.addChild(groundAsset); // Arka zemin (Ground2) var ground2Asset = LK.getAsset('ground2', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: groundY - 40 }); ground2Asset.zIndex = 0.5; game.addChild(ground2Asset); // Karakter oluşturulması var character = game.addChild(new Character()); character.x = centerX(); character.y = groundY / 2; // Menü konteynerini oyuna ekle (ilk açılışta görünür) game.addChild(menuContainer); /**** * Yardımcı Fonksiyonlar: Credits ve Records Gösterimi ****/ function showCredits() { var creditsContainer = new Container(); creditsContainer.zIndex = 300; var bg = new Shape({ width: 500, height: 300, color: 0x000000 }); bg.anchorX = 0.5; bg.anchorY = 0.5; bg.x = centerX(); bg.y = centerY(); creditsContainer.addChild(bg); var creditsText = new Text2("Game by YourName", { fontFamily: "Arial", fontSize: 30, fill: 0xffffff }); creditsText.anchorX = 0.5; creditsText.anchorY = 0.5; creditsText.x = centerX(); creditsText.y = centerY(); creditsContainer.addChild(creditsText); game.addChild(creditsContainer); LK.setTimeout(function () { game.removeChild(creditsContainer); }, 3000); } function showRecords() { var recordsContainer = new Container(); recordsContainer.zIndex = 300; var bg = new Shape({ width: 500, height: 300, color: 0x000000 }); bg.anchorX = 0.5; bg.anchorY = 0.5; bg.x = centerX(); bg.y = centerY(); recordsContainer.addChild(bg); var recordsTextStr = "Top Scores:\n"; for (var i = 0; i < records.length; i++) { recordsTextStr += i + 1 + ". " + records[i] + "\n"; } if (records.length === 0) { recordsTextStr += "No records yet."; } var recordsText = new Text2(recordsTextStr, { fontFamily: "Arial", fontSize: 30, fill: 0xffffff, align: "center" }); recordsText.anchorX = 0.5; recordsText.anchorY = 0.5; recordsText.x = centerX(); recordsText.y = centerY(); recordsContainer.addChild(recordsText); game.addChild(recordsContainer); LK.setTimeout(function () { game.removeChild(recordsContainer); }, 3000); } /**** * Oyun Bitişi ve Reset Fonksiyonları ****/ function endGame() { LK.effects.flashScreen(0xFF0000, 500); character.velocityY = character.jumpStrength; character.update = function () { if (gameOver) { character.velocityY += character.gravity; character.y += character.velocityY; if (character.y > groundY + character.height) { character.y = groundY + character.height; character.velocityY = 0; } } }; game.children.forEach(function (child) { if (child.velocityX) { child.velocityX = 0; } }); game.touchDisabled = true; records.push(passCounter); records.sort(function (a, b) { return b - a; }); if (records.length > 5) { records = records.slice(0, 5); } LK.setTimeout(function () { game.touchDisabled = false; menuOpen = true; menuContainer.visible = true; }, 3000); LK.setTimeout(function () { resetGame(); }, 5000); } function resetGame() { if (gameOverText) { game.removeChild(gameOverText); gameOverText = null; } var objectsToRemove = []; game.children.forEach(function (child) { if (child instanceof Tree || child instanceof Tube) { objectsToRemove.push(child); } }); objectsToRemove.forEach(function (obj) { game.removeChild(obj); }); character.x = centerX(); character.y = groundY / 2; character.velocityY = 0; character.rotation = 0; character.update = function () { if (gameOver) { character.rotation = 0; } }; gameStarted = false; gameOver = false; lastSpawner = null; passCounter = 0; counterText.setText(passCounter); // Menü açık kalır; kayıtlar korunur. } /**** * Dokunma (Touch) Olayı ****/ game.down = function (x, y, obj) { if (menuOpen) { if (obj === playButton || obj === playLabel) { menuOpen = false; menuContainer.visible = false; gameStarted = true; var initialTube = new Tube(); game.addChild(initialTube); lastSpawner = initialTube; } else if (obj === volumeButton || obj === volumeLabel) { volumeOn = !volumeOn; } else if (obj === creditsButton || obj === creditsLabel) { showCredits(); } else if (obj === recordsButton || obj === recordsLabel) { showRecords(); } return; } else if (gameOver) { if (!game.touchDisabled) { menuOpen = true; menuContainer.visible = true; resetGame(); } } else { character.jump(); character.rotation = 0.1; LK.setTimeout(function () { character.rotation = 0; }, 200); } }; /**** * Oyun Döngüsü ****/ game.update = function () { game.children.forEach(function (child) { if (child.update) { child.update(); } }); game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); };
===================================================================
--- original.js
+++ change.js
@@ -197,18 +197,18 @@
/****
* Game Code
****/
-// groundY, kullanılmadan önce tanımlanmalı
+// groundY, diğer hesaplamalarda kullanmak üzere önceden tanımlanmalı
/****
* Global Variables
****/
// Skor sayacı
var groundY = 2732;
var menuOpen = true;
var volumeOn = true;
var records = []; // En iyi 5 skoru saklar
-// Menü konteyneri
+// Menü konteyneri (LK.Container yerine Container kullanıyoruz)
var menuContainer = new Container();
menuContainer.zIndex = 200; // En üstte
// Yardımcı fonksiyonlar: Merkez koordinatları
function centerX() {
@@ -363,11 +363,11 @@
/****
* Yardımcı Fonksiyonlar: Credits ve Records Gösterimi
****/
function showCredits() {
- var creditsContainer = new LK.Container();
+ var creditsContainer = new Container();
creditsContainer.zIndex = 300;
- var bg = new LK.Shape({
+ var bg = new Shape({
width: 500,
height: 300,
color: 0x000000
});
@@ -391,11 +391,11 @@
game.removeChild(creditsContainer);
}, 3000);
}
function showRecords() {
- var recordsContainer = new LK.Container();
+ var recordsContainer = new Container();
recordsContainer.zIndex = 300;
- var bg = new LK.Shape({
+ var bg = new Shape({
width: 500,
height: 300,
color: 0x000000
});