User prompt
move goalkeeper to bottom of the goalpost
User prompt
move the goal keeper asset little down
User prompt
while goalkeeper trying to stop the ball if the ball touch the goal keeper thats the end of the game
User prompt
update when Ball touches Goalkeeper game must finish
Code edit (5 edits merged)
Please save this source code
User prompt
add sound effects
User prompt
remove reverse direction
User prompt
reverse the direction
User prompt
add mechanism in goalkeeper class ,that After each goal, the goalkeeper speeds up
User prompt
goal keeper moving with constant speed
User prompt
increase the goal keeper moment by 1percent every time when score increase
User prompt
in the goalpost class stop rotating 45 degress
User prompt
if the score is 0 the goalkeeper movement is normal and he scores 10 points increase speed 1 percent an he scores 20 increase 1+1, like wise increasing speed +1 every time he scores
User prompt
when the score increasing the movement of the goal keeper should be increase for every time player scored
User prompt
if the ball touch the goalkeeper game will be end
User prompt
if the goalkeeper stops three consecutive balls then game should be end
User prompt
make sure if the goalkeeper stops the three consecutive goals then only game should be end
User prompt
game over text is not visible after end of the game
User prompt
enable the game over text when the game finshed
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'curveGraphics.lineStyle is not a function' in or related to this line: 'curveGraphics.lineStyle(5, 0xFFFFFF);' Line Number: 112
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var curveGraphics = new Graphics(); // Create new graphics object' Line Number: 104
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var curveGraphics = new Graphics(); // Create new graphics object' Line Number: 104
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var curveGraphics = new Graphics(); // Create new graphics object' Line Number: 104
/**** * Classes ****/ // Ball class var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = { x: 0, y: 0 }; self.update = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; }; return self; }); // Goalkeeper class var Goalkeeper = Container.expand(function () { var self = Container.call(this); var keeperGraphics = self.attachAsset('goalkeeper', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.x = 2048 / 2; self.y = 350; // Goalkeeper lower in goalpost self.update = function () { self.x += self.speed; var leftLimit = goalpost.x - goalpost.width / 2 + keeperGraphics.width / 2; var rightLimit = goalpost.x + goalpost.width / 2 - keeperGraphics.width / 2; if (self.x > rightLimit || self.x < leftLimit) { self.speed *= -1; // Reverse direction } }; return self; }); // Goalpost class var Goalpost = Container.expand(function () { var self = Container.call(this); var postGraphics = self.attachAsset('goalpost', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 200; // Near top of the screen self.update = function () { // Static }; return self; }); /**** * Initialize Game ****/ /**** * Game Initialization ****/ var game = new LK.Game({ backgroundColor: 0x4CAF50 }); /**** * Game Code ****/ var score = 0; var missedShots = 0; var maxMissedShots = 5; var ball, goalkeeper, goalpost, scoreTxt, missedTxt, gameOverText; var gameOver = false; function initGame() { ball = game.addChild(new Ball()); ball.x = 2048 / 2; ball.y = 2732 - 200; goalpost = game.addChild(new Goalpost()); goalkeeper = game.addChild(new Goalkeeper()); scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); missedTxt = new Text2('Missed: 0', { size: 100, fill: 0xFFFFFF }); missedTxt.anchor.set(0.5, 0); missedTxt.y = 120; LK.gui.top.addChild(missedTxt); gameOverText = new Text2('Game Over!', { size: 150, fill: 0xFF0000 }); gameOverText.anchor.set(0.5, 0.5); gameOverText.x = 2048 / 2; gameOverText.y = 2048 / 2; gameOverText.visible = false; LK.gui.top.addChild(gameOverText); } /**** * Game Loop ****/ game.update = function () { if (gameOver) { return; } ball.update(); goalkeeper.update(); if (checkGoal()) { score += 10; scoreTxt.setText('Score: ' + score); resetBall(); increaseDifficulty(); LK.getSound('goal').play(); } else if (ball.y < 0) { missedShots++; missedTxt.setText('Missed: ' + missedShots); resetBall(); if (missedShots >= maxMissedShots) { triggerGameOver(); } } else if (ball.intersects(goalkeeper)) { triggerGameOver(); LK.showGameOver(); } }; function checkGoal() { var goalLeft = goalpost.x - goalpost.width / 2; var goalRight = goalpost.x + goalpost.width / 2; var goalTop = goalpost.y - goalpost.height / 2; var goalBottom = goalpost.y + goalpost.height / 2; // Check if ball touches goalpost edges (missed, not a goal) if ((ball.x < goalLeft || ball.x > goalRight) && ball.y < goalBottom && ball.y > goalTop) { return false; // Ball hit side posts } // Ball is inside goal area (and didn't hit post) if (ball.x > goalLeft && ball.x < goalRight && ball.y < goalBottom && ball.y > goalTop) { if (ball.intersects(goalkeeper)) { triggerGameOver(); // Ball hit keeper inside goal - game over return false; } return true; // Valid goal } return false; } /**** * Ball Reset and Difficulty Increase ****/ function resetBall() { ball.x = 2048 / 2; ball.y = 2732 - 200; ball.direction = { x: 0, y: 0 }; ball.speed = 0; } function increaseDifficulty() { goalkeeper.speed += 1; // Increase goalkeeper speed } /**** * Game Over Handling ****/ function triggerGameOver() { gameOver = true; gameOverText.visible = true; LK.showGameOver(); // FRVR standard game over screen } /**** * User Interaction (Ball Kick) ****/ game.down = function (x, y, obj) { if (gameOver) { return; } var angle = Math.atan2(y - ball.y, x - ball.x); ball.direction = { x: Math.cos(angle), y: Math.sin(angle) }; ball.speed = 20; LK.getSound('kick').play(); }; initGame();
===================================================================
--- original.js
+++ change.js
@@ -1,12 +1,11 @@
/****
* Classes
****/
-/**** Classes ****/
// Ball class
var Ball = Container.expand(function () {
var self = Container.call(this);
- self.attachAsset('ball', {
+ var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
@@ -28,121 +27,130 @@
anchorY: 0.5
});
self.speed = 5;
self.x = 2048 / 2;
- self.y = 400; // Bottom of the goalpost (adjusted)
+ self.y = 350; // Goalkeeper lower in goalpost
self.update = function () {
self.x += self.speed;
- if (self.x > goalpost.x + goalpost.width / 2 - keeperGraphics.width / 2 || self.x < goalpost.x - goalpost.width / 2 + keeperGraphics.width / 2) {
- self.speed *= -1;
+ var leftLimit = goalpost.x - goalpost.width / 2 + keeperGraphics.width / 2;
+ var rightLimit = goalpost.x + goalpost.width / 2 - keeperGraphics.width / 2;
+ if (self.x > rightLimit || self.x < leftLimit) {
+ self.speed *= -1; // Reverse direction
}
};
return self;
});
// Goalpost class
var Goalpost = Container.expand(function () {
var self = Container.call(this);
- self.attachAsset('goalpost', {
+ var postGraphics = self.attachAsset('goalpost', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2;
- self.y = 200;
+ self.y = 200; // Near top of the screen
+ self.update = function () {
+ // Static
+ };
return self;
});
/****
* Initialize Game
****/
-/**** Game Setup ****/
+/****
+* Game Initialization
+****/
var game = new LK.Game({
backgroundColor: 0x4CAF50
});
/****
* Game Code
****/
-/**** Assets ****/
-/**** Game Variables ****/
var score = 0;
var missedShots = 0;
var maxMissedShots = 5;
-var ball, goalkeeper, goalpost;
-var scoreTxt, missedShotsTxt, gameOverText;
+var ball, goalkeeper, goalpost, scoreTxt, missedTxt, gameOverText;
var gameOver = false;
-/**** Initialize Game Elements ****/
function initGame() {
ball = game.addChild(new Ball());
ball.x = 2048 / 2;
ball.y = 2732 - 200;
goalpost = game.addChild(new Goalpost());
goalkeeper = game.addChild(new Goalkeeper());
- // Score text
scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
- // Missed shots text
- missedShotsTxt = new Text2('Missed: 0', {
+ missedTxt = new Text2('Missed: 0', {
size: 100,
fill: 0xFFFFFF
});
- missedShotsTxt.anchor.set(0.5, 0);
- missedShotsTxt.y = 120; // Below score
- LK.gui.top.addChild(missedShotsTxt);
- // Game Over text (hidden initially)
+ missedTxt.anchor.set(0.5, 0);
+ missedTxt.y = 120;
+ LK.gui.top.addChild(missedTxt);
gameOverText = new Text2('Game Over!', {
size: 150,
fill: 0xFF0000
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = 2048 / 2;
- gameOverText.y = 2732 / 2;
+ gameOverText.y = 2048 / 2;
gameOverText.visible = false;
LK.gui.top.addChild(gameOverText);
}
-/**** Game Update Loop ****/
+/****
+* Game Loop
+****/
game.update = function () {
if (gameOver) {
return;
}
- if (ball) {
- ball.update();
- // Ball intersects goalkeeper - Game Over
- if (ball.intersects(goalkeeper)) {
- endGame();
- return;
+ ball.update();
+ goalkeeper.update();
+ if (checkGoal()) {
+ score += 10;
+ scoreTxt.setText('Score: ' + score);
+ resetBall();
+ increaseDifficulty();
+ LK.getSound('goal').play();
+ } else if (ball.y < 0) {
+ missedShots++;
+ missedTxt.setText('Missed: ' + missedShots);
+ resetBall();
+ if (missedShots >= maxMissedShots) {
+ triggerGameOver();
}
- // Ball scores if inside goalpost area (ignores height above keeper)
- if (ball.y < goalpost.y + goalpost.height / 2 && ball.x > goalpost.x - goalpost.width / 2 && ball.x < goalpost.x + goalpost.width / 2) {
- if (ball.y > goalkeeper.y - 150) {
- // Check if keeper was in way
- endGame();
- } else {
- score += 10;
- scoreTxt.setText('Score: ' + score);
- resetBall();
- increaseDifficulty();
- LK.getSound('goal').play();
- }
- }
- // Ball misses (goes off-screen)
- if (ball.y < 0) {
- missedShots++;
- missedShotsTxt.setText('Missed: ' + missedShots);
- resetBall();
- if (missedShots >= maxMissedShots) {
- endGame();
- }
- }
+ } else if (ball.intersects(goalkeeper)) {
+ triggerGameOver();
+ LK.showGameOver();
}
- if (goalkeeper) {
- goalkeeper.update();
- }
};
-/**** Reset Ball Position ****/
+function checkGoal() {
+ var goalLeft = goalpost.x - goalpost.width / 2;
+ var goalRight = goalpost.x + goalpost.width / 2;
+ var goalTop = goalpost.y - goalpost.height / 2;
+ var goalBottom = goalpost.y + goalpost.height / 2;
+ // Check if ball touches goalpost edges (missed, not a goal)
+ if ((ball.x < goalLeft || ball.x > goalRight) && ball.y < goalBottom && ball.y > goalTop) {
+ return false; // Ball hit side posts
+ }
+ // Ball is inside goal area (and didn't hit post)
+ if (ball.x > goalLeft && ball.x < goalRight && ball.y < goalBottom && ball.y > goalTop) {
+ if (ball.intersects(goalkeeper)) {
+ triggerGameOver(); // Ball hit keeper inside goal - game over
+ return false;
+ }
+ return true; // Valid goal
+ }
+ return false;
+}
+/****
+* Ball Reset and Difficulty Increase
+****/
function resetBall() {
ball.x = 2048 / 2;
ball.y = 2732 - 200;
ball.direction = {
@@ -150,14 +158,23 @@
y: 0
};
ball.speed = 0;
}
-/**** Increase Goalkeeper Speed After Each Goal ****/
function increaseDifficulty() {
- goalkeeper.speed += 1;
+ goalkeeper.speed += 1; // Increase goalkeeper speed
}
-/**** Handle Touch (Kicking Ball) ****/
-game.down = function (x, y) {
+/****
+* Game Over Handling
+****/
+function triggerGameOver() {
+ gameOver = true;
+ gameOverText.visible = true;
+ LK.showGameOver(); // FRVR standard game over screen
+}
+/****
+* User Interaction (Ball Kick)
+****/
+game.down = function (x, y, obj) {
if (gameOver) {
return;
}
var angle = Math.atan2(y - ball.y, x - ball.x);
@@ -167,12 +184,5 @@
};
ball.speed = 20;
LK.getSound('kick').play();
};
-/**** End Game Logic ****/
-function endGame() {
- gameOver = true;
- gameOverText.visible = true;
- LK.showGameOver(); // Optional (FRVR's built-in game over screen)
-}
-/**** Start Game ****/
initGame();
\ No newline at end of file
soccer ball 3d. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
real soccer goal post front view. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows
Soft circular glow effect with a bright white center fading into soft blue and green edges. The glow should be smooth and slightly pulsating. Transparent background (PNG format), suitable for overlay on a soccer goal or ball to highlight special moments in a mobile soccer game.". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows