User prompt
Karakterler seçtiğimiz takımın logosuna göre olsun
User prompt
Kaleye top yandan girince gol sayılmasın
User prompt
Kalelere direkler ekle ve top kaleye yandan girince gol olmasın.Sahaya çizgiler ekle.topu biraz daha büyült
User prompt
İkinci oyuncuyu düzelt çünkü hareket edince kayboluyor
User prompt
Biraz daha hızlı
User prompt
Karakterler biraz daha büyük olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Futbol Pro: LaLiga vs Süper Lig
Initial prompt
Bana bir futbol oyunu yap.girişe iki seçenek koy.seçeneklerden biri iki kişi oyna,biride yapay zekayla oyna olsun.iki kişi oynaya bastığında oyunu iki kişi oynayabilelim,yapay zekayla oynaya bastığında yapay zekayla oynayabilelim.sonrasında takım seçelim.ama oradada iki seçenek olsun seçeneklerden biri LaLiga diğeri süperlig olsun.Süperlig takımları:Galatasaray,Fenerbahçe,Beşiktaş,Trabzonspor,Başakşehir olsun.LaLiga takımları;RealMadrid ve Barcelona olsun.kaleler orta boyutta olsun karakterler orta boyutta olsun saha büyük olsun.skorboard da seçtiğimiz takımlara göre olsun
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.friction = 0.98;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityX *= self.friction;
self.velocityY *= self.friction;
// Boundary checks
if (self.x < 20) {
self.x = 20;
self.velocityX = -self.velocityX * 0.7;
}
if (self.x > 2028) {
self.x = 2028;
self.velocityX = -self.velocityX * 0.7;
}
if (self.y < 20) {
self.y = 20;
self.velocityY = -self.velocityY * 0.7;
}
if (self.y > 2712) {
self.y = 2712;
self.velocityY = -self.velocityY * 0.7;
}
};
self.kick = function (forceX, forceY) {
self.velocityX += forceX;
self.velocityY += forceY;
LK.getSound('kick').play();
};
return self;
});
var MenuButton = Container.expand(function (text, color) {
var self = Container.call(this);
var bg = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
});
if (color) {
bg.tint = color;
}
var buttonText = new Text2(text, {
size: 40,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
tween(self, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
};
self.up = function (x, y, obj) {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
if (self.onPress) {
self.onPress();
}
};
return self;
});
var Player = Container.expand(function (color) {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
if (color) {
playerGraphics.tint = color;
}
self.isAI = false;
self.targetX = 0;
self.targetY = 0;
self.update = function () {
if (self.isAI && ball) {
// Simple AI behavior
var dx = ball.x - self.x;
var dy = ball.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 100) {
self.x += dx / distance * 2;
self.y += dy / distance * 2;
}
// AI kicks ball towards goal
if (distance < 80) {
var goalX = 1024;
var goalY = self.y < 1366 ? 2650 : 82;
var ballToGoalX = goalX - ball.x;
var ballToGoalY = goalY - ball.y;
ball.kick(ballToGoalX * 0.02, ballToGoalY * 0.02);
}
}
};
self.down = function (x, y, obj) {
if (!self.isAI) {
self.targetX = x;
self.targetY = y;
}
};
self.move = function (x, y, obj) {
if (!self.isAI && self.targetX !== undefined) {
self.x = x;
self.y = y;
// Kick ball if close
if (ball) {
var dx = ball.x - self.x;
var dy = ball.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
ball.kick(dx * 0.3, dy * 0.3);
}
}
}
};
return self;
});
var TeamButton = Container.expand(function (teamName, color) {
var self = Container.call(this);
var bg = self.attachAsset('teamButton', {
anchorX: 0.5,
anchorY: 0.5
});
if (color) {
bg.tint = color;
}
var buttonText = new Text2(teamName, {
size: 32,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.teamName = teamName;
self.teamColor = color;
self.down = function (x, y, obj) {
tween(self, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
};
self.up = function (x, y, obj) {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
if (self.onPress) {
self.onPress();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x004400
});
/****
* Game Code
****/
// Game state variables
var gameState = 'mainMenu'; // mainMenu, leagueSelect, teamSelect, playing
var gameMode = ''; // 'twoPlayer' or 'vsAI'
var selectedLeague = '';
var team1Name = '';
var team2Name = '';
var team1Color = 0xFF0000;
var team2Color = 0x0000FF;
var score1 = 0;
var score2 = 0;
// Game objects
var ball = null;
var players = [];
var field = null;
var goals = [];
var scoreboard = null;
// Team data
var superLigTeams = [{
name: 'Galatasaray',
color: 0xFFFF00
}, {
name: 'Fenerbahçe',
color: 0x000080
}, {
name: 'Beşiktaş',
color: 0x000000
}, {
name: 'Trabzonspor',
color: 0x800000
}, {
name: 'Başakşehir',
color: 0xFF8000
}];
var laLigaTeams = [{
name: 'Real Madrid',
color: 0xFFFFFF
}, {
name: 'Barcelona',
color: 0x004A9F
}];
// UI elements
var menuContainer = new Container();
var leagueContainer = new Container();
var teamContainer = new Container();
function showMainMenu() {
gameState = 'mainMenu';
clearGame();
var title = new Text2('Futbol Pro', {
size: 80,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 800;
menuContainer.addChild(title);
var subtitle = new Text2('LaLiga vs Süper Lig', {
size: 50,
fill: 0xCCCCCC
});
subtitle.anchor.set(0.5, 0.5);
subtitle.x = 1024;
subtitle.y = 900;
menuContainer.addChild(subtitle);
var twoPlayerBtn = new MenuButton('İki Kişi Oyna', 0x0066CC);
twoPlayerBtn.x = 1024;
twoPlayerBtn.y = 1200;
twoPlayerBtn.onPress = function () {
gameMode = 'twoPlayer';
showLeagueSelect();
};
menuContainer.addChild(twoPlayerBtn);
var vsAIBtn = new MenuButton('Yapay Zeka ile Oyna', 0x009900);
vsAIBtn.x = 1024;
vsAIBtn.y = 1350;
vsAIBtn.onPress = function () {
gameMode = 'vsAI';
showLeagueSelect();
};
menuContainer.addChild(vsAIBtn);
game.addChild(menuContainer);
}
function showLeagueSelect() {
gameState = 'leagueSelect';
menuContainer.removeChildren();
var title = new Text2('Liga Seçin', {
size: 60,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 800;
leagueContainer.addChild(title);
var superLigBtn = new MenuButton('Süper Lig', 0xCC0000);
superLigBtn.x = 1024;
superLigBtn.y = 1100;
superLigBtn.onPress = function () {
selectedLeague = 'superlig';
showTeamSelect();
};
leagueContainer.addChild(superLigBtn);
var laLigaBtn = new MenuButton('LaLiga', 0x0066CC);
laLigaBtn.x = 1024;
laLigaBtn.y = 1250;
laLigaBtn.onPress = function () {
selectedLeague = 'laliga';
showTeamSelect();
};
leagueContainer.addChild(laLigaBtn);
game.addChild(leagueContainer);
}
function showTeamSelect() {
gameState = 'teamSelect';
leagueContainer.removeChildren();
var teams = selectedLeague === 'superlig' ? superLigTeams : laLigaTeams;
var selectedTeams = [];
var title = new Text2('Takım Seçin', {
size: 60,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 400;
teamContainer.addChild(title);
var startY = 600;
for (var i = 0; i < teams.length; i++) {
var teamBtn = new TeamButton(teams[i].name, teams[i].color);
teamBtn.x = 1024;
teamBtn.y = startY + i * 120;
teamBtn.onPress = function (team) {
return function () {
selectedTeams.push(team);
if (selectedTeams.length === 1) {
team1Name = team.name;
team1Color = team.color;
if (gameMode === 'vsAI') {
// Auto-select second team for AI
var aiTeam = teams[Math.floor(Math.random() * teams.length)];
team2Name = aiTeam.name + ' (AI)';
team2Color = aiTeam.color;
startGame();
} else {
title.setText('İkinci Takımı Seçin');
}
} else if (selectedTeams.length === 2) {
team2Name = team.name;
team2Color = team.color;
startGame();
}
};
}(teams[i]);
teamContainer.addChild(teamBtn);
}
game.addChild(teamContainer);
}
function startGame() {
gameState = 'playing';
teamContainer.removeChildren();
// Create field
field = game.attachAsset('field', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
// Create goals
var topGoal = game.attachAsset('goal', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 166
});
var bottomGoal = game.attachAsset('goal', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2566
});
goals.push(topGoal, bottomGoal);
// Create center circle
var centerCircle = game.attachAsset('centerCircle', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
centerCircle.alpha = 0.3;
// Create ball
ball = new Ball();
ball.x = 1024;
ball.y = 1366;
game.addChild(ball);
// Create players
var player1 = new Player(team1Color);
player1.x = 1024;
player1.y = 1800;
players.push(player1);
game.addChild(player1);
var player2 = new Player(team2Color);
player2.x = 1024;
player2.y = 900;
if (gameMode === 'vsAI') {
player2.isAI = true;
}
players.push(player2);
game.addChild(player2);
// Create scoreboard
createScoreboard();
score1 = 0;
score2 = 0;
}
function createScoreboard() {
var scoreText = new Text2(team1Name + ' 0 - 0 ' + team2Name, {
size: 40,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreboard = scoreText;
updateScoreboard();
}
function updateScoreboard() {
if (scoreboard) {
scoreboard.setText(team1Name + ' ' + score1 + ' - ' + score2 + ' ' + team2Name);
}
}
function checkGoal() {
if (!ball) return;
// Check top goal (team 1 scores)
if (ball.y < 200 && ball.x > 824 && ball.x < 1224) {
score1++;
LK.getSound('goal').play();
resetBallPosition();
updateScoreboard();
}
// Check bottom goal (team 2 scores)
if (ball.y > 2532 && ball.x > 824 && ball.x < 1224) {
score2++;
LK.getSound('goal').play();
resetBallPosition();
updateScoreboard();
}
}
function resetBallPosition() {
if (ball) {
ball.x = 1024;
ball.y = 1366;
ball.velocityX = 0;
ball.velocityY = 0;
}
}
function clearGame() {
if (ball) {
ball.destroy();
ball = null;
}
for (var i = 0; i < players.length; i++) {
players[i].destroy();
}
players = [];
if (field) {
field.destroy();
field = null;
}
for (var i = 0; i < goals.length; i++) {
goals[i].destroy();
}
goals = [];
if (scoreboard) {
scoreboard.destroy();
scoreboard = null;
}
}
game.update = function () {
if (gameState === 'playing') {
checkGoal();
}
};
// Initialize game
showMainMenu(); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,466 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Ball = Container.expand(function () {
+ var self = Container.call(this);
+ var ballGraphics = self.attachAsset('ball', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocityX = 0;
+ self.velocityY = 0;
+ self.friction = 0.98;
+ self.update = function () {
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ self.velocityX *= self.friction;
+ self.velocityY *= self.friction;
+ // Boundary checks
+ if (self.x < 20) {
+ self.x = 20;
+ self.velocityX = -self.velocityX * 0.7;
+ }
+ if (self.x > 2028) {
+ self.x = 2028;
+ self.velocityX = -self.velocityX * 0.7;
+ }
+ if (self.y < 20) {
+ self.y = 20;
+ self.velocityY = -self.velocityY * 0.7;
+ }
+ if (self.y > 2712) {
+ self.y = 2712;
+ self.velocityY = -self.velocityY * 0.7;
+ }
+ };
+ self.kick = function (forceX, forceY) {
+ self.velocityX += forceX;
+ self.velocityY += forceY;
+ LK.getSound('kick').play();
+ };
+ return self;
+});
+var MenuButton = Container.expand(function (text, color) {
+ var self = Container.call(this);
+ var bg = self.attachAsset('menuButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (color) {
+ bg.tint = color;
+ }
+ var buttonText = new Text2(text, {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.down = function (x, y, obj) {
+ tween(self, {
+ scaleX: 0.95,
+ scaleY: 0.95
+ }, {
+ duration: 100
+ });
+ };
+ self.up = function (x, y, obj) {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ if (self.onPress) {
+ self.onPress();
+ }
+ };
+ return self;
+});
+var Player = Container.expand(function (color) {
+ var self = Container.call(this);
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (color) {
+ playerGraphics.tint = color;
+ }
+ self.isAI = false;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.update = function () {
+ if (self.isAI && ball) {
+ // Simple AI behavior
+ var dx = ball.x - self.x;
+ var dy = ball.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 100) {
+ self.x += dx / distance * 2;
+ self.y += dy / distance * 2;
+ }
+ // AI kicks ball towards goal
+ if (distance < 80) {
+ var goalX = 1024;
+ var goalY = self.y < 1366 ? 2650 : 82;
+ var ballToGoalX = goalX - ball.x;
+ var ballToGoalY = goalY - ball.y;
+ ball.kick(ballToGoalX * 0.02, ballToGoalY * 0.02);
+ }
+ }
+ };
+ self.down = function (x, y, obj) {
+ if (!self.isAI) {
+ self.targetX = x;
+ self.targetY = y;
+ }
+ };
+ self.move = function (x, y, obj) {
+ if (!self.isAI && self.targetX !== undefined) {
+ self.x = x;
+ self.y = y;
+ // Kick ball if close
+ if (ball) {
+ var dx = ball.x - self.x;
+ var dy = ball.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 60) {
+ ball.kick(dx * 0.3, dy * 0.3);
+ }
+ }
+ }
+ };
+ return self;
+});
+var TeamButton = Container.expand(function (teamName, color) {
+ var self = Container.call(this);
+ var bg = self.attachAsset('teamButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (color) {
+ bg.tint = color;
+ }
+ var buttonText = new Text2(teamName, {
+ size: 32,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.teamName = teamName;
+ self.teamColor = color;
+ self.down = function (x, y, obj) {
+ tween(self, {
+ scaleX: 0.95,
+ scaleY: 0.95
+ }, {
+ duration: 100
+ });
+ };
+ self.up = function (x, y, obj) {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ if (self.onPress) {
+ self.onPress();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x004400
+});
+
+/****
+* Game Code
+****/
+// Game state variables
+var gameState = 'mainMenu'; // mainMenu, leagueSelect, teamSelect, playing
+var gameMode = ''; // 'twoPlayer' or 'vsAI'
+var selectedLeague = '';
+var team1Name = '';
+var team2Name = '';
+var team1Color = 0xFF0000;
+var team2Color = 0x0000FF;
+var score1 = 0;
+var score2 = 0;
+// Game objects
+var ball = null;
+var players = [];
+var field = null;
+var goals = [];
+var scoreboard = null;
+// Team data
+var superLigTeams = [{
+ name: 'Galatasaray',
+ color: 0xFFFF00
+}, {
+ name: 'Fenerbahçe',
+ color: 0x000080
+}, {
+ name: 'Beşiktaş',
+ color: 0x000000
+}, {
+ name: 'Trabzonspor',
+ color: 0x800000
+}, {
+ name: 'Başakşehir',
+ color: 0xFF8000
+}];
+var laLigaTeams = [{
+ name: 'Real Madrid',
+ color: 0xFFFFFF
+}, {
+ name: 'Barcelona',
+ color: 0x004A9F
+}];
+// UI elements
+var menuContainer = new Container();
+var leagueContainer = new Container();
+var teamContainer = new Container();
+function showMainMenu() {
+ gameState = 'mainMenu';
+ clearGame();
+ var title = new Text2('Futbol Pro', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ title.anchor.set(0.5, 0.5);
+ title.x = 1024;
+ title.y = 800;
+ menuContainer.addChild(title);
+ var subtitle = new Text2('LaLiga vs Süper Lig', {
+ size: 50,
+ fill: 0xCCCCCC
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.x = 1024;
+ subtitle.y = 900;
+ menuContainer.addChild(subtitle);
+ var twoPlayerBtn = new MenuButton('İki Kişi Oyna', 0x0066CC);
+ twoPlayerBtn.x = 1024;
+ twoPlayerBtn.y = 1200;
+ twoPlayerBtn.onPress = function () {
+ gameMode = 'twoPlayer';
+ showLeagueSelect();
+ };
+ menuContainer.addChild(twoPlayerBtn);
+ var vsAIBtn = new MenuButton('Yapay Zeka ile Oyna', 0x009900);
+ vsAIBtn.x = 1024;
+ vsAIBtn.y = 1350;
+ vsAIBtn.onPress = function () {
+ gameMode = 'vsAI';
+ showLeagueSelect();
+ };
+ menuContainer.addChild(vsAIBtn);
+ game.addChild(menuContainer);
+}
+function showLeagueSelect() {
+ gameState = 'leagueSelect';
+ menuContainer.removeChildren();
+ var title = new Text2('Liga Seçin', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ title.anchor.set(0.5, 0.5);
+ title.x = 1024;
+ title.y = 800;
+ leagueContainer.addChild(title);
+ var superLigBtn = new MenuButton('Süper Lig', 0xCC0000);
+ superLigBtn.x = 1024;
+ superLigBtn.y = 1100;
+ superLigBtn.onPress = function () {
+ selectedLeague = 'superlig';
+ showTeamSelect();
+ };
+ leagueContainer.addChild(superLigBtn);
+ var laLigaBtn = new MenuButton('LaLiga', 0x0066CC);
+ laLigaBtn.x = 1024;
+ laLigaBtn.y = 1250;
+ laLigaBtn.onPress = function () {
+ selectedLeague = 'laliga';
+ showTeamSelect();
+ };
+ leagueContainer.addChild(laLigaBtn);
+ game.addChild(leagueContainer);
+}
+function showTeamSelect() {
+ gameState = 'teamSelect';
+ leagueContainer.removeChildren();
+ var teams = selectedLeague === 'superlig' ? superLigTeams : laLigaTeams;
+ var selectedTeams = [];
+ var title = new Text2('Takım Seçin', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ title.anchor.set(0.5, 0.5);
+ title.x = 1024;
+ title.y = 400;
+ teamContainer.addChild(title);
+ var startY = 600;
+ for (var i = 0; i < teams.length; i++) {
+ var teamBtn = new TeamButton(teams[i].name, teams[i].color);
+ teamBtn.x = 1024;
+ teamBtn.y = startY + i * 120;
+ teamBtn.onPress = function (team) {
+ return function () {
+ selectedTeams.push(team);
+ if (selectedTeams.length === 1) {
+ team1Name = team.name;
+ team1Color = team.color;
+ if (gameMode === 'vsAI') {
+ // Auto-select second team for AI
+ var aiTeam = teams[Math.floor(Math.random() * teams.length)];
+ team2Name = aiTeam.name + ' (AI)';
+ team2Color = aiTeam.color;
+ startGame();
+ } else {
+ title.setText('İkinci Takımı Seçin');
+ }
+ } else if (selectedTeams.length === 2) {
+ team2Name = team.name;
+ team2Color = team.color;
+ startGame();
+ }
+ };
+ }(teams[i]);
+ teamContainer.addChild(teamBtn);
+ }
+ game.addChild(teamContainer);
+}
+function startGame() {
+ gameState = 'playing';
+ teamContainer.removeChildren();
+ // Create field
+ field = game.attachAsset('field', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366
+ });
+ // Create goals
+ var topGoal = game.attachAsset('goal', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 166
+ });
+ var bottomGoal = game.attachAsset('goal', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 2566
+ });
+ goals.push(topGoal, bottomGoal);
+ // Create center circle
+ var centerCircle = game.attachAsset('centerCircle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366
+ });
+ centerCircle.alpha = 0.3;
+ // Create ball
+ ball = new Ball();
+ ball.x = 1024;
+ ball.y = 1366;
+ game.addChild(ball);
+ // Create players
+ var player1 = new Player(team1Color);
+ player1.x = 1024;
+ player1.y = 1800;
+ players.push(player1);
+ game.addChild(player1);
+ var player2 = new Player(team2Color);
+ player2.x = 1024;
+ player2.y = 900;
+ if (gameMode === 'vsAI') {
+ player2.isAI = true;
+ }
+ players.push(player2);
+ game.addChild(player2);
+ // Create scoreboard
+ createScoreboard();
+ score1 = 0;
+ score2 = 0;
+}
+function createScoreboard() {
+ var scoreText = new Text2(team1Name + ' 0 - 0 ' + team2Name, {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ scoreText.anchor.set(0.5, 0);
+ LK.gui.top.addChild(scoreText);
+ scoreboard = scoreText;
+ updateScoreboard();
+}
+function updateScoreboard() {
+ if (scoreboard) {
+ scoreboard.setText(team1Name + ' ' + score1 + ' - ' + score2 + ' ' + team2Name);
+ }
+}
+function checkGoal() {
+ if (!ball) return;
+ // Check top goal (team 1 scores)
+ if (ball.y < 200 && ball.x > 824 && ball.x < 1224) {
+ score1++;
+ LK.getSound('goal').play();
+ resetBallPosition();
+ updateScoreboard();
+ }
+ // Check bottom goal (team 2 scores)
+ if (ball.y > 2532 && ball.x > 824 && ball.x < 1224) {
+ score2++;
+ LK.getSound('goal').play();
+ resetBallPosition();
+ updateScoreboard();
+ }
+}
+function resetBallPosition() {
+ if (ball) {
+ ball.x = 1024;
+ ball.y = 1366;
+ ball.velocityX = 0;
+ ball.velocityY = 0;
+ }
+}
+function clearGame() {
+ if (ball) {
+ ball.destroy();
+ ball = null;
+ }
+ for (var i = 0; i < players.length; i++) {
+ players[i].destroy();
+ }
+ players = [];
+ if (field) {
+ field.destroy();
+ field = null;
+ }
+ for (var i = 0; i < goals.length; i++) {
+ goals[i].destroy();
+ }
+ goals = [];
+ if (scoreboard) {
+ scoreboard.destroy();
+ scoreboard = null;
+ }
+}
+game.update = function () {
+ if (gameState === 'playing') {
+ checkGoal();
+ }
+};
+// Initialize game
+showMainMenu();
\ No newline at end of file