User prompt
Yapay zeka kaleye çok yavaş gidiyor biraz hızlandır
User prompt
Yapay zekanın hedefi gol atmak olsun
User prompt
Yapay zekanın hızını 10 yap ve yapay zeka oyuncuları zorlamasın
User prompt
Yapay zeka titriyor bunu düzelt
User prompt
Yapay zeka oynarken biraz oyuncuları zorlasın
User prompt
Yapay zekanın hızını 10 yap
User prompt
Yapay zekayı 2x hızlı yap
User prompt
Ayarlar tuşu koy tuşa basıncada oyunun ayarlarına girelim ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Sağ alt köşeyede ayarlar tuşu koy ayarların içinde ses ayarlama tuşu olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Sol köşedeki tuşa basınca menüye gidelim
User prompt
Sağ üst köşeye tuş koy o tuşa basınca yapay zekayla oyna ve iki kişi oyna yazan sekmeye girelim
User prompt
Sağ üst köşeye menü tuşu koy o tuşa basınca oyunun giriş sekmesine gidelim
User prompt
Yapay zekayı biraz daha hızlandır
User prompt
Karakterleri yuvarlak yap
Initial prompt
Topun hızını karakterlerin hızlı veya yavaş vurmalarına göre ayarla
/****
* 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.96;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityX *= self.friction;
self.velocityY *= self.friction;
// Boundary checks
if (self.x < 30) {
self.x = 30;
self.velocityX = -self.velocityX * 0.7;
}
if (self.x > 2018) {
self.x = 2018;
self.velocityX = -self.velocityX * 0.7;
}
if (self.y < 30) {
self.y = 30;
self.velocityY = -self.velocityY * 0.7;
}
if (self.y > 2702) {
self.y = 2702;
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 (teamLogo, fallbackColor) {
var self = Container.call(this);
var playerGraphics;
if (teamLogo) {
// Create a circular background for the team logo
var circleBackground = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
if (fallbackColor) {
circleBackground.tint = fallbackColor;
} else {
circleBackground.tint = 0xFFFFFF;
}
// Add team logo on top, scaled down to fit inside circle
var logoGraphics = self.attachAsset(teamLogo, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
playerGraphics = circleBackground; // Keep reference to main graphics
} else {
playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
if (fallbackColor) {
playerGraphics.tint = fallbackColor;
}
}
self.isAI = false;
self.targetX = 0;
self.targetY = 0;
self.lastX = 0;
self.lastY = 0;
self.velocityX = 0;
self.velocityY = 0;
self.update = function () {
// Calculate velocity based on position change
self.velocityX = self.x - self.lastX;
self.velocityY = self.y - self.lastY;
self.lastX = self.x;
self.lastY = self.y;
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 * 6;
self.y += dy / distance * 6;
}
// 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;
// Calculate AI speed for kick force
var aiSpeed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY);
var speedMultiplier = Math.max(0.02, Math.min(0.1, 0.02 + aiSpeed * 0.02));
ball.kick(ballToGoalX * speedMultiplier, ballToGoalY * speedMultiplier);
}
}
};
self.down = function (x, y, obj) {
if (!self.isAI) {
self.targetX = x;
self.targetY = y;
}
};
// Move method removed - now handled by global game event handlers
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
****/
// Team logo assets
// 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 team1Logo = '';
var team2Logo = '';
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,
logo: 'galatasaray'
}, {
name: 'Fenerbahçe',
color: 0x000080,
logo: 'fenerbahce'
}, {
name: 'Beşiktaş',
color: 0x000000,
logo: 'besiktas'
}, {
name: 'Trabzonspor',
color: 0x800000,
logo: 'trabzonspor'
}, {
name: 'Başakşehir',
color: 0xFF8000,
logo: 'basaksehir'
}];
var laLigaTeams = [{
name: 'Real Madrid',
color: 0xFFFFFF,
logo: 'realmadrid'
}, {
name: 'Barcelona',
color: 0x004A9F,
logo: 'barcelona'
}];
// 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;
team1Logo = team.logo;
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;
team2Logo = aiTeam.logo;
startGame();
} else {
title.setText('İkinci Takımı Seçin');
}
} else if (selectedTeams.length === 2) {
team2Name = team.name;
team2Color = team.color;
team2Logo = team.logo;
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 goal posts for top goal
var topLeftPost = game.attachAsset('goalPost', {
anchorX: 0.5,
anchorY: 0.5,
x: 824,
y: 166
});
var topRightPost = game.attachAsset('goalPost', {
anchorX: 0.5,
anchorY: 0.5,
x: 1224,
y: 166
});
// Create goal posts for bottom goal
var bottomLeftPost = game.attachAsset('goalPost', {
anchorX: 0.5,
anchorY: 0.5,
x: 824,
y: 2566
});
var bottomRightPost = game.attachAsset('goalPost', {
anchorX: 0.5,
anchorY: 0.5,
x: 1224,
y: 2566
});
// Create center line
var centerLine = game.attachAsset('centerLine', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
// Create penalty areas
var topPenaltyArea = game.attachAsset('penaltyArea', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 316
});
topPenaltyArea.alpha = 0.3;
var bottomPenaltyArea = game.attachAsset('penaltyArea', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2416
});
bottomPenaltyArea.alpha = 0.3;
// 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(team1Logo, team1Color);
player1.x = 1024;
player1.y = 1800;
players.push(player1);
game.addChild(player1);
var player2 = new Player(team2Logo, 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;
// Initialize lastY if not set
if (ball.lastY === undefined) {
ball.lastY = ball.y;
return;
}
// Check top goal (team 1 scores) - ball must enter from front (from below), not sides
if (ball.y < 166 && ball.x > 824 && ball.x < 1224 && ball.y > 91) {
// Only count as goal if ball entered from below (lastY was greater than goal line)
if (ball.lastY >= 166) {
score1++;
LK.getSound('goal').play();
resetBallPosition();
updateScoreboard();
}
}
// Check bottom goal (team 2 scores) - ball must enter from front (from above), not sides
if (ball.y > 2566 && ball.x > 824 && ball.x < 1224 && ball.y < 2641) {
// Only count as goal if ball entered from above (lastY was less than goal line)
if (ball.lastY <= 2566) {
score2++;
LK.getSound('goal').play();
resetBallPosition();
updateScoreboard();
}
}
// Update lastY for next frame
ball.lastY = ball.y;
}
function resetBallPosition() {
if (ball) {
ball.x = 1024;
ball.y = 1366;
ball.velocityX = 0;
ball.velocityY = 0;
ball.lastY = 1366; // Reset lastY tracking
}
}
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;
}
}
// Global variables for tracking player control
var activePlayer = null;
var player1Active = false;
var player2Active = false;
// Game event handlers
game.down = function (x, y, obj) {
if (gameState !== 'playing') return;
// Determine which player should be controlled based on touch position
if (players.length >= 2) {
var distToPlayer1 = Math.sqrt((x - players[0].x) * (x - players[0].x) + (y - players[0].y) * (y - players[0].y));
var distToPlayer2 = Math.sqrt((x - players[1].x) * (x - players[1].x) + (y - players[1].y) * (y - players[1].y));
if (gameMode === 'twoPlayer') {
// In two player mode, closest player gets controlled
if (distToPlayer1 < distToPlayer2) {
activePlayer = players[0];
player1Active = true;
player2Active = false;
} else {
activePlayer = players[1];
player1Active = false;
player2Active = true;
}
} else {
// In vs AI mode, only player 1 can be controlled
if (!players[0].isAI) {
activePlayer = players[0];
player1Active = true;
player2Active = false;
}
}
if (activePlayer && !activePlayer.isAI) {
activePlayer.targetX = x;
activePlayer.targetY = y;
}
}
};
game.move = function (x, y, obj) {
if (gameState !== 'playing' || !activePlayer || activePlayer.isAI) return;
activePlayer.x = x;
activePlayer.y = y;
// Kick ball if close
if (ball) {
var dx = ball.x - activePlayer.x;
var dy = ball.y - activePlayer.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 80) {
// Calculate player speed for kick force
var playerSpeed = Math.sqrt(activePlayer.velocityX * activePlayer.velocityX + activePlayer.velocityY * activePlayer.velocityY);
// Base kick force + speed multiplier (min 0.3, max 1.2)
var kickMultiplier = Math.max(0.3, Math.min(1.2, 0.3 + playerSpeed * 0.05));
ball.kick(dx * kickMultiplier, dy * kickMultiplier);
}
}
};
game.up = function (x, y, obj) {
activePlayer = null;
player1Active = false;
player2Active = false;
};
game.update = function () {
if (gameState === 'playing') {
checkGoal();
}
};
// Create menu button for top right corner
var menuBtn = new MenuButton('Menü', 0x0066CC);
menuBtn.x = 1900; // Position in top right, leaving space from edge
menuBtn.y = 150;
menuBtn.onPress = function () {
// Return to main menu
gameState = 'mainMenu';
clearGame();
// Clear all containers
menuContainer.removeChildren();
leagueContainer.removeChildren();
teamContainer.removeChildren();
// Remove containers from game
if (game.children.indexOf(menuContainer) !== -1) game.removeChild(menuContainer);
if (game.children.indexOf(leagueContainer) !== -1) game.removeChild(leagueContainer);
if (game.children.indexOf(teamContainer) !== -1) game.removeChild(teamContainer);
// Show main menu
showMainMenu();
};
LK.gui.topRight.addChild(menuBtn);
// Initialize game
showMainMenu();
; ===================================================================
--- original.js
+++ change.js
@@ -615,6 +615,27 @@
if (gameState === 'playing') {
checkGoal();
}
};
+// Create menu button for top right corner
+var menuBtn = new MenuButton('Menü', 0x0066CC);
+menuBtn.x = 1900; // Position in top right, leaving space from edge
+menuBtn.y = 150;
+menuBtn.onPress = function () {
+ // Return to main menu
+ gameState = 'mainMenu';
+ clearGame();
+ // Clear all containers
+ menuContainer.removeChildren();
+ leagueContainer.removeChildren();
+ teamContainer.removeChildren();
+ // Remove containers from game
+ if (game.children.indexOf(menuContainer) !== -1) game.removeChild(menuContainer);
+ if (game.children.indexOf(leagueContainer) !== -1) game.removeChild(leagueContainer);
+ if (game.children.indexOf(teamContainer) !== -1) game.removeChild(teamContainer);
+ // Show main menu
+ showMainMenu();
+};
+LK.gui.topRight.addChild(menuBtn);
// Initialize game
-showMainMenu();
\ No newline at end of file
+showMainMenu();
+;
\ No newline at end of file