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; goalArea.scaleX = 2; // Make goal twice as wide // Left goal post var leftPost = self.attachAsset('goalPost', { anchorX: 0.5, anchorY: 1 }); leftPost.x = -200; // Move left post further left // Right goal post var rightPost = self.attachAsset('goalPost', { anchorX: 0.5, anchorY: 1 }); rightPost.x = 200; // Move right post further right // Crossbar var crossbar = self.attachAsset('crossbar', { anchorX: 0.5, anchorY: 0.5 }); crossbar.y = -300; crossbar.scaleX = 2; // Make crossbar twice as wide self.checkGoal = function (ball) { // Check if ball is within goal area (larger goal) var ballInGoalX = ball.x > self.x - 200 && ball.x < self.x + 200; 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)); // Calculate aim direction based on drag movement var dragDeltaX = x - dragStartX; var dragDeltaY = y - dragStartY; var dragDistance = Math.sqrt(dragDeltaX * dragDeltaX + dragDeltaY * dragDeltaY); if (dragDistance > 10) { // Only update aim if dragged far enough aimDirection.x = dragDeltaX / dragDistance; aimDirection.y = dragDeltaY / dragDistance; } } } // Touch/mouse handlers game.move = handleMove; // Variables to track drag direction for aiming var dragStartX = 0; var dragStartY = 0; var aimDirection = { x: 0, y: -1 }; // Default aim up toward goal game.down = function (x, y, obj) { dragNode = player; dragStartX = x; dragStartY = y; handleMove(x, y, obj); }; game.up = function (x, y, obj) { // If ball is near player and not moving, kick it in aim direction if (dragNode === player) { 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()) { var kickPower = 25; // Calculate target position based on aim direction var targetX = ball.x + aimDirection.x * 800; // Extend aim direction var targetY = ball.y + aimDirection.y * 800; ball.kickTowards(targetX, targetY, kickPower); ballHasBeenKicked = true; } } 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
@@ -200,29 +200,47 @@
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));
+ // Calculate aim direction based on drag movement
+ var dragDeltaX = x - dragStartX;
+ var dragDeltaY = y - dragStartY;
+ var dragDistance = Math.sqrt(dragDeltaX * dragDeltaX + dragDeltaY * dragDeltaY);
+ if (dragDistance > 10) {
+ // Only update aim if dragged far enough
+ aimDirection.x = dragDeltaX / dragDistance;
+ aimDirection.y = dragDeltaY / dragDistance;
+ }
}
}
// Touch/mouse handlers
game.move = handleMove;
+// Variables to track drag direction for aiming
+var dragStartX = 0;
+var dragStartY = 0;
+var aimDirection = {
+ x: 0,
+ y: -1
+}; // Default aim up toward goal
game.down = function (x, y, obj) {
dragNode = player;
+ dragStartX = x;
+ dragStartY = y;
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()) {
- // Calculate kick direction based on player position relative to goal center
- var kickPower = 25;
- var playerOffsetFromGoalCenter = player.x - goal.x;
- // Kick in direction proportional to player's horizontal position
- var targetX = goal.x + playerOffsetFromGoalCenter * 0.8; // Amplify the angle
- var targetY = goal.y - 150;
- ball.kickTowards(targetX, targetY, kickPower);
- ballHasBeenKicked = true;
- }
};
game.up = function (x, y, obj) {
+ // If ball is near player and not moving, kick it in aim direction
+ if (dragNode === player) {
+ 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()) {
+ var kickPower = 25;
+ // Calculate target position based on aim direction
+ var targetX = ball.x + aimDirection.x * 800; // Extend aim direction
+ var targetY = ball.y + aimDirection.y * 800;
+ ball.kickTowards(targetX, targetY, kickPower);
+ ballHasBeenKicked = true;
+ }
+ }
dragNode = null;
};
// Main game update loop
game.update = function () {