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,
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'menu is not defined' in or related to this line: 'game.addChild(menu); // Menü ekleniyor' Line Number: 294
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'menu is not defined' in or related to this line: 'game.addChild(menu); // Menü ekleniyor' Line Number: 294
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ // 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; // En önde self.velocityY = 0; self.gravity = 0.3; self.jumpStrength = -12; self.width = 350; self.height = 300; self.update = function () { // Update yalnızca oyun aktifken çalışsın 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(); } // Ekran sınır kontrolü: karakter ekranın dışına çıkarsa oyun biter. 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, screenRight = 2048, screenTop = 0, screenBottom = groundY; if (characterLeft < screenLeft || characterRight > screenRight || characterTop < screenTop || characterBottom > screenBottom) { gameOver = true; endGame(); } // Tube ve Tree ile çarpışma kontrolü 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; } }; }); // GameOver Text 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; }); // Menu Class var Menu = Container.expand(function () { var self = Container.call(this); self.zIndex = 10; var background = self.attachAsset('menu_background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 20, scaleY: 30 }); self.addChild(background); var playButton = self.attachAsset('button_play', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1000 }); playButton.on('down', function () { self.visible = false; resetGame(); gameStarted = true; gameOver = false; }); self.addChild(playButton); var volumeButton = self.attachAsset('button_volume', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1300 }); self.addChild(volumeButton); var creditsButton = self.attachAsset('button_credits', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1600 }); self.addChild(creditsButton); var recordsButton = self.attachAsset('button_records', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1900 }); self.addChild(recordsButton); return self; }); // Tree Class (Tube mantığıyla) 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 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 ****/ /**** * Global Değişkenler ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ /**** * Global Değişkenler ****/ // (Assets tanımlamaları aynı kalıyor) var gapOffset = 400; var gameStarted = false; var gameOver = false; var centerX = 2048 / 2; var screenRight = 2048; // Orijinal değerlere yakın eşikler: var tubeSpawnThreshold = centerX + (screenRight - centerX) / 2; // Örneğin 1536 var treeSpawnThreshold = centerX + 3 * (screenRight - centerX) / 4; // Örneğin 1792 var groundY = 2732; var totalUnits = 10; var lastSpawner = null; var gameOverText = null; var passCounter = 0; // GUI: Skor sayacı 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); game.addChild(menu); // Menü ekleniyor menu.visible = true; // Başlangıçta menü görünsün // Arka plan, sky, ground vs. eklemeleri: var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY / 2 }); background.zIndex = 0; game.addChild(background); var sky = LK.getAsset('sky', { anchorX: 0.5, anchorY: 0, x: 2048 / 2, y: 0 }); sky.zIndex = 2; game.addChild(sky); var groundAsset = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY - -25 }); groundAsset.zIndex = 4.1; game.addChild(groundAsset); var ground2Asset = LK.getAsset('ground2', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY - 40 }); ground2Asset.zIndex = 0.5; game.addChild(ground2Asset); var character = game.addChild(new Character()); character.x = 2048 / 2; character.y = groundY / 2; // Oyun bitiş fonksiyonu 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; LK.setTimeout(function () { game.touchDisabled = false; }, 3000); LK.setTimeout(function () { menu.visible = true; // Menü, game over'dan sonra görünür olsun }, 2500); } // Oyunu sıfırlama fonksiyonu 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 = 2048 / 2; character.y = groundY / 2; character.velocityY = 0; character.rotation = 0; // Karakter update fonksiyonunu yeniden tanımlıyoruz: character.update = function () { if (gameStarted && !gameOver) { character.velocityY += character.gravity; character.y += character.velocityY; if (character.y > groundY - 100) { character.y = groundY - 100; character.velocityY = 0; gameOver = true; endGame(); } // (Çarpışma kontrolü burada devam eder...) } }; gameStarted = false; gameOver = false; lastSpawner = null; passCounter = 0; counterText.setText(passCounter); } // Dokunma olayı: Menü açıkken dokunmaları pasif hale getir. game.down = function (x, y, obj) { console.log("Game state before touch:", { gameStarted: gameStarted, gameOver: gameOver, menuVisible: menu.visible }); if (menu.visible) { return; } // Menü açıksa hiçbir işlem yapma if (gameOver) { if (!game.touchDisabled) { resetGame(); } } else if (!gameStarted) { gameStarted = true; var initialTube = new Tube(); game.addChild(initialTube); lastSpawner = initialTube; } character.jump(); character.rotation = 0.1; LK.setTimeout(function () { character.rotation = 0; }, 200); }; // Oyun döngüsü: Menü açıkken güncellemeyi duraklatıyoruz. game.update = function () { if (menu.visible) { return; } // Menü açıkken güncelleme yapma game.children.forEach(function (child) { if (child.update) { child.update(); } }); game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); };
/****
* Classes
****/
// 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; // En önde
self.velocityY = 0;
self.gravity = 0.3;
self.jumpStrength = -12;
self.width = 350;
self.height = 300;
self.update = function () {
// Update yalnızca oyun aktifken çalışsın
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();
}
// Ekran sınır kontrolü: karakter ekranın dışına çıkarsa oyun biter.
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,
screenRight = 2048,
screenTop = 0,
screenBottom = groundY;
if (characterLeft < screenLeft || characterRight > screenRight || characterTop < screenTop || characterBottom > screenBottom) {
gameOver = true;
endGame();
}
// Tube ve Tree ile çarpışma kontrolü
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;
}
};
});
// GameOver Text
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;
});
// Menu Class
var Menu = Container.expand(function () {
var self = Container.call(this);
self.zIndex = 10;
var background = self.attachAsset('menu_background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 20,
scaleY: 30
});
self.addChild(background);
var playButton = self.attachAsset('button_play', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1000
});
playButton.on('down', function () {
self.visible = false;
resetGame();
gameStarted = true;
gameOver = false;
});
self.addChild(playButton);
var volumeButton = self.attachAsset('button_volume', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1300
});
self.addChild(volumeButton);
var creditsButton = self.attachAsset('button_credits', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1600
});
self.addChild(creditsButton);
var recordsButton = self.attachAsset('button_records', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1900
});
self.addChild(recordsButton);
return self;
});
// Tree Class (Tube mantığıyla)
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
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
****/
/****
* Global Değişkenler
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
/****
* Global Değişkenler
****/
// (Assets tanımlamaları aynı kalıyor)
var gapOffset = 400;
var gameStarted = false;
var gameOver = false;
var centerX = 2048 / 2;
var screenRight = 2048;
// Orijinal değerlere yakın eşikler:
var tubeSpawnThreshold = centerX + (screenRight - centerX) / 2; // Örneğin 1536
var treeSpawnThreshold = centerX + 3 * (screenRight - centerX) / 4; // Örneğin 1792
var groundY = 2732;
var totalUnits = 10;
var lastSpawner = null;
var gameOverText = null;
var passCounter = 0;
// GUI: Skor sayacı
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);
game.addChild(menu); // Menü ekleniyor
menu.visible = true; // Başlangıçta menü görünsün
// Arka plan, sky, ground vs. eklemeleri:
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: groundY / 2
});
background.zIndex = 0;
game.addChild(background);
var sky = LK.getAsset('sky', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 0
});
sky.zIndex = 2;
game.addChild(sky);
var groundAsset = LK.getAsset('ground', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: groundY - -25
});
groundAsset.zIndex = 4.1;
game.addChild(groundAsset);
var ground2Asset = LK.getAsset('ground2', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: groundY - 40
});
ground2Asset.zIndex = 0.5;
game.addChild(ground2Asset);
var character = game.addChild(new Character());
character.x = 2048 / 2;
character.y = groundY / 2;
// Oyun bitiş fonksiyonu
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;
LK.setTimeout(function () {
game.touchDisabled = false;
}, 3000);
LK.setTimeout(function () {
menu.visible = true; // Menü, game over'dan sonra görünür olsun
}, 2500);
}
// Oyunu sıfırlama fonksiyonu
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 = 2048 / 2;
character.y = groundY / 2;
character.velocityY = 0;
character.rotation = 0;
// Karakter update fonksiyonunu yeniden tanımlıyoruz:
character.update = function () {
if (gameStarted && !gameOver) {
character.velocityY += character.gravity;
character.y += character.velocityY;
if (character.y > groundY - 100) {
character.y = groundY - 100;
character.velocityY = 0;
gameOver = true;
endGame();
}
// (Çarpışma kontrolü burada devam eder...)
}
};
gameStarted = false;
gameOver = false;
lastSpawner = null;
passCounter = 0;
counterText.setText(passCounter);
}
// Dokunma olayı: Menü açıkken dokunmaları pasif hale getir.
game.down = function (x, y, obj) {
console.log("Game state before touch:", {
gameStarted: gameStarted,
gameOver: gameOver,
menuVisible: menu.visible
});
if (menu.visible) {
return;
} // Menü açıksa hiçbir işlem yapma
if (gameOver) {
if (!game.touchDisabled) {
resetGame();
}
} else if (!gameStarted) {
gameStarted = true;
var initialTube = new Tube();
game.addChild(initialTube);
lastSpawner = initialTube;
}
character.jump();
character.rotation = 0.1;
LK.setTimeout(function () {
character.rotation = 0;
}, 200);
};
// Oyun döngüsü: Menü açıkken güncellemeyi duraklatıyoruz.
game.update = function () {
if (menu.visible) {
return;
} // Menü açıkken güncelleme yapma
game.children.forEach(function (child) {
if (child.update) {
child.update();
}
});
game.children.sort(function (a, b) {
return (a.zIndex || 0) - (b.zIndex || 0);
});
};
green theme forest by green tones to the sky , not to much detail just simple tree shadows trees has no details just shadowed green and shadowless places, beautiful view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
hyper realistic nature too reallistic proffational blue sky white clouds yellow sun an over realistic mountain view with full of trees and sun and clouds view a forest of a mountain challangeing mountain road. No background.cool background. view background. No shadows. 2d. In-Game asset. flat