Code edit (1 edits merged)
Please save this source code
User prompt
pop-up'Da butonları yine yazıya çevirelim
User prompt
pop up boyutunu eski haline getirebiliriz
User prompt
pop up daki butonlar yan yana ve pop-up'ın altında olsun
User prompt
sıradaki level ve tekrar oyna butonları yazı olmasın image olsun, buton oldukları anlaşılmıyor
User prompt
pop-up 'da arka plan resmi olsun
User prompt
Level skoru pop-up içerisine sığmadı .Pop-up'ı yeterince uzatalım ve level skoru yazısını tebrikler ile sıradaki level yazıları arasına yazalım
User prompt
levelin altında level skorumuz olsun. Level skoru level başlangıcında levelde çıkan duvar sayısı çarpı 100 olsun ve her duvara çarptığımızda level skorundan 20 puan eksilsin. Hedefe vurduğumuzda level skorumuz pop-up içerisinde yazsın. Yeni levele geçince level skoru tekrar levelde çıkan duvar sayısı çarpı 100 olsun.
User prompt
Pop-up açıkken atış yapamasın
User prompt
pop up aktifken ateş edemesin
User prompt
pop up kapandıktan sonraki ilk tıklama kontrolünü geri alalım, ilk tıklamada atabilsin
Code edit (1 edits merged)
Please save this source code
User prompt
Tekrar oyna butonunda işe yarıyor ama sıradaki level butonunda işe yaramıyor
User prompt
pop-up aktifken topu ateşlemesin
User prompt
sorun devam ediyor, pop-up 'daki butona tıkladıktan sonra yeni ateşleme için yeni bir tıklama beklesin
User prompt
a pop-up 'daki butona basınca topu direkt ateşliyor.
User prompt
Pop up güzel olmuş ama pop-up 'daki butona basınca topu direkt ateşliyor.
User prompt
Hedefi vurunca diğer levele geçmesin. Hedefe vurunca ekrana yeni bir pencere açılsın sıradaki levele geçmek için bir buton olsun, aynı leveli tekrar oynamak için başka bir buton olsun
User prompt
Pop up çıkmıyor
User prompt
Hedefe vurunca pop-up çıksın
User prompt
Level bittiğinde ekrana pop up açılsın level skoru yazsın ve sıradaki level geçmek için bir buton olsun
User prompt
sorunu düzelt
User prompt
sorunu düzelt
User prompt
Level skoru ekleyelim. Level başlangıcında level skoru oyunda çıkan duvar çarpı 100 olsun. Top duvara her değdiğinde 20 puan düşsün. Level bitince level skorunu büyük bir şekilde ekranda göstersin. Level bittiğinde level skorunun altında sıradaki levele geçmek için buton olsun. Level bitince kendiliğinden diğer levele geçmesin.
User prompt
Hedefin görüntüsü kayboldu
/****
* Classes
****/
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletAsset = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = bulletAsset.width / 2;
self.vx = 0;
self.vy = 0;
self.lastX = 0;
self.lastY = 0;
self.update = function () {
self.lastX = self.x;
self.lastY = self.y;
self.x += self.vx;
self.y += self.vy;
// Rotate bullet to match its direction
if (self.vx !== 0 || self.vy !== 0) {
bulletAsset.rotation = Math.atan2(self.vy, self.vx);
}
// Wall bounce
if (self.x - self.radius <= ARENA_X && self.lastX - self.radius > ARENA_X) {
self.x = ARENA_X + self.radius;
self.vx *= -1;
// No sound for left wall
}
if (self.x + self.radius >= ARENA_X + ARENA_SIZE && self.lastX + self.radius < ARENA_X + ARENA_SIZE) {
self.x = ARENA_X + ARENA_SIZE - self.radius;
self.vx *= -1;
// No sound for right wall
}
// No sound for top wall
if (self.y - self.radius <= ARENA_Y && self.lastY - self.radius > ARENA_Y) {
self.y = ARENA_Y + self.radius;
self.vy *= -1;
}
// No sound for bottom wall
if (self.y + self.radius >= ARENA_Y + ARENA_SIZE && self.lastY + self.radius < ARENA_Y + ARENA_SIZE) {
self.y = ARENA_Y + ARENA_SIZE - self.radius;
self.vy *= -1;
}
};
return self;
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obsAsset = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = obsAsset.width;
self.height = obsAsset.height;
// Crack state: 0 = no crack, 1 = small crack, 2 = big crack, 3 = broken
self.crackLevel = 0;
self.crackAsset = null;
// Show crack overlay
self.showCrack = function (level) {
// Remove previous crack asset if any
if (self.crackAsset) {
self.crackAsset.destroy();
self.crackAsset = null;
}
if (level === 1) {
// Small crack
self.crackAsset = self.attachAsset('obstacle_crack1', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (level === 2) {
// Big crack
self.crackAsset = self.attachAsset('obstacle_crack2', {
anchorX: 0.5,
anchorY: 0.5
});
}
// If level 0 or 3, no crack overlay
};
// Break wall (remove from game)
self.breakWall = function () {
// Play break sound
var breakSound = LK.getSound && LK.getSound('break');
if (breakSound) {
breakSound.play();
}
// Remove crack asset if any
if (self.crackAsset) {
self.crackAsset.destroy();
self.crackAsset = null;
}
// Remove self from game
self.destroy();
};
return self;
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerAsset = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = playerAsset.width / 2;
return self;
});
// Target class
var Target = Container.expand(function () {
var self = Container.call(this);
var targetAsset = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = targetAsset.width / 2;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Add background image to the game scene
// Small crack overlay
// Big crack overlay
// Wall break sound
var backgroundImg = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
game.addChild(backgroundImg);
// Arena and gameplay variables
var ARENA_SIZE = 1800; // Square arena, fits well in 2048x2732
var ARENA_X = (2048 - ARENA_SIZE) / 2;
var ARENA_Y = (2732 - ARENA_SIZE) / 2;
// Add visible arena border using a white rectangle shape
var borderThickness = 16;
var borderColor = 0xffffff;
var arenaBorder = LK.getAsset('arenaBorder', {
anchorX: 0,
anchorY: 0,
x: ARENA_X - borderThickness / 2,
y: ARENA_Y - borderThickness / 2,
width: ARENA_SIZE + borderThickness,
height: ARENA_SIZE + borderThickness,
color: borderColor,
shape: 'box'
});
game.addChild(arenaBorder);
// Arena and gameplay variables
var ARENA_SIZE = 1800; // Square arena, fits well in 2048x2732
var ARENA_X = (2048 - ARENA_SIZE) / 2;
var ARENA_Y = (2732 - ARENA_SIZE) / 2;
var player = null;
var target = null;
var bullets = [];
var obstacles = [];
var level = 1;
var isAiming = false;
var aimLine = null;
var aimStart = null;
var aimEnd = null;
// Level score variables
var levelScore = 0;
var levelScoreText = null;
var levelScorePopup = null;
var nextLevelBtn = null;
// Store X positions for each level so they are consistent on restart
var levelPositions = {};
function setupLevel(lvl) {
// Always ensure arena border is above background and below gameplay elements
if (arenaBorder && arenaBorder.parent) {
arenaBorder.parent.removeChild(arenaBorder);
}
game.addChild(arenaBorder);
// Clear previous
if (player) {
player.destroy();
}
if (target) {
target.destroy();
}
for (var i = 0; i < bullets.length; ++i) {
bullets[i].destroy();
}
bullets = [];
for (var i = 0; i < obstacles.length; ++i) {
obstacles[i].destroy();
}
obstacles = [];
// Player at random X along bottom, but keep same X for same level
player = new Player();
var playerMinX = ARENA_X + player.radius + 60;
var playerMaxX = ARENA_X + ARENA_SIZE - player.radius - 60;
if (!levelPositions[lvl]) {
levelPositions[lvl] = {};
levelPositions[lvl].playerX = playerMinX + Math.random() * (playerMaxX - playerMinX);
}
player.x = levelPositions[lvl].playerX;
player.y = ARENA_Y + ARENA_SIZE - 120;
game.addChild(player);
// Set player asset rotation to default (facing up)
if (typeof player.children !== "undefined" && player.children.length > 0) {
var playerAsset = player.children[0];
playerAsset.rotation = -Math.PI / 2;
}
// Target at random X along top, but keep same X for same level
target = new Target();
var targetMinX = ARENA_X + target.radius + 60;
var targetMaxX = ARENA_X + ARENA_SIZE - target.radius - 60;
if (!levelPositions[lvl].targetX) {
levelPositions[lvl].targetX = targetMinX + Math.random() * (targetMaxX - targetMinX);
}
target.x = levelPositions[lvl].targetX;
target.y = ARENA_Y + 120;
game.addChild(target);
// Obstacles for all levels, always at least 1 between player and target
var obsCount = Math.max(1, Math.min(lvl - 1, 10));
if (!levelPositions[lvl].obstacles) {
levelPositions[lvl].obstacles = [];
if (lvl > 1) {
// Always place the first obstacle between player and target (on the line between them)
var obsDummy = new Obstacle();
var margin = 200;
var t = 0.5 + (Math.random() - 0.5) * 0.2; // t in [0.4,0.6] for some randomness
var betweenX = levelPositions[lvl].playerX * (1 - t) + levelPositions[lvl].targetX * t;
// Clamp X to arena
betweenX = Math.max(ARENA_X + margin + obsDummy.width / 2, Math.min(ARENA_X + ARENA_SIZE - margin - obsDummy.width / 2, betweenX));
var betweenY = ARENA_Y + ARENA_SIZE / 2 + (Math.random() - 0.5) * 200; // Center-ish, some vertical randomness
levelPositions[lvl].obstacles.push({
x: betweenX,
y: betweenY
});
obsDummy.destroy();
// Place additional obstacles for higher levels
for (var i = 1; i < obsCount; ++i) {
var obsDummy2 = new Obstacle();
var posType = i % 3;
var xPos;
var maxTries = 20;
var tryCount = 0;
do {
if (posType === 0) {
// Left third
xPos = ARENA_X + margin + obsDummy2.width / 2 + Math.random() * (ARENA_SIZE / 3 - margin - obsDummy2.width);
} else if (posType === 1) {
// Right third
xPos = ARENA_X + 2 * ARENA_SIZE / 3 + margin + obsDummy2.width / 2 + Math.random() * (ARENA_SIZE / 3 - margin - obsDummy2.width);
} else {
// Center third
xPos = ARENA_X + ARENA_SIZE / 3 + margin + obsDummy2.width / 2 + Math.random() * (ARENA_SIZE / 3 - 2 * margin - obsDummy2.width);
}
tryCount++;
} while ((Math.abs(xPos - levelPositions[lvl].playerX) < obsDummy2.width || Math.abs(xPos - levelPositions[lvl].targetX) < obsDummy2.width || levelPositions[lvl].obstacles.some(function (o) {
return Math.abs(xPos - o.x) < obsDummy2.width && Math.abs(o.y - (ARENA_Y + ARENA_SIZE / (obsCount + 1) * (i + 1))) < obsDummy2.height;
})) && tryCount < maxTries);
// Y position: spread vertically, but randomize a bit
var yBase = ARENA_Y + ARENA_SIZE / (obsCount + 1) * (i + 1);
var yRand = Math.random() * 120 - 60; // -60 to +60 px
var yPos = yBase + yRand;
levelPositions[lvl].obstacles.push({
x: xPos,
y: yPos
});
obsDummy2.destroy();
}
}
}
for (var i = 0; i < levelPositions[lvl].obstacles.length; ++i) {
var obs = new Obstacle();
obs.x = levelPositions[lvl].obstacles[i].x;
obs.y = levelPositions[lvl].obstacles[i].y;
game.addChild(obs);
obstacles.push(obs);
}
// Set level score: number of obstacles * 100
levelScore = obstacles.length * 100;
// Remove previous level score text if any
if (levelScoreText && levelScoreText.parent) {
levelScoreText.parent.removeChild(levelScoreText);
levelScoreText = null;
}
// Show level score at top right
levelScoreText = new Text2('Score: ' + levelScore, {
size: 90,
fill: 0xFFD700
});
levelScoreText.anchor.set(1, 0);
levelScoreText.x = 2048 - 60;
levelScoreText.y = 60;
LK.gui.top.addChild(levelScoreText);
// Remove popup and next button if present
if (levelScorePopup && levelScorePopup.parent) {
levelScorePopup.parent.removeChild(levelScorePopup);
levelScorePopup = null;
}
if (nextLevelBtn && nextLevelBtn.parent) {
nextLevelBtn.parent.removeChild(nextLevelBtn);
nextLevelBtn = null;
}
}
setupLevel(level);
// Level counter text
var levelTxt = new Text2('Level: ' + level, {
size: 100,
fill: 0xFFFFFF
});
levelTxt.anchor.set(0.5, 0);
// Place at top center, but not in the top left 100x100 area
LK.gui.top.addChild(levelTxt);
// Add a button to restart the current level (without resetting level number)
var retryBtn = new Text2('↺', {
size: 120,
fill: 0xFFFFFF
});
retryBtn.anchor.set(0.5, 0.5);
// Place at top left, just below the restart button, still below the 100x100 reserved area
retryBtn.x = 600;
retryBtn.y = 100;
retryBtn.interactive = true;
retryBtn.buttonMode = true;
retryBtn.down = function (x, y, obj) {
setupLevel(level);
if (levelTxt) {
levelTxt.setText('Level: ' + level);
}
};
LK.gui.top.addChild(retryBtn);
// Aiming and shooting
game.down = function (x, y, obj) {
// Only allow aiming if no bullet is in play
if (bullets.length === 0) {
isAiming = true;
aimStart = {
x: player.x,
y: player.y
};
aimEnd = {
x: x,
y: y
};
}
};
game.move = function (x, y, obj) {
if (isAiming) {
aimEnd = {
x: x,
y: y
};
// Rotate player asset to match the aiming direction
var dx = aimEnd.x - player.x;
var dy = aimEnd.y - player.y;
if (typeof player.children !== "undefined" && player.children.length > 0) {
// playerAsset is the first child
var playerAsset = player.children[0];
playerAsset.rotation = Math.atan2(dy, dx);
}
}
};
game.up = function (x, y, obj) {
if (isAiming) {
// Fire bullet
var dx = aimEnd.x - player.x;
var dy = aimEnd.y - player.y;
var len = Math.sqrt(dx * dx + dy * dy);
if (len > 10) {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
var speed = 30;
bullet.vx = dx / len * speed;
bullet.vy = dy / len * speed;
bullets.push(bullet);
game.addChild(bullet);
}
isAiming = false;
aimStart = null;
aimEnd = null;
// Reset player asset rotation to default (facing up)
if (typeof player.children !== "undefined" && player.children.length > 0) {
var playerAsset = player.children[0];
playerAsset.rotation = -Math.PI / 2;
}
}
};
// Main update loop
game.update = function () {
// Draw aim line if aiming
if (isAiming && aimStart && aimEnd) {
if (!aimLine) {
aimLine = LK.getAsset('aimLine', {
anchorX: 0,
anchorY: 0
});
game.addChild(aimLine);
}
// Set aimLine position and size
var dx = aimEnd.x - aimStart.x;
var dy = aimEnd.y - aimStart.y;
var len = Math.sqrt(dx * dx + dy * dy);
aimLine.x = aimStart.x;
aimLine.y = aimStart.y;
aimLine.width = len;
aimLine.height = 10;
aimLine.rotation = Math.atan2(dy, dx);
} else if (aimLine) {
aimLine.destroy();
aimLine = null;
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; --i) {
var b = bullets[i];
b.update();
// Check collision with target
if (target) {
var dx = b.x - target.x;
var dy = b.y - target.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < b.radius + target.radius) {
// Play special sound for hitting the target
var targetHitSound = LK.getSound && LK.getSound('targethit');
if (targetHitSound) {
targetHitSound.play();
}
// Show broken target image
var brokenTarget = LK.getAsset('target_broken', {
anchorX: 0.5,
anchorY: 0.5,
x: target.x,
y: target.y
});
game.addChild(brokenTarget);
// Remove bullet and target
b.destroy();
bullets.splice(i, 1);
if (target) {
target.destroy();
target = null;
}
// Show level score popup and next level button (do not auto-advance)
LK.setTimeout(function () {
if (brokenTarget) {
brokenTarget.destroy();
}
// Remove previous popup/button if any
if (levelScorePopup && levelScorePopup.parent) {
levelScorePopup.parent.removeChild(levelScorePopup);
levelScorePopup = null;
}
if (nextLevelBtn && nextLevelBtn.parent) {
nextLevelBtn.parent.removeChild(nextLevelBtn);
nextLevelBtn = null;
}
// Show level score in big text at center
levelScorePopup = new Text2('Level Score: ' + levelScore, {
size: 220,
fill: 0xFFD700
});
levelScorePopup.anchor.set(0.5, 0.5);
levelScorePopup.x = 2048 / 2;
levelScorePopup.y = 2732 / 2 - 120;
LK.gui.center.addChild(levelScorePopup);
// Show next level button below score
nextLevelBtn = new Text2('Next Level ▶', {
size: 140,
fill: 0xFFFFFF
});
nextLevelBtn.anchor.set(0.5, 0.5);
nextLevelBtn.x = 2048 / 2;
nextLevelBtn.y = 2732 / 2 + 120;
nextLevelBtn.interactive = true;
nextLevelBtn.buttonMode = true;
nextLevelBtn.down = function (x, y, obj) {
// Remove popup/button
if (levelScorePopup && levelScorePopup.parent) {
levelScorePopup.parent.removeChild(levelScorePopup);
levelScorePopup = null;
}
if (nextLevelBtn && nextLevelBtn.parent) {
nextLevelBtn.parent.removeChild(nextLevelBtn);
nextLevelBtn = null;
}
level += 1;
setupLevel(level);
if (levelTxt) {
levelTxt.setText('Level: ' + level);
}
};
LK.gui.center.addChild(nextLevelBtn);
}, 500); // Show after 0.5s for effect
return;
}
} // end if (target)
// Check collision with obstacles
for (var j = obstacles.length - 1; j >= 0; --j) {
var obs = obstacles[j];
var left = obs.x - obs.width / 2;
var right = obs.x + obs.width / 2;
var top = obs.y - obs.height / 2;
var bottom = obs.y + obs.height / 2;
// Simple AABB collision
if (b.x + b.radius > left && b.x - b.radius < right && b.y + b.radius > top && b.y - b.radius < bottom) {
// Reflect bullet: pick axis of minimum penetration
var overlapX = Math.min(Math.abs(b.x + b.radius - left), Math.abs(b.x - b.radius - right));
var overlapY = Math.min(Math.abs(b.y + b.radius - top), Math.abs(b.y - b.radius - bottom));
if (overlapX < overlapY) {
b.vx *= -1;
} else {
b.vy *= -1;
}
// Crack and break logic
if (typeof obs.crackLevel === "undefined") {
obs.crackLevel = 0;
}
obs.crackLevel++;
// Decrease level score by 20, minimum 0
levelScore = Math.max(0, levelScore - 20);
if (levelScoreText) {
levelScoreText.setText('Score: ' + levelScore);
}
// Play break sound for every hit, break3 on 3rd hit
if (obs.crackLevel === 3) {
var break3Sound = LK.getSound && LK.getSound('break3');
if (break3Sound) break3Sound.play();
} else {
var breakSound = LK.getSound && LK.getSound('break');
if (breakSound) breakSound.play();
}
if (obs.crackLevel === 1) {
if (typeof obs.showCrack === "function") {
obs.showCrack(1);
}
} else if (obs.crackLevel === 2) {
if (typeof obs.showCrack === "function") {
obs.showCrack(2);
}
} else if (obs.crackLevel >= 3) {
if (typeof obs.breakWall === "function") {
obs.breakWall();
}
obstacles.splice(j, 1);
}
}
}
// Remove bullet if out of arena for too long (failsafe)
if (b.x < ARENA_X - 200 || b.x > ARENA_X + ARENA_SIZE + 200 || b.y < ARENA_Y - 200 || b.y > ARENA_Y + ARENA_SIZE + 200) {
b.destroy();
bullets.splice(i, 1);
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -171,12 +171,13 @@
var isAiming = false;
var aimLine = null;
var aimStart = null;
var aimEnd = null;
-var brokenTarget = null;
-// Score variables
-var totalScore = 0;
+// Level score variables
var levelScore = 0;
+var levelScoreText = null;
+var levelScorePopup = null;
+var nextLevelBtn = null;
// Store X positions for each level so they are consistent on restart
var levelPositions = {};
function setupLevel(lvl) {
// Always ensure arena border is above background and below gameplay elements
@@ -283,13 +284,33 @@
obs.y = levelPositions[lvl].obstacles[i].y;
game.addChild(obs);
obstacles.push(obs);
}
- // Set level score: obstacle count * 100
- levelScore = levelPositions[lvl].obstacles.length * 100;
- if (typeof levelScoreTxt !== "undefined") {
- levelScoreTxt.setText('Level Skor: ' + levelScore);
+ // Set level score: number of obstacles * 100
+ levelScore = obstacles.length * 100;
+ // Remove previous level score text if any
+ if (levelScoreText && levelScoreText.parent) {
+ levelScoreText.parent.removeChild(levelScoreText);
+ levelScoreText = null;
}
+ // Show level score at top right
+ levelScoreText = new Text2('Score: ' + levelScore, {
+ size: 90,
+ fill: 0xFFD700
+ });
+ levelScoreText.anchor.set(1, 0);
+ levelScoreText.x = 2048 - 60;
+ levelScoreText.y = 60;
+ LK.gui.top.addChild(levelScoreText);
+ // Remove popup and next button if present
+ if (levelScorePopup && levelScorePopup.parent) {
+ levelScorePopup.parent.removeChild(levelScorePopup);
+ levelScorePopup = null;
+ }
+ if (nextLevelBtn && nextLevelBtn.parent) {
+ nextLevelBtn.parent.removeChild(nextLevelBtn);
+ nextLevelBtn = null;
+ }
}
setupLevel(level);
// Level counter text
var levelTxt = new Text2('Level: ' + level, {
@@ -298,26 +319,8 @@
});
levelTxt.anchor.set(0.5, 0);
// Place at top center, but not in the top left 100x100 area
LK.gui.top.addChild(levelTxt);
-// Level score text (top right)
-var levelScoreTxt = new Text2('Level Skor: 0', {
- size: 80,
- fill: 0xFFFF00
-});
-levelScoreTxt.anchor.set(1, 0);
-levelScoreTxt.x = 2048 - 60;
-levelScoreTxt.y = 100;
-LK.gui.top.addChild(levelScoreTxt);
-// Total score text (top left, but not in reserved 100x100)
-var totalScoreTxt = new Text2('Toplam Skor: 0', {
- size: 80,
- fill: 0x00FFAA
-});
-totalScoreTxt.anchor.set(0, 0);
-totalScoreTxt.x = 120;
-totalScoreTxt.y = 100;
-LK.gui.top.addChild(totalScoreTxt);
// Add a button to restart the current level (without resetting level number)
var retryBtn = new Text2('↺', {
size: 120,
fill: 0xFFFFFF
@@ -430,13 +433,10 @@
var targetHitSound = LK.getSound && LK.getSound('targethit');
if (targetHitSound) {
targetHitSound.play();
}
- // Show broken target image and keep reference globally so it doesn't get GC'd
- if (typeof brokenTarget !== "undefined" && brokenTarget) {
- brokenTarget.destroy();
- }
- brokenTarget = LK.getAsset('target_broken', {
+ // Show broken target image
+ var brokenTarget = LK.getAsset('target_broken', {
anchorX: 0.5,
anchorY: 0.5,
x: target.x,
y: target.y
@@ -448,25 +448,59 @@
if (target) {
target.destroy();
target = null;
}
- // Delay next level by 2 seconds
+ // Show level score popup and next level button (do not auto-advance)
LK.setTimeout(function () {
- if (typeof brokenTarget !== "undefined" && brokenTarget) {
+ if (brokenTarget) {
brokenTarget.destroy();
- brokenTarget = null;
}
- // Add levelScore to totalScore
- totalScore += levelScore;
- if (typeof totalScoreTxt !== "undefined") {
- totalScoreTxt.setText('Toplam Skor: ' + totalScore);
+ // Remove previous popup/button if any
+ if (levelScorePopup && levelScorePopup.parent) {
+ levelScorePopup.parent.removeChild(levelScorePopup);
+ levelScorePopup = null;
}
- level += 1;
- setupLevel(level);
- if (levelTxt) {
- levelTxt.setText('Level: ' + level);
+ if (nextLevelBtn && nextLevelBtn.parent) {
+ nextLevelBtn.parent.removeChild(nextLevelBtn);
+ nextLevelBtn = null;
}
- }, 2000);
+ // Show level score in big text at center
+ levelScorePopup = new Text2('Level Score: ' + levelScore, {
+ size: 220,
+ fill: 0xFFD700
+ });
+ levelScorePopup.anchor.set(0.5, 0.5);
+ levelScorePopup.x = 2048 / 2;
+ levelScorePopup.y = 2732 / 2 - 120;
+ LK.gui.center.addChild(levelScorePopup);
+ // Show next level button below score
+ nextLevelBtn = new Text2('Next Level ▶', {
+ size: 140,
+ fill: 0xFFFFFF
+ });
+ nextLevelBtn.anchor.set(0.5, 0.5);
+ nextLevelBtn.x = 2048 / 2;
+ nextLevelBtn.y = 2732 / 2 + 120;
+ nextLevelBtn.interactive = true;
+ nextLevelBtn.buttonMode = true;
+ nextLevelBtn.down = function (x, y, obj) {
+ // Remove popup/button
+ if (levelScorePopup && levelScorePopup.parent) {
+ levelScorePopup.parent.removeChild(levelScorePopup);
+ levelScorePopup = null;
+ }
+ if (nextLevelBtn && nextLevelBtn.parent) {
+ nextLevelBtn.parent.removeChild(nextLevelBtn);
+ nextLevelBtn = null;
+ }
+ level += 1;
+ setupLevel(level);
+ if (levelTxt) {
+ levelTxt.setText('Level: ' + level);
+ }
+ };
+ LK.gui.center.addChild(nextLevelBtn);
+ }, 500); // Show after 0.5s for effect
return;
}
} // end if (target)
// Check collision with obstacles
@@ -490,12 +524,12 @@
if (typeof obs.crackLevel === "undefined") {
obs.crackLevel = 0;
}
obs.crackLevel++;
- // Decrease level score by 20 for each obstacle hit
+ // Decrease level score by 20, minimum 0
levelScore = Math.max(0, levelScore - 20);
- if (typeof levelScoreTxt !== "undefined") {
- levelScoreTxt.setText('Level Skor: ' + levelScore);
+ if (levelScoreText) {
+ levelScoreText.setText('Score: ' + levelScore);
}
// Play break sound for every hit, break3 on 3rd hit
if (obs.crackLevel === 3) {
var break3Sound = LK.getSound && LK.getSound('break3');
full blue screen. In-Game asset. 2d. High contrast. No shadows
gülle. In-Game asset. 2d. High contrast. No shadows
castle wall. In-Game asset. 2d. High contrast. No shadows
only the mouth part of the cannon and looking at the vertical. In-Game asset. 2d. High contrast. No shadows
castle. In-Game asset. 2d. High contrast. No shadows
kırık
daha çok kırık
yıkılmış kale
next button , no background. In-Game asset. 2d. High contrast. No shadows