User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'velocityY')' in or related to this line: 'self.velocityY += self.gravity;' Line Number: 431
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'velocityY')' in or related to this line: 'self.velocityY += self.gravity;' Line Number: 430
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'velocityY')' in or related to this line: 'self.velocityY += self.gravity;' Line Number: 429
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'velocityY')' in or related to this line: 'self.velocityY += self.gravity;' Line Number: 428
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'velocityY')' in or related to this line: 'self.velocityY += self.gravity;' Line Number: 426
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'velocityY')' in or related to this line: 'self.velocityY += self.gravity;' Line Number: 412
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'velocityY')' in or related to this line: 'self.velocityY += self.gravity;' Line Number: 410
User prompt
game is unplayable gravity doesnt work jump doesnt work game over doesnt work
User prompt
oyun başlayınca 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,
User prompt
when died return menu screen and make unplayable again when touched play make it playable again
User prompt
make game unplayable if menu is opened when touched to button play close everything about menu
User prompt
oyun başlayınca bir menüye yönlensin, 3 seçenek ilk seçenek play ikinci seçenek volume , 3. seçenek credits yapan kişi hakkında bunu yap
Code edit (1 edits merged)
Please save this source code
User prompt
trigger game over when character touches the mirrored tube
User prompt
make game over when touched tube or mirrored tube
User prompt
make character die when touched tube asset or mirrored tube
User prompt
make character die when character touches mirrored tube
User prompt
make character die when touched tree or tubes
User prompt
Move the counter 100 pixels to the right
User prompt
move pixel 200 pixel to right
User prompt
move 200 pixels right
User prompt
Move the counter 1000 pixels to the right
User prompt
move counter 100 pixel right
User prompt
move counter to middle
User prompt
more and more it is invisible because out of screen move it to the screen
/**** * 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; // Karakter genişliği self.height = 300; // Karakter yüksekliği self.update = function () { if (gameStarted && !gameOver) { // Yerçekimi ve zıplama hesaplaması 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ü 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 screenRight = 2048; 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(); } // Özel Tube çarpışma kontrolü // Tube'ların kendi intersects metodu yerine, safe (güvenli) alanı hesaplıyoruz. game.children.forEach(function (child) { if (child instanceof Tube) { // Tube'nun yatay sınırlarını hesapla (dünya koordinatlarında) var tubeLeft = child.x - child.bottomTube.width / 2; var tubeRight = child.x + child.bottomTube.width / 2; // Tube'nun safe gap hesaplaması: // Tube container'ının y değeri groundY olduğundan, // bottomTube'nun üst kenarı (dünya koordinatında): var safeGapLowerEdge = child.y - child.bottomTube.height; // topTube'nun dünya koordinatındaki y değeri: // topTube.worldY = child.y + child.topTube.y // Burada: child.topTube.y = -groundY - gapOffset + child.topTube.height/2 // Dolayısıyla topTube world y = groundY + (-groundY - gapOffset + child.topTube.height/2) = -gapOffset + child.topTube.height/2 // TopTube'nun alt kenarı (safe gap üst sınırı) = (world y of topTube) + (child.topTube.height/2) var safeGapUpperEdge = -gapOffset + child.topTube.height / 2 + child.topTube.height / 2; // Yani: safeGapUpperEdge = -gapOffset + child.topTube.height; // Karakter tube'nun yatay bölgesindeyse if (self.x + self.width / 2 > tubeLeft && self.x - self.width / 2 < tubeRight) { // Eğer karakterin dikey boyutu, güvenli geçiş bölgesinin dışına çıkıyorsa çarpışma var. // Güvenli bölge: [safeGapUpperEdge, safeGapLowerEdge] if (self.y - self.height / 2 < safeGapUpperEdge || self.y + self.height / 2 > 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; // En üstte göster return self; }); // Tree: Tube mantığıyla oluşturuldu, alt tree normal, // üst tree ise 180 derece döndürülerek aynalama efekti veriliyor. 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; // Alt Tree self.bottomTree = self.attachAsset('tree', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: false }); // Üst Tree (aynalama) 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; // Skor kontrolü: Geçiş sayacı artırılıyor if (!self.passed && character.x > self.x + self.bottomTree.width / 2) { self.passed = true; passCounter += 1; counterText.setText(passCounter); } } }; }); // Tube: 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; // Alt Tube self.bottomTube = self.attachAsset('tube', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: false }); // Üst Tube (aynalama) 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; // Skor kontrolü: Geçiş sayacı artırılıyor if (!self.passed && character.x > self.x + self.bottomTube.width / 2) { self.passed = true; passCounter += 1; counterText.setText(passCounter); } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Skor sayacı 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); /**** * Global Değişkenler ****/ var gapOffset = 400; var gameStarted = false; var gameOver = false; var centerX = 2048 / 2; var screenRight = 2048; var tubeSpawnThreshold = centerX + (screenRight - centerX) / 2; var treeSpawnThreshold = centerX + 3 * (screenRight - centerX) / 4; var groundY = 2732; var totalUnits = 10; var lastSpawner = null; var gameOverText = null; // Background var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY / 2 }); background.zIndex = 0; game.addChild(background); // Sky var sky = LK.getAsset('sky', { anchorX: 0.5, anchorY: 0, x: 2048 / 2, y: 0 }); sky.zIndex = 2; game.addChild(sky); // Ground: zIndex 4.1 (karakterin arkasında kalacak) var groundAsset = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY - -25 }); groundAsset.zIndex = 4.1; game.addChild(groundAsset); // Ground2: Arka planda, zIndex daha düşük var ground2Asset = LK.getAsset('ground2', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY - 40 }); ground2Asset.zIndex = 0.5; game.addChild(ground2Asset); // Character: En önde 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 () { resetGame(); }, 5000); } // 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; character.update = function () { if (gameOver) { character.rotation = 0; } }; gameStarted = false; gameOver = false; lastSpawner = null; passCounter = 0; counterText.setText(passCounter); } // Dokunma olayı: Dokununca oyun başlar ve ilk Tube spawn edilir. game.down = function (x, y, obj) { 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ü 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
@@ -15,52 +15,56 @@
self.width = 350; // Karakter genişliği
self.height = 300; // Karakter yüksekliği
self.update = function () {
if (gameStarted && !gameOver) {
+ // Yerçekimi ve zıplama hesaplaması
self.velocityY += self.gravity;
self.y += self.velocityY;
if (self.y > groundY - 100) {
self.y = groundY - 100;
self.velocityY = 0;
gameOver = true;
endGame();
}
- // Karakterin yarısı ekran dışına çıkarsa ölüm kontrolü
+ // Ekran sınır kontrolü
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;
- // Ekran sınırları
var screenLeft = 0;
var screenRight = 2048;
var screenTop = 0;
var screenBottom = groundY;
- // Karakterin yarısı ekranın solundan çıkarsa
- if (characterLeft + self.width / 2 < screenLeft) {
+ if (characterLeft + self.width / 2 < screenLeft || characterRight - self.width / 2 > screenRight || characterTop + self.height / 2 < screenTop || characterBottom - self.height / 2 > screenBottom) {
gameOver = true;
endGame();
}
- // Karakterin yarısı ekranın sağından çıkarsa
- else if (characterRight - self.width / 2 > screenRight) {
- gameOver = true;
- endGame();
- }
- // Karakterin yarısı ekranın üstünden çıkarsa
- else if (characterTop + self.height / 2 < screenTop) {
- gameOver = true;
- endGame();
- }
- // Karakterin yarısı ekranın altından çıkarsa
- else if (characterBottom - self.height / 2 > screenBottom) {
- gameOver = true;
- endGame();
- }
- // Check for collision with mirrored tube
+ // Özel Tube çarpışma kontrolü
+ // Tube'ların kendi intersects metodu yerine, safe (güvenli) alanı hesaplıyoruz.
game.children.forEach(function (child) {
if (child instanceof Tube) {
- if (self.intersects(child.topTube) || self.intersects(child.bottomTube)) {
- gameOver = true;
- endGame();
+ // Tube'nun yatay sınırlarını hesapla (dünya koordinatlarında)
+ var tubeLeft = child.x - child.bottomTube.width / 2;
+ var tubeRight = child.x + child.bottomTube.width / 2;
+ // Tube'nun safe gap hesaplaması:
+ // Tube container'ının y değeri groundY olduğundan,
+ // bottomTube'nun üst kenarı (dünya koordinatında):
+ var safeGapLowerEdge = child.y - child.bottomTube.height;
+ // topTube'nun dünya koordinatındaki y değeri:
+ // topTube.worldY = child.y + child.topTube.y
+ // Burada: child.topTube.y = -groundY - gapOffset + child.topTube.height/2
+ // Dolayısıyla topTube world y = groundY + (-groundY - gapOffset + child.topTube.height/2) = -gapOffset + child.topTube.height/2
+ // TopTube'nun alt kenarı (safe gap üst sınırı) = (world y of topTube) + (child.topTube.height/2)
+ var safeGapUpperEdge = -gapOffset + child.topTube.height / 2 + child.topTube.height / 2;
+ // Yani: safeGapUpperEdge = -gapOffset + child.topTube.height;
+ // Karakter tube'nun yatay bölgesindeyse
+ if (self.x + self.width / 2 > tubeLeft && self.x - self.width / 2 < tubeRight) {
+ // Eğer karakterin dikey boyutu, güvenli geçiş bölgesinin dışına çıkıyorsa çarpışma var.
+ // Güvenli bölge: [safeGapUpperEdge, safeGapLowerEdge]
+ if (self.y - self.height / 2 < safeGapUpperEdge || self.y + self.height / 2 > safeGapLowerEdge) {
+ gameOver = true;
+ endGame();
+ }
}
}
});
}
@@ -73,17 +77,15 @@
});
// GameOver Text
var GameOverText = Container.expand(function () {
var self = Container.call(this);
- // Metin oluşturma
self.text = new Text2("GAME OVER", {
fontFamily: "Arial",
fontSize: 2250,
fill: 0xFF0000,
align: "center",
fontWeight: "bold"
});
- // Metni ortala
self.text.anchorX = 0.5;
self.text.anchorY = 0.5;
self.addChild(self.text);
self.zIndex = 100; // En üstte göster
@@ -98,17 +100,17 @@
var unitSize = groundY / totalUnits;
var bottomHeight = bottomUnit * unitSize;
var topHeight = topUnit * unitSize;
self.y = groundY;
- // Alt Tree: normal asset
+ // Alt Tree
self.bottomTree = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 1,
width: 300,
height: bottomHeight,
flipY: false
});
- // Üst Tree: 180 derece döndürülerek aynalama efekti veriliyor.
+ // Üst Tree (aynalama)
self.topTree = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 0.5,
width: 300,
@@ -116,30 +118,29 @@
flipY: false
});
self.topTree.rotation = Math.PI;
self.topTree.y = -groundY - gapOffset + topHeight / 2;
- self.zIndex = 1; // Background'ın üstünde, sky/ground'dan önce
- self.x = 2048 + 800; // Ekranın hemen dışında spawn ediliyor
+ 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;
- // Tree'nin spawn threshold değeri: Ekranın ortası ile en sağı arasındaki orta nokta
if (!self.spawned && self.prevX > treeSpawnThreshold && self.x <= treeSpawnThreshold) {
self.spawned = true;
var newTube = new Tube();
- newTube.x = 2048 + 800; // Yeni obje ekran dışında spawn ediliyor
+ newTube.x = 2048 + 800;
game.addChild(newTube);
lastSpawner = newTube;
}
self.prevX = self.x;
- // Check if the character has passed between the tree and mirrored tree
+ // Skor kontrolü: Geçiş sayacı artırılıyor
if (!self.passed && character.x > self.x + self.bottomTree.width / 2) {
self.passed = true;
- passCounter += 1; // Increase the counter
- counterText.setText(passCounter); // Update the counter display
+ passCounter += 1;
+ counterText.setText(passCounter);
}
}
};
});
@@ -151,17 +152,17 @@
var unitSize = groundY / totalUnits;
var bottomHeight = bottomUnit * unitSize;
var topHeight = topUnit * unitSize;
self.y = groundY;
- // Alt Tube: normal asset
+ // Alt Tube
self.bottomTube = self.attachAsset('tube', {
anchorX: 0.5,
anchorY: 1,
width: 300,
height: bottomHeight,
flipY: false
});
- // Üst Tube: 180 derece döndürülerek aynalama efekti veriliyor.
+ // Üst Tube (aynalama)
self.topTube = self.attachAsset('tube', {
anchorX: 0.5,
anchorY: 0.5,
width: 300,
@@ -169,30 +170,29 @@
flipY: false
});
self.topTube.rotation = Math.PI;
self.topTube.y = -groundY - gapOffset + topHeight / 2;
- self.zIndex = 1; // Background'ın üstünde, sky/ground'dan önce
- self.x = 2048 + 800; // Ekranın hemen dışında spawn ediliyor
+ 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;
- // Tube'un spawn threshold değeri: Ekranın en sağı ile ortasının arasındaki orta nokta
if (!self.spawned && self.prevX > tubeSpawnThreshold && self.x <= tubeSpawnThreshold) {
self.spawned = true;
var newTree = new Tree();
- newTree.x = 2048 + 800; // Yeni obje ekran dışında spawn ediliyor
+ newTree.x = 2048 + 800;
game.addChild(newTree);
lastSpawner = newTree;
}
self.prevX = self.x;
- // Check if the character has passed between the tube and mirrored tube
+ // Skor kontrolü: Geçiş sayacı artırılıyor
if (!self.passed && character.x > self.x + self.bottomTube.width / 2) {
self.passed = true;
- passCounter += 1; // Increase the counter
- counterText.setText(passCounter); // Update the counter display
+ passCounter += 1;
+ counterText.setText(passCounter);
}
}
};
});
@@ -206,82 +206,75 @@
/****
* Game Code
****/
-// Initialize a counter to track the number of times the character goes between the tube and mirrored tube
+// Skor sayacı
var passCounter = 0;
-// Create a Text2 object to display the counter on the top left of the screen
var counterText = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
-counterText.anchor.set(0, 0); // Set anchor to the top-left corner
-counterText.x = 1320; // Move 100 pixels to the right
-counterText.y = 20; // Move slightly down
-LK.gui.topLeft.addChild(counterText); // Add the counter text to the GUI overlay
+counterText.anchor.set(0, 0);
+counterText.x = 1320;
+counterText.y = 20;
+LK.gui.topLeft.addChild(counterText);
/****
* Global Değişkenler
****/
-// Background: En arkada.
-var gapOffset = 400; // Normal ve mirror arasındaki boşluk
+var gapOffset = 400;
var gameStarted = false;
var gameOver = false;
var centerX = 2048 / 2;
-var screenRight = 2048; // Ekranın en sağı
-// Ekranın ortası ile en sağı arasındaki orta nokta (Tube için)
+var screenRight = 2048;
var tubeSpawnThreshold = centerX + (screenRight - centerX) / 2;
-// Ekranın en sağı ile ortasının arasındaki orta nokta (Tree için)
var treeSpawnThreshold = centerX + 3 * (screenRight - centerX) / 4;
var groundY = 2732;
var totalUnits = 10;
var lastSpawner = null;
var gameOverText = null;
+// Background
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: groundY / 2
});
background.zIndex = 0;
game.addChild(background);
-// Sky: Ekranın en üstünde yer alması için konumlandırıldı.
+// Sky
var sky = LK.getAsset('sky', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 0
});
sky.zIndex = 2;
game.addChild(sky);
-// Ground: Sky'ın üzerinde.
+// Ground: zIndex 4.1 (karakterin arkasında kalacak)
var groundAsset = LK.getAsset('ground', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: groundY - -25
});
groundAsset.zIndex = 4.1;
game.addChild(groundAsset);
-// Add ground2 on top of the existing ground asset
-// Add ground2 on top of the existing ground asset
+// Ground2: Arka planda, zIndex daha düşük
var ground2Asset = LK.getAsset('ground2', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: groundY - 40
});
-// Set zIndex lower than tree and tube (which are 1) so ground2 appears behind them
ground2Asset.zIndex = 0.5;
game.addChild(ground2Asset);
-// Character: En önde.
+// Character: En önde
var character = game.addChild(new Character());
character.x = 2048 / 2;
character.y = groundY / 2;
-// Oyun sonu fonksiyonu
+// Oyun bitiş fonksiyonu
function endGame() {
- // Flash screen red for a moment
LK.effects.flashScreen(0xFF0000, 500);
- // Make character untouchable and fall to the bottom of the screen
character.velocityY = character.jumpStrength;
character.update = function () {
if (gameOver) {
character.velocityY += character.gravity;
@@ -291,32 +284,27 @@
character.velocityY = 0;
}
}
};
- // Tüm hareketleri durdur
game.children.forEach(function (child) {
if (child.velocityX) {
child.velocityX = 0;
}
});
- // Disable touch input for 3 seconds
game.touchDisabled = true;
LK.setTimeout(function () {
game.touchDisabled = false;
}, 3000);
- // 5 saniye sonra oyunu yeniden başlat
LK.setTimeout(function () {
resetGame();
}, 5000);
}
// Oyunu sıfırlama fonksiyonu
function resetGame() {
- // Game Over metnini kaldır
if (gameOverText) {
game.removeChild(gameOverText);
gameOverText = null;
}
- // Tüm tube ve tree objelerini kaldır
var objectsToRemove = [];
game.children.forEach(function (child) {
if (child instanceof Tree || child instanceof Tube) {
objectsToRemove.push(child);
@@ -324,25 +312,24 @@
});
objectsToRemove.forEach(function (obj) {
game.removeChild(obj);
});
- // Karakteri başlangıç pozisyonuna getir
character.x = 2048 / 2;
character.y = groundY / 2;
character.velocityY = 0;
character.rotation = 0;
- // Disable character rotation when game is over
character.update = function () {
if (gameOver) {
character.rotation = 0;
}
};
- // Oyunu sıfırla
gameStarted = false;
gameOver = false;
lastSpawner = null;
+ passCounter = 0;
+ counterText.setText(passCounter);
}
-// Dokunma olayı: Ekrana dokununca oyun başlar ve sağdan ilk Tube spawn edilir.
+// Dokunma olayı: Dokununca oyun başlar ve ilk Tube spawn edilir.
game.down = function (x, y, obj) {
if (gameOver) {
if (!game.touchDisabled) {
resetGame();
@@ -358,9 +345,9 @@
LK.setTimeout(function () {
character.rotation = 0;
}, 200);
};
-// Oyun döngüsü.
+// Oyun döngüsü
game.update = function () {
game.children.forEach(function (child) {
if (child.update) {
child.update();