User prompt
Cuando la pelota se va a fuera de reinicia la puntuación
User prompt
Que se agrande el arco para meter gol
User prompt
Cuando el rival tapa el tiro se reinicie tu puntuación
User prompt
Que el jugador sea más grande,y el rival también
User prompt
Cada vez que hagas 10 puntos el rival va más rápidos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que el rival sea mueva de un lado a otro ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que cada 10 puntos haya un rival tapando el tiro
User prompt
Que la pelota valla adónde la pelota del jugador le pegue
User prompt
Que la pelota sea más grande
User prompt
Que la pelota valla en dirección donde apuntas
User prompt
Que la pelota valla más rápido para que entre en el arco
User prompt
Que el arco sea más grande,que la pelota balla en dirección donde patea el jugador
Code edit (1 edits merged)
Please save this source code
User prompt
Infinite Kick Master
Initial prompt
Has un juego 3D en el que un hombre patea una pelota en un arco infinitas veces
/**** * 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.isMoving = false; self.startX = 0; self.startY = 0; self.update = function () { if (self.isMoving) { self.x += self.velocityX; self.y += self.velocityY; // Apply some friction self.velocityX *= 0.99; self.velocityY *= 0.99; // Stop if moving too slowly if (Math.abs(self.velocityX) < 0.1 && Math.abs(self.velocityY) < 0.1) { self.stop(); } } }; self.kickTowards = function (targetX, targetY, power) { var deltaX = targetX - self.x; var deltaY = targetY - self.y; var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); if (distance > 0) { self.velocityX = deltaX / distance * power; self.velocityY = deltaY / distance * power; self.isMoving = true; } }; self.stop = function () { self.velocityX = 0; self.velocityY = 0; self.isMoving = false; }; self.reset = function () { self.x = self.startX; self.y = self.startY; self.stop(); }; return self; }); var Goal = Container.expand(function () { var self = Container.call(this); // Goal background var goalArea = self.attachAsset('goal', { anchorX: 0.5, anchorY: 1 }); goalArea.alpha = 0.3; // Left goal post var leftPost = self.attachAsset('goalPost', { anchorX: 0.5, anchorY: 1 }); leftPost.x = -90; // Right goal post var rightPost = self.attachAsset('goalPost', { anchorX: 0.5, anchorY: 1 }); rightPost.x = 90; // Crossbar var crossbar = self.attachAsset('crossbar', { anchorX: 0.5, anchorY: 0.5 }); crossbar.y = -300; self.checkGoal = function (ball) { // Check if ball is within goal area var ballInGoalX = ball.x > self.x - 90 && ball.x < self.x + 90; var ballInGoalY = ball.y < self.y && ball.y > self.y - 280; return ballInGoalX && ballInGoalY; }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.canKick = true; self.kickCooldown = 0; self.update = function () { if (self.kickCooldown > 0) { self.kickCooldown--; } if (self.kickCooldown <= 0) { self.canKick = true; } }; self.kick = function () { if (self.canKick) { self.canKick = false; self.kickCooldown = 30; // 0.5 second cooldown at 60fps LK.getSound('kick').play(); return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228b22 }); /**** * Game Code ****/ // Game variables var player; var ball; var goal; var scoreTxt; var dragNode = null; var gameState = 'playing'; // 'playing', 'goal', 'miss' var ballHasBeenKicked = false; var lastBallMoving = false; // Create score display scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 100; // Move down from very top // Create game objects player = game.addChild(new Player()); ball = game.addChild(new Ball()); goal = game.addChild(new Goal()); // Position game objects player.x = 1024; // Center horizontally player.y = 2200; // Near bottom ball.x = 1024; // Center horizontally ball.y = 2000; // Above player ball.startX = ball.x; ball.startY = ball.y; goal.x = 1024; // Center horizontally goal.y = 400; // Near top // Update score display function updateScore() { scoreTxt.setText(LK.getScore()); } // Handle goal scoring function handleGoal() { if (gameState === 'playing') { gameState = 'goal'; LK.setScore(LK.getScore() + 1); updateScore(); LK.getSound('goal').play(); // Flash effect LK.effects.flashScreen(0x00ff00, 500); // Reset after delay LK.setTimeout(function () { resetBall(); gameState = 'playing'; }, 1000); } } // Handle ball going off screen (miss) function handleMiss() { if (gameState === 'playing') { gameState = 'miss'; // Reset after short delay LK.setTimeout(function () { resetBall(); gameState = 'playing'; }, 500); } } // Reset ball to starting position function resetBall() { ball.reset(); ballHasBeenKicked = false; lastBallMoving = false; } // Handle player movement and kicking function handleMove(x, y, obj) { if (dragNode === player) { player.x = x; player.y = y; // Keep player in bounds player.x = Math.max(100, Math.min(1948, player.x)); player.y = Math.max(1500, Math.min(2600, player.y)); } } // Touch/mouse handlers game.move = handleMove; game.down = function (x, y, obj) { dragNode = player; handleMove(x, y, obj); // If ball is near player and not moving, kick it var distanceToBall = Math.sqrt((player.x - ball.x) * (player.x - ball.x) + (player.y - ball.y) * (player.y - ball.y)); if (distanceToBall < 120 && !ball.isMoving && player.kick()) { // Kick ball towards goal with some variation based on player position var kickPower = 15; var targetX = goal.x + (Math.random() - 0.5) * 50; // Add slight randomness var targetY = goal.y - 150; ball.kickTowards(targetX, targetY, kickPower); ballHasBeenKicked = true; } }; game.up = function (x, y, obj) { dragNode = null; }; // Main game update loop game.update = function () { // Track ball movement state changes var currentBallMoving = ball.isMoving; // Check for goal if (ball.isMoving && goal.checkGoal(ball)) { handleGoal(); } // Check if ball went off screen (miss) if (ballHasBeenKicked && lastBallMoving && !currentBallMoving) { // Ball stopped moving after being kicked if (!goal.checkGoal(ball)) { handleMiss(); } } // Check if ball went too far off screen if (ball.y < -100 || ball.x < -100 || ball.x > 2148) { if (ballHasBeenKicked) { handleMiss(); } } // Update last ball moving state lastBallMoving = currentBallMoving; }; // Initialize score updateScore();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,248 @@
-/****
+/****
+* 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.isMoving = false;
+ self.startX = 0;
+ self.startY = 0;
+ self.update = function () {
+ if (self.isMoving) {
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ // Apply some friction
+ self.velocityX *= 0.99;
+ self.velocityY *= 0.99;
+ // Stop if moving too slowly
+ if (Math.abs(self.velocityX) < 0.1 && Math.abs(self.velocityY) < 0.1) {
+ self.stop();
+ }
+ }
+ };
+ self.kickTowards = function (targetX, targetY, power) {
+ var deltaX = targetX - self.x;
+ var deltaY = targetY - self.y;
+ var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+ if (distance > 0) {
+ self.velocityX = deltaX / distance * power;
+ self.velocityY = deltaY / distance * power;
+ self.isMoving = true;
+ }
+ };
+ self.stop = function () {
+ self.velocityX = 0;
+ self.velocityY = 0;
+ self.isMoving = false;
+ };
+ self.reset = function () {
+ self.x = self.startX;
+ self.y = self.startY;
+ self.stop();
+ };
+ return self;
+});
+var Goal = Container.expand(function () {
+ var self = Container.call(this);
+ // Goal background
+ var goalArea = self.attachAsset('goal', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ goalArea.alpha = 0.3;
+ // Left goal post
+ var leftPost = self.attachAsset('goalPost', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ leftPost.x = -90;
+ // Right goal post
+ var rightPost = self.attachAsset('goalPost', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ rightPost.x = 90;
+ // Crossbar
+ var crossbar = self.attachAsset('crossbar', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crossbar.y = -300;
+ self.checkGoal = function (ball) {
+ // Check if ball is within goal area
+ var ballInGoalX = ball.x > self.x - 90 && ball.x < self.x + 90;
+ var ballInGoalY = ball.y < self.y && ball.y > self.y - 280;
+ return ballInGoalX && ballInGoalY;
+ };
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.canKick = true;
+ self.kickCooldown = 0;
+ self.update = function () {
+ if (self.kickCooldown > 0) {
+ self.kickCooldown--;
+ }
+ if (self.kickCooldown <= 0) {
+ self.canKick = true;
+ }
+ };
+ self.kick = function () {
+ if (self.canKick) {
+ self.canKick = false;
+ self.kickCooldown = 30; // 0.5 second cooldown at 60fps
+ LK.getSound('kick').play();
+ return true;
+ }
+ return false;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x228b22
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var player;
+var ball;
+var goal;
+var scoreTxt;
+var dragNode = null;
+var gameState = 'playing'; // 'playing', 'goal', 'miss'
+var ballHasBeenKicked = false;
+var lastBallMoving = false;
+// Create score display
+scoreTxt = new Text2('0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+scoreTxt.y = 100; // Move down from very top
+// Create game objects
+player = game.addChild(new Player());
+ball = game.addChild(new Ball());
+goal = game.addChild(new Goal());
+// Position game objects
+player.x = 1024; // Center horizontally
+player.y = 2200; // Near bottom
+ball.x = 1024; // Center horizontally
+ball.y = 2000; // Above player
+ball.startX = ball.x;
+ball.startY = ball.y;
+goal.x = 1024; // Center horizontally
+goal.y = 400; // Near top
+// Update score display
+function updateScore() {
+ scoreTxt.setText(LK.getScore());
+}
+// Handle goal scoring
+function handleGoal() {
+ if (gameState === 'playing') {
+ gameState = 'goal';
+ LK.setScore(LK.getScore() + 1);
+ updateScore();
+ LK.getSound('goal').play();
+ // Flash effect
+ LK.effects.flashScreen(0x00ff00, 500);
+ // Reset after delay
+ LK.setTimeout(function () {
+ resetBall();
+ gameState = 'playing';
+ }, 1000);
+ }
+}
+// Handle ball going off screen (miss)
+function handleMiss() {
+ if (gameState === 'playing') {
+ gameState = 'miss';
+ // Reset after short delay
+ LK.setTimeout(function () {
+ resetBall();
+ gameState = 'playing';
+ }, 500);
+ }
+}
+// Reset ball to starting position
+function resetBall() {
+ ball.reset();
+ ballHasBeenKicked = false;
+ lastBallMoving = false;
+}
+// Handle player movement and kicking
+function handleMove(x, y, obj) {
+ if (dragNode === player) {
+ player.x = x;
+ player.y = y;
+ // Keep player in bounds
+ player.x = Math.max(100, Math.min(1948, player.x));
+ player.y = Math.max(1500, Math.min(2600, player.y));
+ }
+}
+// Touch/mouse handlers
+game.move = handleMove;
+game.down = function (x, y, obj) {
+ dragNode = player;
+ handleMove(x, y, obj);
+ // If ball is near player and not moving, kick it
+ var distanceToBall = Math.sqrt((player.x - ball.x) * (player.x - ball.x) + (player.y - ball.y) * (player.y - ball.y));
+ if (distanceToBall < 120 && !ball.isMoving && player.kick()) {
+ // Kick ball towards goal with some variation based on player position
+ var kickPower = 15;
+ var targetX = goal.x + (Math.random() - 0.5) * 50; // Add slight randomness
+ var targetY = goal.y - 150;
+ ball.kickTowards(targetX, targetY, kickPower);
+ ballHasBeenKicked = true;
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Main game update loop
+game.update = function () {
+ // Track ball movement state changes
+ var currentBallMoving = ball.isMoving;
+ // Check for goal
+ if (ball.isMoving && goal.checkGoal(ball)) {
+ handleGoal();
+ }
+ // Check if ball went off screen (miss)
+ if (ballHasBeenKicked && lastBallMoving && !currentBallMoving) {
+ // Ball stopped moving after being kicked
+ if (!goal.checkGoal(ball)) {
+ handleMiss();
+ }
+ }
+ // Check if ball went too far off screen
+ if (ball.y < -100 || ball.x < -100 || ball.x > 2148) {
+ if (ballHasBeenKicked) {
+ handleMiss();
+ }
+ }
+ // Update last ball moving state
+ lastBallMoving = currentBallMoving;
+};
+// Initialize score
+updateScore();
\ No newline at end of file