User prompt
The goalkeeper should always stay on the goal line but move forward when the player comes. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When I touch the goalkeeper, the ball goes forward
User prompt
The time will be 90 seconds, the player will always get the ball, that is, when the defender touches the ball will pass to him, there is no way not to pass
User prompt
When the football ball is a goal, it will always be in the middle, there will be a line indicating the middle, it will be in the circle.
User prompt
Write demo below
User prompt
Don't write soccer strike, just write welcome at the top, write FFT 26 but in the middle, welcome at the top, FFT26
User prompt
Write welcome FFT26 above
User prompt
The game name is FFT26
User prompt
Let's start with 0-0, when the opponent scores, it increases by 1, left is us, right is the opponent.
User prompt
Let the defender go to the ball and score a goal, and write the score above.
User prompt
remove color menu
User prompt
It's always the same color, change the color of the character
User prompt
Please fix the bug: 'Uncaught TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 306
User prompt
Still the same error, the color I touch does not appear, the character appears
User prompt
bro it doesn't work, whatever color you click on is the color of the character
User prompt
I pressed orange and it came out green
User prompt
The character will become that color if he presses the color
User prompt
When we press play, the screen opens and the color becomes red, blue, green, black, yellow and orange. When we press it, we become that.
User prompt
There will be two goals and two goalkeepers, the situation will become more difficult with every goal scored
User prompt
Let the menu have grass in the background
User prompt
Let there be grass in the background
User prompt
Let there be a menu at the beginning and two buttons, let it say play at the top and exit at the bottom.
Code edit (1 edits merged)
Please save this source code
User prompt
Soccer Strike 2007
Initial prompt
futbol oyunu yap fifa 2007 gibi
/****
* 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.95;
self.isMoving = false;
self.update = function () {
if (self.isMoving) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityX *= self.friction;
self.velocityY *= self.friction;
// Stop ball if velocity is very low
if (Math.abs(self.velocityX) < 0.5 && Math.abs(self.velocityY) < 0.5) {
self.velocityX = 0;
self.velocityY = 0;
self.isMoving = false;
}
// Field boundaries
if (self.x < 50) {
self.x = 50;
self.velocityX = -self.velocityX * 0.8;
}
if (self.x > 1998) {
self.x = 1998;
self.velocityX = -self.velocityX * 0.8;
}
if (self.y < 300) {
self.y = 300;
self.velocityY = -self.velocityY * 0.8;
}
if (self.y > 1800) {
self.y = 1800;
self.velocityY = -self.velocityY * 0.8;
}
}
};
self.shoot = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
self.velocityX = dx / distance * 15;
self.velocityY = dy / distance * 15;
self.isMoving = true;
LK.getSound('kick').play();
};
return self;
});
var Defender = Container.expand(function () {
var self = Container.call(this);
var defenderGraphics = self.attachAsset('defender', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.targetX = 0;
self.targetY = 0;
self.update = function () {
// Move towards target
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
return self;
});
var Goalkeeper = Container.expand(function () {
var self = Container.call(this);
var goalkeeperGraphics = self.attachAsset('goalkeeper', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.direction = 1;
self.centerX = 0;
self.update = function () {
self.x += self.direction * self.speed;
// Bounce between goal posts
if (self.x < self.centerX - 150 || self.x > self.centerX + 150) {
self.direction *= -1;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.hasBall = false;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228b22
});
/****
* Game Code
****/
// Menu system
var menuActive = true;
var gameStarted = false;
// Menu grass background
var menuGrassBackground = game.attachAsset('grass', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0
});
// Menu title
var titleTxt = new Text2('SOCCER STRIKE 2007', {
size: 120,
fill: 0xFFFFFF
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.x = 1024;
titleTxt.y = 800;
game.addChild(titleTxt);
// Play button
var playButton = new Text2('PLAY', {
size: 100,
fill: 0x00FF00
});
playButton.anchor.set(0.5, 0.5);
playButton.x = 1024;
playButton.y = 1200;
game.addChild(playButton);
// Exit button
var exitButton = new Text2('EXIT', {
size: 100,
fill: 0xFF0000
});
exitButton.anchor.set(0.5, 0.5);
exitButton.x = 1024;
exitButton.y = 1400;
game.addChild(exitButton);
// Function to start the game
function startGame() {
menuActive = false;
gameStarted = true;
// Hide menu elements
titleTxt.visible = false;
playButton.visible = false;
exitButton.visible = false;
// Show game elements
initializeGameElements();
}
// Function to initialize game elements
function initializeGameElements() {
// Grass background
var grassBackground = game.attachAsset('grass', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0
});
// Game field setup
var fieldBackground = game.attachAsset('field', {
x: 0,
y: 400,
anchorX: 0,
anchorY: 0
});
// Goal setup
goalArea = game.attachAsset('goal', {
x: 1024,
y: 300,
anchorX: 0.5,
anchorY: 0
});
goalArea.alpha = 0.3;
leftGoalPost = game.attachAsset('goalpost', {
x: 824,
y: 300,
anchorX: 0.5,
anchorY: 0
});
rightGoalPost = game.attachAsset('goalpost', {
x: 1224,
y: 300,
anchorX: 0.5,
anchorY: 0
});
// Score display
scoreTxt = new Text2('Goals: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Timer display
timerTxt = new Text2('Time: 60', {
size: 60,
fill: 0xFFFFFF
});
timerTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(timerTxt);
// Game entities
player = game.addChild(new Player());
player.x = 1024;
player.y = 1500;
ball = game.addChild(new Ball());
ball.x = 1024;
ball.y = 1450;
goalkeeper = game.addChild(new Goalkeeper());
goalkeeper.x = 1024;
goalkeeper.y = 350;
goalkeeper.centerX = 1024;
// Defenders
defenders = [];
for (var i = 0; i < 3; i++) {
var defender = game.addChild(new Defender());
defender.x = 600 + i * 300;
defender.y = 800 + i * 150;
defenders.push(defender);
}
// Game variables
gameTime = 60;
goals = 0;
gameActive = true;
dragNode = null;
lastGameTime = 60;
// Game timer
gameTimer = LK.setInterval(function () {
if (gameActive) {
gameTime--;
timerTxt.setText('Time: ' + gameTime);
if (gameTime <= 0) {
gameActive = false;
LK.showGameOver();
}
}
}, 1000);
}
// Declare game variables globally
var goalArea, leftGoalPost, rightGoalPost, scoreTxt, timerTxt;
var player, ball, goalkeeper, defenders;
var gameTime, goals, gameActive, dragNode, lastGameTime, gameTimer;
// Touch controls
game.down = function (x, y, obj) {
if (menuActive) {
// Check if play button was clicked
var distanceToPlay = Math.sqrt((x - playButton.x) * (x - playButton.x) + (y - playButton.y) * (y - playButton.y));
if (distanceToPlay < 150) {
startGame();
return;
}
// Check if exit button was clicked
var distanceToExit = Math.sqrt((x - exitButton.x) * (x - exitButton.x) + (y - exitButton.y) * (y - exitButton.y));
if (distanceToExit < 150) {
// Exit functionality - show game over to end the game
LK.showGameOver();
return;
}
return;
}
if (!gameActive || !gameStarted) return;
var distanceToPlayer = Math.sqrt((x - player.x) * (x - player.x) + (y - player.y) * (y - player.y));
var distanceToBall = Math.sqrt((x - ball.x) * (x - ball.x) + (y - ball.y) * (y - ball.y));
if (distanceToPlayer < 100) {
dragNode = player;
} else if (distanceToBall < 80 && player.hasBall) {
// Shoot ball towards tap location
ball.shoot(x, y);
player.hasBall = false;
}
};
game.move = function (x, y, obj) {
if (!gameActive || !gameStarted || menuActive) return;
if (dragNode === player) {
player.x = x;
player.y = y;
// Keep player within field bounds
if (player.x < 100) player.x = 100;
if (player.x > 1948) player.x = 1948;
if (player.y < 400) player.y = 400;
if (player.y > 1850) player.y = 1850;
// Move ball with player if close enough
if (player.hasBall && !ball.isMoving) {
ball.x = player.x;
ball.y = player.y - 50;
}
}
};
game.up = function (x, y, obj) {
if (!gameStarted || menuActive) return;
dragNode = null;
};
// Main game loop
game.update = function () {
if (!gameActive || !gameStarted || menuActive) return;
// Check if player can pick up ball
var distanceToBall = Math.sqrt((player.x - ball.x) * (player.x - ball.x) + (player.y - ball.y) * (player.y - ball.y));
if (distanceToBall < 60 && !ball.isMoving && !player.hasBall) {
player.hasBall = true;
}
// Update defenders to chase player
for (var i = 0; i < defenders.length; i++) {
var defender = defenders[i];
defender.targetX = player.x;
defender.targetY = player.y;
// Check collision with player
var distanceToPlayer = Math.sqrt((defender.x - player.x) * (defender.x - player.x) + (defender.y - player.y) * (defender.y - player.y));
if (distanceToPlayer < 80 && player.hasBall) {
player.hasBall = false;
ball.x = player.x + 60;
ball.y = player.y;
LK.effects.flashObject(player, 0xff0000, 500);
}
}
// Check goal scoring
if (ball.x > 844 && ball.x < 1204 && ball.y < 500 && ball.y > 300) {
if (ball.lastY === undefined || ball.lastY > 500) {
goals++;
LK.setScore(goals);
scoreTxt.setText('Goals: ' + goals);
LK.getSound('goal').play();
LK.effects.flashScreen(0x00ff00, 1000);
// Reset ball and player positions
player.x = 1024;
player.y = 1500;
ball.x = 1024;
ball.y = 1450;
ball.velocityX = 0;
ball.velocityY = 0;
ball.isMoving = false;
player.hasBall = false;
// Check win condition
if (goals >= 5) {
gameActive = false;
LK.showYouWin();
}
}
}
ball.lastY = ball.y;
}; ===================================================================
--- original.js
+++ change.js
@@ -120,8 +120,15 @@
****/
// Menu system
var menuActive = true;
var gameStarted = false;
+// Menu grass background
+var menuGrassBackground = game.attachAsset('grass', {
+ x: 0,
+ y: 0,
+ anchorX: 0,
+ anchorY: 0
+});
// Menu title
var titleTxt = new Text2('SOCCER STRIKE 2007', {
size: 120,
fill: 0xFFFFFF