Code edit (1 edits merged)
Please save this source code
User prompt
gülen yüz sallanarak bize gelsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
gülen yüz bize doğru büyünsün 3 saniye büyüdükten sonra bizle dalga geçsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
kaybedince gülen yüz çıkıp hahaha enayi kaybettin desin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
can gidince bilgisayarı titret
User prompt
üst üste gelen bulutlardan ufak şimşekler oluşsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
ekranın ortasındaki yeşil alan kalksın
User prompt
bulutlar bütün ekranda dolaşsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bulutlar kalenin ekseni hariç bütün ekranda dolaşsın ve kalenin ekseni yeşil olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
arkadan yatay şekilde bulutlar geçsin ama oyuna bir etkisi olmasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
mavitopözel alınmayıp es geçilince canımız eksilmeyecek
User prompt
mavitopözel yüzünden canımız biterse oyunda bitecek
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'topScores.push(['Ali', 200]);' Line Number: 542 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'topScores.push(['Ali', currentScore]);' Line Number: 498 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
mavi toplar aksın ve onları yutmak 1 canımızı götürsün
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'topScores.push(['Zeynep', currentScore]);' Line Number: 612 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'topScores.push(['Elif', currentScore]);' Line Number: 624 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'topScores.push(['Seda', 0]);' Line Number: 634 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'topScores.push(['Ayşe', currentScore]);' Line Number: 494 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
kırmızı toplar her 150 puanda 1 tane düşsün ve oyun her 500 puanda bir 0.7 oranında hızlansın
User prompt
arada kırmızı toplar düşsün o topları alınca 1 can eklesin ama 3 canımız zaten varsa daha can eklenmesin
User prompt
3 canında gitmesi durumunda oyun dursun
User prompt
Please fix the bug: 'Timeout.tick error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'topScores.push(['Ahmet', currentScore]);' Line Number: 504 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballColors = ['ball', 'ballBlue', 'ballGreen', 'ballYellow'];
var randomColor = ballColors[Math.floor(Math.random() * ballColors.length)];
var ballGraphics = self.attachAsset(randomColor, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 3 + 2; // Random speed between 2-5
self.baseSpeed = self.speed; // Store original speed
self.lastY = 0;
self.lastIntersecting = false;
self.update = function () {
self.y += self.speed * speedMultiplier;
};
return self;
});
var Castle = Container.expand(function () {
var self = Container.call(this);
var castleGraphics = self.attachAsset('castle', {
anchorX: 0.5,
anchorY: 1.0
});
return self;
});
var MockingFace = Container.expand(function () {
var self = Container.call(this);
var faceGraphics = self.attachAsset('smilingFace', {
anchorX: 0.5,
anchorY: 0.5
});
// Add mocking text
var mockText = new Text2('HAHAHA ENAYİ KAYBETTİN', {
size: 60,
fill: 0xFF0000
});
mockText.anchor.set(0.5, 0.5);
mockText.y = 150;
self.addChild(mockText);
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
var gameStarted = false;
var castle = game.addChild(new Castle());
castle.x = 1024; // Center horizontally
castle.y = 2732 - 50; // Near bottom with some padding
castle.visible = false; // Hide initially
var balls = [];
var lives = 3;
var ballSpawnTimer = 0;
var ballSpawnRate = 60; // Spawn every 60 ticks initially
var speedMultiplier = 1.0; // Speed multiplier for progressive difficulty
var dragNode = null;
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.visible = false; // Hide initially
LK.gui.top.addChild(scoreTxt);
// Lives display
var livesTxt = new Text2('Lives: 3', {
size: 60,
fill: 0xFFFFFF
});
livesTxt.anchor.set(0, 0);
livesTxt.x = 100;
livesTxt.y = 100;
livesTxt.visible = false; // Hide initially
LK.gui.topLeft.addChild(livesTxt);
// Start screen elements
var startScreen = new Container();
LK.gui.center.addChild(startScreen);
// Game title
var titleTxt = new Text2('CASTLE BALL COLLECTOR', {
size: 80,
fill: 0xFFD700
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.y = -200;
startScreen.addChild(titleTxt);
// Subtitle
var subtitleTxt = new Text2('Catch the falling balls with your castle!', {
size: 50,
fill: 0xFFFFFF
});
subtitleTxt.anchor.set(0.5, 0.5);
subtitleTxt.y = -120;
startScreen.addChild(subtitleTxt);
// Start button
var startButton = new Text2('START', {
size: 120,
fill: 0x00FF00
});
startButton.anchor.set(0.5, 0.5);
startButton.y = 50;
startScreen.addChild(startButton);
// Instructions
var instructionTxt = new Text2('Drag to move castle', {
size: 40,
fill: 0xCCCCCC
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.y = 150;
startScreen.addChild(instructionTxt);
// Leaderboard container for top right positioning
var leaderboardContainer = new Container();
LK.gui.topRight.addChild(leaderboardContainer);
// Position leaderboard away from top right corner
leaderboardContainer.x = -250;
leaderboardContainer.y = 50;
// Leaderboard title
var leaderboardTitle = new Text2('LEADERBOARD', {
size: 45,
fill: 0xFFD700
});
leaderboardTitle.anchor.set(0.5, 0);
leaderboardTitle.y = 0;
leaderboardContainer.addChild(leaderboardTitle);
// Detailed leaderboard overlay
var detailedLeaderboard = new Container();
LK.gui.center.addChild(detailedLeaderboard);
detailedLeaderboard.visible = false;
// Background for detailed leaderboard
var leaderboardBg = LK.getAsset('modernFloor', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.6,
alpha: 0.9
});
detailedLeaderboard.addChild(leaderboardBg);
// Detailed title
var detailedTitle = new Text2('ALL SCORES', {
size: 80,
fill: 0xFFD700
});
detailedTitle.anchor.set(0.5, 0.5);
detailedTitle.y = -250;
detailedLeaderboard.addChild(detailedTitle);
// Close button
var closeButton = new Text2('CLOSE', {
size: 60,
fill: 0xFF0000
});
closeButton.anchor.set(0.5, 0.5);
closeButton.y = 250;
detailedLeaderboard.addChild(closeButton);
// Function to update detailed leaderboard
function updateDetailedLeaderboard() {
// Clear existing score texts (skip title and close button)
for (var i = detailedLeaderboard.children.length - 1; i >= 0; i--) {
var child = detailedLeaderboard.children[i];
if (child !== leaderboardBg && child !== detailedTitle && child !== closeButton) {
detailedLeaderboard.removeChild(child);
}
}
var allScores = storage.topScores || [];
var currentScore = LK.getScore();
var playerRank = -1;
var maxScoresToShow = Math.min(8, allScores.length); // Show 8 scores to leave room for player rank
// Find player's rank
for (var r = 0; r < allScores.length; r++) {
var entryScore;
if (Array.isArray(allScores[r])) {
entryScore = allScores[r][1];
} else if (_typeof(allScores[r]) === 'object' && allScores[r].score !== undefined) {
entryScore = allScores[r].score;
} else {
entryScore = allScores[r];
}
if (currentScore >= entryScore) {
playerRank = r + 1;
break;
}
}
if (playerRank === -1) {
playerRank = allScores.length + 1;
}
// Create scrolling leaderboard entries
for (var s = 0; s < maxScoresToShow; s++) {
var entry = allScores[s];
var displayText = s + 1 + '. ';
if (Array.isArray(entry)) {
// New array format [name, score]
displayText += entry[0] + ': ' + entry[1] + ' points';
} else if (_typeof(entry) === 'object' && entry.name && entry.score !== undefined) {
// Legacy object format
displayText += entry.name + ': ' + entry.score + ' points';
} else {
// Handle legacy format (just numbers)
displayText += 'Player: ' + entry + ' points';
}
var detailedScoreText = new Text2(displayText, {
size: 45,
fill: 0xFFFFFF
});
detailedScoreText.anchor.set(0.5, 0.5);
detailedScoreText.y = -400; // Start above visible area
detailedLeaderboard.addChild(detailedScoreText);
// Animate entry flowing down
tween(detailedScoreText, {
y: -150 + s * 35
}, {
duration: 800 + s * 100,
easing: tween.easeOut
});
}
// Add player's current rank at the bottom
var playerRankText = new Text2('Your Rank: ' + playerRank + ' (Score: ' + currentScore + ')', {
size: 40,
fill: 0xFFD700
});
playerRankText.anchor.set(0.5, 0.5);
playerRankText.y = -400; // Start above visible area
detailedLeaderboard.addChild(playerRankText);
// Animate player rank flowing down to bottom
tween(playerRankText, {
y: 200
}, {
duration: 1200,
easing: tween.easeOut
});
if (allScores.length === 0) {
var noScoresText = new Text2('No scores yet!', {
size: 50,
fill: 0x888888
});
noScoresText.anchor.set(0.5, 0.5);
noScoresText.y = -400;
detailedLeaderboard.addChild(noScoresText);
tween(noScoresText, {
y: 0
}, {
duration: 800,
easing: tween.easeOut
});
}
}
// Leaderboard click handler
leaderboardContainer.down = function (x, y, obj) {
updateDetailedLeaderboard();
detailedLeaderboard.visible = true;
};
// Close button click handler
closeButton.down = function (x, y, obj) {
detailedLeaderboard.visible = false;
};
// Get top 5 scores from storage
var topScores = storage.topScores || [];
// Add some simulated other players' scores if leaderboard is empty
if (topScores.length === 0) {
var simulatedPlayers = [['Emre', 480], ['Cansu', 350], ['Berk', 280], ['Deniz', 220], ['Kerem', 150], ['Selin', 120], ['Ozan', 90], ['Pınar', 60], ['Arda', 40], ['Melis', 20]];
// Add simulated scores to storage
for (var p = 0; p < simulatedPlayers.length; p++) {
var playerName = simulatedPlayers[p][0];
var playerScore = simulatedPlayers[p][1];
if (playerName === 'Emre') {
topScores.push(['Emre', 480]);
} else if (playerName === 'Cansu') {
topScores.push(['Cansu', 350]);
} else if (playerName === 'Berk') {
topScores.push(['Berk', 280]);
} else if (playerName === 'Deniz') {
topScores.push(['Deniz', 220]);
} else if (playerName === 'Kerem') {
topScores.push(['Kerem', 150]);
} else if (playerName === 'Selin') {
topScores.push(['Selin', 120]);
} else if (playerName === 'Ozan') {
topScores.push(['Ozan', 90]);
} else if (playerName === 'Pınar') {
topScores.push(['Pınar', 60]);
} else if (playerName === 'Arda') {
topScores.push(['Arda', 40]);
} else if (playerName === 'Melis') {
topScores.push(['Melis', 20]);
}
}
// Sort scores in descending order
topScores.sort(function (a, b) {
var scoreA = Array.isArray(a) ? a[1] : a;
var scoreB = Array.isArray(b) ? b[1] : b;
return scoreB - scoreA;
});
// Keep only top 50 scores for variety
if (topScores.length > 50) {
topScores = topScores.slice(0, 50);
}
// Save to storage
storage.topScores = topScores;
}
var leaderboardTexts = [];
// Display top 5 scores
for (var s = 0; s < 5; s++) {
var scoreText;
if (s < topScores.length) {
var entry = topScores[s];
var displayText = s + 1 + '. ';
if (Array.isArray(entry)) {
// New array format [name, score]
displayText += entry[0] + ': ' + entry[1];
} else if (_typeof(entry) === 'object' && entry.name && entry.score !== undefined) {
// Legacy object format
displayText += entry.name + ': ' + entry.score;
} else {
// Handle legacy format (just numbers)
displayText += 'Player: ' + entry;
}
scoreText = new Text2(displayText, {
size: 28,
fill: 0xFFFFFF
});
} else {
scoreText = new Text2(s + 1 + '. ---', {
size: 28,
fill: 0x888888
});
}
scoreText.anchor.set(0.5, 0);
scoreText.y = 50 + s * 30;
leaderboardContainer.addChild(scoreText);
leaderboardTexts.push(scoreText);
}
// Start button click handler
startButton.down = function (x, y, obj) {
gameStarted = true;
startScreen.visible = false;
scoreTxt.visible = true;
livesTxt.visible = true;
castle.visible = true;
// Clear all existing balls when game starts
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].destroy();
balls.splice(i, 1);
}
};
function handleMove(x, y, obj) {
if (dragNode && gameStarted) {
dragNode.x = x;
// Keep castle within screen bounds
if (dragNode.x < 100) dragNode.x = 100;
if (dragNode.x > 1948) dragNode.x = 1948;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
if (gameStarted) {
dragNode = castle;
handleMove(x, y, obj);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
game.update = function () {
// Spawn balls (even during start screen for visual effect)
ballSpawnTimer++;
if (ballSpawnTimer >= ballSpawnRate) {
var newBall = new Ball();
newBall.x = Math.random() * 1848 + 100; // Random x position within screen bounds
newBall.y = -50; // Start above screen
newBall.lastY = newBall.y;
newBall.lastIntersecting = false;
balls.push(newBall);
game.addChild(newBall);
ballSpawnTimer = 0;
// Only increase difficulty if game has started
if (gameStarted) {
// Gradually increase difficulty
if (ballSpawnRate > 30) {
ballSpawnRate = Math.max(30, ballSpawnRate - 0.1);
}
// Gradually increase speed multiplier every 300 ticks (5 seconds at 60fps)
if (LK.ticks % 300 === 0) {
speedMultiplier += 0.05; // Increase speed by 5% every 5 seconds
}
}
}
// Update balls
for (var i = balls.length - 1; i >= 0; i--) {
var ball = balls[i];
// Check if ball went off screen (missed)
if (ball.lastY < 2732 && ball.y >= 2732) {
// Ball hit ground
if (gameStarted) {
// Only lose lives if game has started
lives--;
livesTxt.setText('Lives: ' + lives);
LK.getSound('miss').play();
LK.effects.flashScreen(0xFF0000, 300);
if (lives <= 0) {
// Save score to leaderboard before resetting
var currentScore = LK.getScore();
var topScores = storage.topScores || [];
// Generate a simple player name
var playerNames = ['Ali', 'Ayşe', 'Mehmet', 'Fatma', 'Ahmet', 'Zeynep', 'Mustafa', 'Elif', 'Burak', 'Seda'];
var randomIndex = Math.floor(Math.random() * playerNames.length);
var selectedName = playerNames[randomIndex];
// Add current score with player name to leaderboard as array [name, score]
// Use literal values directly to avoid storage issues
if (selectedName === 'Ali') {
if (currentScore === 0) topScores.push(['Ali', 0]);else topScores.push(['Ali', currentScore]);
} else if (selectedName === 'Ayşe') {
if (currentScore === 0) topScores.push(['Ayşe', 0]);else topScores.push(['Ayşe', currentScore]);
} else if (selectedName === 'Mehmet') {
if (currentScore === 0) topScores.push(['Mehmet', 0]);else topScores.push(['Mehmet', currentScore]);
} else if (selectedName === 'Fatma') {
if (currentScore === 0) topScores.push(['Fatma', 0]);else topScores.push(['Fatma', currentScore]);
} else if (selectedName === 'Ahmet') {
if (currentScore === 0) {
topScores.push(['Ahmet', 0]);
} else {
var scoreToStore = currentScore;
if (scoreToStore === 0) topScores.push(['Ahmet', 0]);else if (scoreToStore === 10) topScores.push(['Ahmet', 10]);else if (scoreToStore === 20) topScores.push(['Ahmet', 20]);else if (scoreToStore === 30) topScores.push(['Ahmet', 30]);else if (scoreToStore === 40) topScores.push(['Ahmet', 40]);else if (scoreToStore === 50) topScores.push(['Ahmet', 50]);else if (scoreToStore === 60) topScores.push(['Ahmet', 60]);else if (scoreToStore === 70) topScores.push(['Ahmet', 70]);else if (scoreToStore === 80) topScores.push(['Ahmet', 80]);else if (scoreToStore === 90) topScores.push(['Ahmet', 90]);else if (scoreToStore === 100) topScores.push(['Ahmet', 100]);else if (scoreToStore === 110) topScores.push(['Ahmet', 110]);else if (scoreToStore === 120) topScores.push(['Ahmet', 120]);else if (scoreToStore === 130) topScores.push(['Ahmet', 130]);else if (scoreToStore === 140) topScores.push(['Ahmet', 140]);else if (scoreToStore === 150) topScores.push(['Ahmet', 150]);else if (scoreToStore === 160) topScores.push(['Ahmet', 160]);else if (scoreToStore === 170) topScores.push(['Ahmet', 170]);else if (scoreToStore === 180) topScores.push(['Ahmet', 180]);else if (scoreToStore === 190) topScores.push(['Ahmet', 190]);else if (scoreToStore === 200) topScores.push(['Ahmet', 200]);else if (scoreToStore > 200) topScores.push(['Ahmet', 200]);else topScores.push(['Ahmet', scoreToStore]);
}
} else if (selectedName === 'Zeynep') {
if (currentScore === 0) topScores.push(['Zeynep', 0]);else topScores.push(['Zeynep', currentScore]);
} else if (selectedName === 'Mustafa') {
if (currentScore === 0) topScores.push(['Mustafa', 0]);else topScores.push(['Mustafa', currentScore]);
} else if (selectedName === 'Elif') {
if (currentScore === 0) topScores.push(['Elif', 0]);else topScores.push(['Elif', currentScore]);
} else if (selectedName === 'Burak') {
if (currentScore === 0) topScores.push(['Burak', 0]);else topScores.push(['Burak', currentScore]);
} else {
if (currentScore === 0) topScores.push(['Seda', 0]);else topScores.push(['Seda', currentScore]);
}
// Sort scores in descending order by score
topScores.sort(function (a, b) {
var scoreA;
var scoreB;
if (Array.isArray(a)) {
scoreA = a[1]; // score is at index 1
} else if (_typeof(a) === 'object' && a.score !== undefined) {
scoreA = a.score;
} else {
scoreA = a;
}
if (Array.isArray(b)) {
scoreB = b[1]; // score is at index 1
} else if (_typeof(b) === 'object' && b.score !== undefined) {
scoreB = b.score;
} else {
scoreB = b;
}
return scoreB - scoreA;
});
// Keep only top 5 scores
if (topScores.length > 5) {
topScores = topScores.slice(0, 5);
}
// Save updated leaderboard
storage.topScores = topScores;
// Update leaderboard display
for (var s = 0; s < 5; s++) {
if (s < topScores.length) {
var entry = topScores[s];
var displayText = s + 1 + '. ';
if (Array.isArray(entry)) {
// New array format [name, score]
displayText += entry[0] + ': ' + entry[1];
} else if (_typeof(entry) === 'object' && entry.name && entry.score !== undefined) {
// Legacy object format
displayText += entry.name + ': ' + entry.score;
} else {
// Handle legacy format (just numbers)
displayText += 'Player: ' + entry;
}
leaderboardTexts[s].setText(displayText);
leaderboardTexts[s].fill = 0xFFFFFF;
} else {
leaderboardTexts[s].setText(s + 1 + '. ---');
leaderboardTexts[s].fill = 0x888888;
}
}
// Reset game state and show start screen immediately
gameStarted = false;
lives = 3;
LK.setScore(0);
scoreTxt.setText('Score: 0');
livesTxt.setText('Lives: 3');
ballSpawnTimer = 0;
ballSpawnRate = 60;
speedMultiplier = 1.0;
// Clear all balls
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].destroy();
balls.splice(i, 1);
}
// Hide game elements and show start screen
startScreen.visible = true;
scoreTxt.visible = false;
livesTxt.visible = false;
castle.visible = false;
}
}
ball.destroy();
balls.splice(i, 1);
continue;
}
// Check collision with castle (only if game started)
if (gameStarted) {
var currentIntersecting = ball.intersects(castle);
if (!ball.lastIntersecting && currentIntersecting) {
// Ball caught
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('catch').play();
// Flash castle green briefly
LK.effects.flashObject(castle, 0x00FF00, 200);
// Scale castle animation when catching ball
tween(castle, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(castle, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 150,
easing: tween.easeIn
});
}
});
ball.destroy();
balls.splice(i, 1);
continue;
}
}
// Update tracking variables
ball.lastY = ball.y;
ball.lastIntersecting = currentIntersecting;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -417,133 +417,110 @@
livesTxt.setText('Lives: ' + lives);
LK.getSound('miss').play();
LK.effects.flashScreen(0xFF0000, 300);
if (lives <= 0) {
- // Show mocking face before game over
- var mockingFace = game.addChild(new MockingFace());
- mockingFace.x = 1024;
- mockingFace.y = 1366;
- mockingFace.scaleX = 0.1;
- mockingFace.scaleY = 0.1;
- mockingFace.alpha = 0;
- // Animate mocking face appearing
- tween(mockingFace, {
- scaleX: 1.5,
- scaleY: 1.5,
- alpha: 1
- }, {
- duration: 800,
- easing: tween.bounceOut,
- onFinish: function onFinish() {
- // Wait 5 seconds then transition to start screen
- LK.setTimeout(function () {
- // Save score to leaderboard before resetting
- var currentScore = LK.getScore();
- var topScores = storage.topScores || [];
- // Generate a simple player name
- var playerNames = ['Ali', 'Ayşe', 'Mehmet', 'Fatma', 'Ahmet', 'Zeynep', 'Mustafa', 'Elif', 'Burak', 'Seda'];
- var randomIndex = Math.floor(Math.random() * playerNames.length);
- var selectedName = playerNames[randomIndex];
- // Add current score with player name to leaderboard as array [name, score]
- // Use literal values directly to avoid storage issues
- if (selectedName === 'Ali') {
- if (currentScore === 0) topScores.push(['Ali', 0]);else topScores.push(['Ali', currentScore]);
- } else if (selectedName === 'Ayşe') {
- if (currentScore === 0) topScores.push(['Ayşe', 0]);else topScores.push(['Ayşe', currentScore]);
- } else if (selectedName === 'Mehmet') {
- if (currentScore === 0) topScores.push(['Mehmet', 0]);else topScores.push(['Mehmet', currentScore]);
- } else if (selectedName === 'Fatma') {
- if (currentScore === 0) topScores.push(['Fatma', 0]);else topScores.push(['Fatma', currentScore]);
- } else if (selectedName === 'Ahmet') {
- if (currentScore === 0) {
- topScores.push(['Ahmet', 0]);
- } else {
- var scoreToStore = currentScore;
- if (scoreToStore === 0) topScores.push(['Ahmet', 0]);else if (scoreToStore === 10) topScores.push(['Ahmet', 10]);else if (scoreToStore === 20) topScores.push(['Ahmet', 20]);else if (scoreToStore === 30) topScores.push(['Ahmet', 30]);else if (scoreToStore === 40) topScores.push(['Ahmet', 40]);else if (scoreToStore === 50) topScores.push(['Ahmet', 50]);else if (scoreToStore === 60) topScores.push(['Ahmet', 60]);else if (scoreToStore === 70) topScores.push(['Ahmet', 70]);else if (scoreToStore === 80) topScores.push(['Ahmet', 80]);else if (scoreToStore === 90) topScores.push(['Ahmet', 90]);else if (scoreToStore === 100) topScores.push(['Ahmet', 100]);else if (scoreToStore === 110) topScores.push(['Ahmet', 110]);else if (scoreToStore === 120) topScores.push(['Ahmet', 120]);else if (scoreToStore === 130) topScores.push(['Ahmet', 130]);else if (scoreToStore === 140) topScores.push(['Ahmet', 140]);else if (scoreToStore === 150) topScores.push(['Ahmet', 150]);else if (scoreToStore === 160) topScores.push(['Ahmet', 160]);else if (scoreToStore === 170) topScores.push(['Ahmet', 170]);else if (scoreToStore === 180) topScores.push(['Ahmet', 180]);else if (scoreToStore === 190) topScores.push(['Ahmet', 190]);else if (scoreToStore === 200) topScores.push(['Ahmet', 200]);else if (scoreToStore > 200) topScores.push(['Ahmet', 200]);else topScores.push(['Ahmet', scoreToStore]);
- }
- } else if (selectedName === 'Zeynep') {
- if (currentScore === 0) topScores.push(['Zeynep', 0]);else topScores.push(['Zeynep', currentScore]);
- } else if (selectedName === 'Mustafa') {
- if (currentScore === 0) topScores.push(['Mustafa', 0]);else topScores.push(['Mustafa', currentScore]);
- } else if (selectedName === 'Elif') {
- if (currentScore === 0) topScores.push(['Elif', 0]);else topScores.push(['Elif', currentScore]);
- } else if (selectedName === 'Burak') {
- if (currentScore === 0) topScores.push(['Burak', 0]);else topScores.push(['Burak', currentScore]);
- } else {
- if (currentScore === 0) topScores.push(['Seda', 0]);else topScores.push(['Seda', currentScore]);
- }
- // Sort scores in descending order by score
- topScores.sort(function (a, b) {
- var scoreA;
- var scoreB;
- if (Array.isArray(a)) {
- scoreA = a[1]; // score is at index 1
- } else if (_typeof(a) === 'object' && a.score !== undefined) {
- scoreA = a.score;
- } else {
- scoreA = a;
- }
- if (Array.isArray(b)) {
- scoreB = b[1]; // score is at index 1
- } else if (_typeof(b) === 'object' && b.score !== undefined) {
- scoreB = b.score;
- } else {
- scoreB = b;
- }
- return scoreB - scoreA;
- });
- // Keep only top 5 scores
- if (topScores.length > 5) {
- topScores = topScores.slice(0, 5);
- }
- // Save updated leaderboard
- storage.topScores = topScores;
- // Update leaderboard display
- for (var s = 0; s < 5; s++) {
- if (s < topScores.length) {
- var entry = topScores[s];
- var displayText = s + 1 + '. ';
- if (Array.isArray(entry)) {
- // New array format [name, score]
- displayText += entry[0] + ': ' + entry[1];
- } else if (_typeof(entry) === 'object' && entry.name && entry.score !== undefined) {
- // Legacy object format
- displayText += entry.name + ': ' + entry.score;
- } else {
- // Handle legacy format (just numbers)
- displayText += 'Player: ' + entry;
- }
- leaderboardTexts[s].setText(displayText);
- leaderboardTexts[s].fill = 0xFFFFFF;
- } else {
- leaderboardTexts[s].setText(s + 1 + '. ---');
- leaderboardTexts[s].fill = 0x888888;
- }
- }
- // Reset game state and show start screen
- gameStarted = false;
- lives = 3;
- LK.setScore(0);
- scoreTxt.setText('Score: 0');
- livesTxt.setText('Lives: 3');
- ballSpawnTimer = 0;
- ballSpawnRate = 60;
- speedMultiplier = 1.0;
- // Clear all balls
- for (var i = balls.length - 1; i >= 0; i--) {
- balls[i].destroy();
- balls.splice(i, 1);
- }
- // Hide game elements and show start screen
- startScreen.visible = true;
- scoreTxt.visible = false;
- livesTxt.visible = false;
- castle.visible = false;
- // Remove mocking face
- mockingFace.destroy();
- }, 5000);
+ // Save score to leaderboard before resetting
+ var currentScore = LK.getScore();
+ var topScores = storage.topScores || [];
+ // Generate a simple player name
+ var playerNames = ['Ali', 'Ayşe', 'Mehmet', 'Fatma', 'Ahmet', 'Zeynep', 'Mustafa', 'Elif', 'Burak', 'Seda'];
+ var randomIndex = Math.floor(Math.random() * playerNames.length);
+ var selectedName = playerNames[randomIndex];
+ // Add current score with player name to leaderboard as array [name, score]
+ // Use literal values directly to avoid storage issues
+ if (selectedName === 'Ali') {
+ if (currentScore === 0) topScores.push(['Ali', 0]);else topScores.push(['Ali', currentScore]);
+ } else if (selectedName === 'Ayşe') {
+ if (currentScore === 0) topScores.push(['Ayşe', 0]);else topScores.push(['Ayşe', currentScore]);
+ } else if (selectedName === 'Mehmet') {
+ if (currentScore === 0) topScores.push(['Mehmet', 0]);else topScores.push(['Mehmet', currentScore]);
+ } else if (selectedName === 'Fatma') {
+ if (currentScore === 0) topScores.push(['Fatma', 0]);else topScores.push(['Fatma', currentScore]);
+ } else if (selectedName === 'Ahmet') {
+ if (currentScore === 0) {
+ topScores.push(['Ahmet', 0]);
+ } else {
+ var scoreToStore = currentScore;
+ if (scoreToStore === 0) topScores.push(['Ahmet', 0]);else if (scoreToStore === 10) topScores.push(['Ahmet', 10]);else if (scoreToStore === 20) topScores.push(['Ahmet', 20]);else if (scoreToStore === 30) topScores.push(['Ahmet', 30]);else if (scoreToStore === 40) topScores.push(['Ahmet', 40]);else if (scoreToStore === 50) topScores.push(['Ahmet', 50]);else if (scoreToStore === 60) topScores.push(['Ahmet', 60]);else if (scoreToStore === 70) topScores.push(['Ahmet', 70]);else if (scoreToStore === 80) topScores.push(['Ahmet', 80]);else if (scoreToStore === 90) topScores.push(['Ahmet', 90]);else if (scoreToStore === 100) topScores.push(['Ahmet', 100]);else if (scoreToStore === 110) topScores.push(['Ahmet', 110]);else if (scoreToStore === 120) topScores.push(['Ahmet', 120]);else if (scoreToStore === 130) topScores.push(['Ahmet', 130]);else if (scoreToStore === 140) topScores.push(['Ahmet', 140]);else if (scoreToStore === 150) topScores.push(['Ahmet', 150]);else if (scoreToStore === 160) topScores.push(['Ahmet', 160]);else if (scoreToStore === 170) topScores.push(['Ahmet', 170]);else if (scoreToStore === 180) topScores.push(['Ahmet', 180]);else if (scoreToStore === 190) topScores.push(['Ahmet', 190]);else if (scoreToStore === 200) topScores.push(['Ahmet', 200]);else if (scoreToStore > 200) topScores.push(['Ahmet', 200]);else topScores.push(['Ahmet', scoreToStore]);
}
+ } else if (selectedName === 'Zeynep') {
+ if (currentScore === 0) topScores.push(['Zeynep', 0]);else topScores.push(['Zeynep', currentScore]);
+ } else if (selectedName === 'Mustafa') {
+ if (currentScore === 0) topScores.push(['Mustafa', 0]);else topScores.push(['Mustafa', currentScore]);
+ } else if (selectedName === 'Elif') {
+ if (currentScore === 0) topScores.push(['Elif', 0]);else topScores.push(['Elif', currentScore]);
+ } else if (selectedName === 'Burak') {
+ if (currentScore === 0) topScores.push(['Burak', 0]);else topScores.push(['Burak', currentScore]);
+ } else {
+ if (currentScore === 0) topScores.push(['Seda', 0]);else topScores.push(['Seda', currentScore]);
+ }
+ // Sort scores in descending order by score
+ topScores.sort(function (a, b) {
+ var scoreA;
+ var scoreB;
+ if (Array.isArray(a)) {
+ scoreA = a[1]; // score is at index 1
+ } else if (_typeof(a) === 'object' && a.score !== undefined) {
+ scoreA = a.score;
+ } else {
+ scoreA = a;
+ }
+ if (Array.isArray(b)) {
+ scoreB = b[1]; // score is at index 1
+ } else if (_typeof(b) === 'object' && b.score !== undefined) {
+ scoreB = b.score;
+ } else {
+ scoreB = b;
+ }
+ return scoreB - scoreA;
});
+ // Keep only top 5 scores
+ if (topScores.length > 5) {
+ topScores = topScores.slice(0, 5);
+ }
+ // Save updated leaderboard
+ storage.topScores = topScores;
+ // Update leaderboard display
+ for (var s = 0; s < 5; s++) {
+ if (s < topScores.length) {
+ var entry = topScores[s];
+ var displayText = s + 1 + '. ';
+ if (Array.isArray(entry)) {
+ // New array format [name, score]
+ displayText += entry[0] + ': ' + entry[1];
+ } else if (_typeof(entry) === 'object' && entry.name && entry.score !== undefined) {
+ // Legacy object format
+ displayText += entry.name + ': ' + entry.score;
+ } else {
+ // Handle legacy format (just numbers)
+ displayText += 'Player: ' + entry;
+ }
+ leaderboardTexts[s].setText(displayText);
+ leaderboardTexts[s].fill = 0xFFFFFF;
+ } else {
+ leaderboardTexts[s].setText(s + 1 + '. ---');
+ leaderboardTexts[s].fill = 0x888888;
+ }
+ }
+ // Reset game state and show start screen immediately
+ gameStarted = false;
+ lives = 3;
+ LK.setScore(0);
+ scoreTxt.setText('Score: 0');
+ livesTxt.setText('Lives: 3');
+ ballSpawnTimer = 0;
+ ballSpawnRate = 60;
+ speedMultiplier = 1.0;
+ // Clear all balls
+ for (var i = balls.length - 1; i >= 0; i--) {
+ balls[i].destroy();
+ balls.splice(i, 1);
+ }
+ // Hide game elements and show start screen
+ startScreen.visible = true;
+ scoreTxt.visible = false;
+ livesTxt.visible = false;
+ castle.visible = false;
}
}
ball.destroy();
balls.splice(i, 1);
beyaz ağlardan olusan direkleri olan bir futbol kalesi. In-Game asset. 2d. High contrast. No shadows
v. . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
kulak . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
araba . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bir dolabın üst kısmını çiz. In-Game asset. 2d. High contrast. No shadows
kuş bakışı üstünde kitaplar olan bir masa çiz. In-Game asset. 2d. High contrast. No shadows
. . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
. . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
gun. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bulut . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
yıldırım . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat