User prompt
oyunu tam ekran yap
User prompt
top köşeye gidince maç otomatik yeniden başlasın,
User prompt
top köşelere gidince ortaya gelsin otomatik
User prompt
iki kalenin resimleri farklı olsun
User prompt
kalecilerin resimleri farklı olsun
User prompt
bot takımı kendi kalesine değil benim kaleme gol atmaya çalışsın
User prompt
6 ya 6 değil 1 e 1 olsun
User prompt
rakip takımın resmi farklı olsun
User prompt
oynanış daha gerçekci olsun ve kolay olsun kaleciler topu kurtarsın bizim takımı komple ben yönetim
User prompt
kalelere kaleci koy birer tane
User prompt
bir takımı biz kontrol edelim karşı takım topu bizim kaleye atmaya çalışsın
User prompt
dikeylemesine yap telefon için kalelerin yeri yatay değil dikey yerde olsun
User prompt
tema saha olsun
Code edit (1 edits merged)
Please save this source code
User prompt
6v6 Futbol Arenası
Initial prompt
futbol oyunu yap 6 ya 6 olsun 2 kale taç ve korner olsun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Ball class var Ball = Container.expand(function () { var self = Container.call(this); // Attach ball asset (ellipse, white) var ballAsset = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); // Ball properties self.radius = ballAsset.width / 2; self.vx = 0; self.vy = 0; self.friction = 0.98; // Ball slows down over time // Update method (called every tick) self.update = function () { self.x += self.vx; self.y += self.vy; self.vx *= self.friction; self.vy *= self.friction; // Clamp speed to zero if very small if (Math.abs(self.vx) < 0.1) self.vx = 0; if (Math.abs(self.vy) < 0.1) self.vy = 0; }; return self; }); // Goal class var Goal = Container.expand(function () { var self = Container.call(this); // Attach goal asset (rectangle) var goalAsset = self.attachAsset('goal', { anchorX: 0.5, anchorY: 0.5 }); self.width = goalAsset.width; self.height = goalAsset.height; return self; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); // Attach player asset (circle, color depends on team) var playerAsset = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.radius = playerAsset.width / 2; self.team = 0; // 0: left, 1: right self.index = 0; // 0-5 self.isUser = false; // Only one player is user-controlled // For AI: target position self.targetX = self.x; self.targetY = self.y; // For user drag self.isDragging = false; // Update method self.update = function () { if (!self.isUser) { // Simple AI: move toward ball var dx = ball.x - self.x; var dy = ball.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 80) { self.x += dx / dist * 6; self.y += dy / dist * 6; } } // Clamp inside field if (self.x < field.left + self.radius) self.x = field.left + self.radius; if (self.x > field.right - self.radius) self.x = field.right - self.radius; if (self.y < field.top + self.radius) self.y = field.top + self.radius; if (self.y > field.bottom - self.radius) self.y = field.bottom - self.radius; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a8f3c // Football field green }); /**** * Game Code ****/ // Tween plugin for animations (not used in MVP but included for future use) // Field dimensions (centered) var field = { width: 1700, height: 2500, left: (2048 - 1700) / 2, right: (2048 + 1700) / 2, top: (2732 - 2500) / 2, bottom: (2732 + 2500) / 2 }; // Draw field (rectangle, lines, center circle, etc.) var fieldAsset = LK.getAsset('field', { width: field.width, height: field.height, color: 0x2e7d32, // More realistic football field green shape: 'box', x: field.left, y: field.top }); game.addChild(fieldAsset); // Center line var centerLine = LK.getAsset('centerLine', { width: field.width, height: 10, color: 0xffffff, shape: 'box', x: field.left, y: field.top + field.height / 2 - 5 }); game.addChild(centerLine); // Penalty areas (left and right) var penaltyWidth = 500; var penaltyHeight = 1100; var leftPenalty = LK.getAsset('penaltyAreaLeft', { width: penaltyWidth, height: penaltyHeight, color: 0xffffff, shape: 'box', x: field.left - 5, y: 2732 / 2 - penaltyHeight / 2 }); leftPenalty.alpha = 0.12; game.addChild(leftPenalty); var rightPenalty = LK.getAsset('penaltyAreaRight', { width: penaltyWidth, height: penaltyHeight, color: 0xffffff, shape: 'box', x: field.right - penaltyWidth + 5, y: 2732 / 2 - penaltyHeight / 2 }); rightPenalty.alpha = 0.12; game.addChild(rightPenalty); // Goal areas (left and right) var goalAreaWidth = 250; var goalAreaHeight = 500; var leftGoalArea = LK.getAsset('goalAreaLeft', { width: goalAreaWidth, height: goalAreaHeight, color: 0xffffff, shape: 'box', x: field.left - 5, y: 2732 / 2 - goalAreaHeight / 2 }); leftGoalArea.alpha = 0.18; game.addChild(leftGoalArea); var rightGoalArea = LK.getAsset('goalAreaRight', { width: goalAreaWidth, height: goalAreaHeight, color: 0xffffff, shape: 'box', x: field.right - goalAreaWidth + 5, y: 2732 / 2 - goalAreaHeight / 2 }); rightGoalArea.alpha = 0.18; game.addChild(rightGoalArea); // Penalty spots var penaltySpotRadius = 18; var leftPenaltySpot = LK.getAsset('penaltySpotLeft', { width: penaltySpotRadius * 2, height: penaltySpotRadius * 2, color: 0xffffff, shape: 'ellipse', x: field.left + 120, y: 2732 / 2 - penaltySpotRadius }); leftPenaltySpot.alpha = 0.7; game.addChild(leftPenaltySpot); var rightPenaltySpot = LK.getAsset('penaltySpotRight', { width: penaltySpotRadius * 2, height: penaltySpotRadius * 2, color: 0xffffff, shape: 'ellipse', x: field.right - 120 - penaltySpotRadius * 2, y: 2732 / 2 - penaltySpotRadius }); rightPenaltySpot.alpha = 0.7; game.addChild(rightPenaltySpot); // Center circle var centerCircle = LK.getAsset('centerCircle', { width: 320, height: 320, color: 0xffffff, shape: 'ellipse', x: 2048 / 2 - 160, y: 2732 / 2 - 160 }); centerCircle.alpha = 0.25; game.addChild(centerCircle); // Center spot var centerSpot = LK.getAsset('centerSpot', { width: 24, height: 24, color: 0xffffff, shape: 'ellipse', x: 2048 / 2 - 12, y: 2732 / 2 - 12 }); centerSpot.alpha = 0.7; game.addChild(centerSpot); // Corner arcs (for visual, not used in logic) for (var i = 0; i < 4; i++) { var cx = i % 2 === 0 ? field.left : field.right; var cy = i < 2 ? field.top : field.bottom; var cornerArc = LK.getAsset('cornerArc' + i, { width: 60, height: 60, color: 0xffffff, shape: 'ellipse', x: cx - 30, y: cy - 30 }); cornerArc.alpha = 0.15; game.addChild(cornerArc); } // Goals var goalWidth = 400; var goalHeight = 120; var leftGoal = new Goal(); var rightGoal = new Goal(); leftGoal.x = field.left - 20 + goalWidth / 2; leftGoal.y = 2732 / 2; rightGoal.x = field.right + 20 - goalWidth / 2; rightGoal.y = 2732 / 2; leftGoal.width = goalWidth; leftGoal.height = goalHeight; rightGoal.width = goalWidth; rightGoal.height = goalHeight; game.addChild(leftGoal); game.addChild(rightGoal); // Ball var ball = new Ball(); ball.x = 2048 / 2; ball.y = 2732 / 2; var ballAsset = ball.children[0]; ballAsset.width = 60; ballAsset.height = 60; ball.radius = 30; ballAsset.color = 0xffffff; game.addChild(ball); // Teams var teamA = []; var teamB = []; var playerRadius = 60; var playerColors = [0x1e90ff, 0xff3333]; // Blue, Red // Place teamA (left, blue) for (var i = 0; i < 6; i++) { var p = new Player(); var asset = p.children[0]; asset.width = playerRadius * 2; asset.height = playerRadius * 2; asset.color = playerColors[0]; p.radius = playerRadius; p.team = 0; p.index = i; // Arrange in 2-2-2 formation var row = Math.floor(i / 2); var col = i % 2; p.x = field.left + 300 + row * 150; p.y = field.top + field.height / 6 + col * (field.height / 3) + (row - 1) * 100; if (i === 0) { p.isUser = true; // Only first player is user-controlled } teamA.push(p); game.addChild(p); } // Place teamB (right, red) for (var i = 0; i < 6; i++) { var p = new Player(); var asset = p.children[0]; asset.width = playerRadius * 2; asset.height = playerRadius * 2; asset.color = playerColors[1]; p.radius = playerRadius; p.team = 1; p.index = i; // Arrange in 2-2-2 formation var row = Math.floor(i / 2); var col = i % 2; p.x = field.right - 300 - row * 150; p.y = field.top + field.height / 6 + col * (field.height / 3) + (row - 1) * 100; teamB.push(p); game.addChild(p); } // Score var scoreA = 0; var scoreB = 0; var scoreTxt = new Text2('0 - 0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Game state var lastTouch = { x: 0, y: 0 }; var draggingPlayer = null; var throwInActive = false; var throwInTeam = 0; var throwInPos = { x: 0, y: 0 }; var cornerActive = false; var cornerTeam = 0; var cornerPos = { x: 0, y: 0 }; var lastTeamTouched = 0; // 0: teamA, 1: teamB // Helper: check collision between two circles function circlesCollide(ax, ay, ar, bx, by, br) { var dx = ax - bx; var dy = ay - by; var dist = Math.sqrt(dx * dx + dy * dy); return dist < ar + br; } // Helper: check if ball is in goal function isGoal(ball, goal) { return ball.x > goal.x - goal.width / 2 && ball.x < goal.x + goal.width / 2 && ball.y > goal.y - goal.height / 2 && ball.y < goal.y + goal.height / 2; } // Helper: reset positions after goal function resetPositions() { // Ball to center ball.x = 2048 / 2; ball.y = 2732 / 2; ball.vx = 0; ball.vy = 0; // TeamA for (var i = 0; i < 6; i++) { var p = teamA[i]; var row = Math.floor(i / 2); var col = i % 2; p.x = field.left + 300 + row * 150; p.y = field.top + field.height / 6 + col * (field.height / 3) + (row - 1) * 100; } // TeamB for (var i = 0; i < 6; i++) { var p = teamB[i]; var row = Math.floor(i / 2); var col = i % 2; p.x = field.right - 300 - row * 150; p.y = field.top + field.height / 6 + col * (field.height / 3) + (row - 1) * 100; } } // Helper: check if ball is out for throw-in or corner function checkOutOfBounds() { // Left/right (taç) if (ball.x < field.left) { throwInActive = true; throwInTeam = 1; // Right team gets throw-in throwInPos.x = field.left + ball.radius + 10; throwInPos.y = Math.max(field.top + ball.radius + 10, Math.min(ball.y, field.bottom - ball.radius - 10)); ball.vx = 0; ball.vy = 0; ball.x = throwInPos.x; ball.y = throwInPos.y; } else if (ball.x > field.right) { throwInActive = true; throwInTeam = 0; // Left team gets throw-in throwInPos.x = field.right - ball.radius - 10; throwInPos.y = Math.max(field.top + ball.radius + 10, Math.min(ball.y, field.bottom - ball.radius - 10)); ball.vx = 0; ball.vy = 0; ball.x = throwInPos.x; ball.y = throwInPos.y; } // Top/bottom (korner veya aut) else if (ball.y < field.top) { // If ball is between goal posts, it's a goal if (ball.x > leftGoal.x - leftGoal.width / 2 && ball.x < leftGoal.x + leftGoal.width / 2) { // Left goal scoreB++; scoreTxt.setText(scoreA + " - " + scoreB); resetPositions(); return; } // Otherwise, corner or goal kick if (ball.x < field.left + 200) { // Left corner cornerActive = true; cornerTeam = 1; // Right team gets corner cornerPos.x = field.left + 30; cornerPos.y = field.top + 30; } else if (ball.x > field.right - 200) { // Right corner cornerActive = true; cornerTeam = 0; // Left team gets corner cornerPos.x = field.right - 30; cornerPos.y = field.top + 30; } else { // Goal kick (not implemented, treat as throw-in for now) throwInActive = true; throwInTeam = lastTeamTouched === 0 ? 1 : 0; throwInPos.x = Math.max(field.left + ball.radius + 10, Math.min(ball.x, field.right - ball.radius - 10)); throwInPos.y = field.top + ball.radius + 10; } ball.vx = 0; ball.vy = 0; if (cornerActive) { ball.x = cornerPos.x; ball.y = cornerPos.y; } else { ball.x = throwInPos.x; ball.y = throwInPos.y; } } else if (ball.y > field.bottom) { // If ball is between goal posts, it's a goal if (ball.x > rightGoal.x - rightGoal.width / 2 && ball.x < rightGoal.x + rightGoal.width / 2) { // Right goal scoreA++; scoreTxt.setText(scoreA + " - " + scoreB); resetPositions(); return; } // Otherwise, corner or goal kick if (ball.x < field.left + 200) { // Left corner cornerActive = true; cornerTeam = 1; // Right team gets corner cornerPos.x = field.left + 30; cornerPos.y = field.bottom - 30; } else if (ball.x > field.right - 200) { // Right corner cornerActive = true; cornerTeam = 0; // Left team gets corner cornerPos.x = field.right - 30; cornerPos.y = field.bottom - 30; } else { // Goal kick (not implemented, treat as throw-in for now) throwInActive = true; throwInTeam = lastTeamTouched === 0 ? 1 : 0; throwInPos.x = Math.max(field.left + ball.radius + 10, Math.min(ball.x, field.right - ball.radius - 10)); throwInPos.y = field.bottom - ball.radius - 10; } ball.vx = 0; ball.vy = 0; if (cornerActive) { ball.x = cornerPos.x; ball.y = cornerPos.y; } else { ball.x = throwInPos.x; ball.y = throwInPos.y; } } } // Touch/drag logic for user player game.down = function (x, y, obj) { // Only allow drag if not in throw-in/corner if (throwInActive || cornerActive) return; // Check if user player is touched var userPlayer = teamA[0]; var dx = x - userPlayer.x; var dy = y - userPlayer.y; if (dx * dx + dy * dy < userPlayer.radius * userPlayer.radius) { draggingPlayer = userPlayer; draggingPlayer.isDragging = true; lastTouch.x = x; lastTouch.y = y; } }; game.move = function (x, y, obj) { if (draggingPlayer && draggingPlayer.isDragging) { // Move player with finger, clamp inside field draggingPlayer.x = Math.max(field.left + draggingPlayer.radius, Math.min(x, field.right - draggingPlayer.radius)); draggingPlayer.y = Math.max(field.top + draggingPlayer.radius, Math.min(y, field.bottom - draggingPlayer.radius)); lastTouch.x = x; lastTouch.y = y; } }; game.up = function (x, y, obj) { if (draggingPlayer && draggingPlayer.isDragging) { // On release, if close to ball, kick it var dx = ball.x - draggingPlayer.x; var dy = ball.y - draggingPlayer.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < draggingPlayer.radius + ball.radius + 10) { // Kick direction: from player to ball, magnitude based on drag var kickVx = (ball.x - lastTouch.x) * 0.3; var kickVy = (ball.y - lastTouch.y) * 0.3; ball.vx += kickVx; ball.vy += kickVy; lastTeamTouched = 0; } draggingPlayer.isDragging = false; draggingPlayer = null; } // Throw-in/corner logic if (throwInActive) { // Only allow throw-in by correct team if (throwInTeam === 0) { // Left team var dx = x - ball.x; var dy = y - ball.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 30) { ball.vx = dx * 0.15; ball.vy = dy * 0.15; throwInActive = false; } } if (throwInTeam === 1) { // Right team var dx = x - ball.x; var dy = y - ball.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 30) { ball.vx = dx * 0.15; ball.vy = dy * 0.15; throwInActive = false; } } } if (cornerActive) { // Only allow corner by correct team if (cornerTeam === 0) { // Left team var dx = x - ball.x; var dy = y - ball.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 30) { ball.vx = dx * 0.15; ball.vy = dy * 0.15; cornerActive = false; } } if (cornerTeam === 1) { // Right team var dx = x - ball.x; var dy = y - ball.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 30) { ball.vx = dx * 0.15; ball.vy = dy * 0.15; cornerActive = false; } } } }; // Main game update game.update = function () { // Update all players for (var i = 0; i < 6; i++) { teamA[i].update(); teamB[i].update(); } // Update ball ball.update(); // Ball-player collision for (var i = 0; i < 6; i++) { var p = teamA[i]; var dx = ball.x - p.x; var dy = ball.y - p.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < ball.radius + p.radius) { // Push ball away var overlap = ball.radius + p.radius - dist + 1; var nx = dx / dist; var ny = dy / dist; ball.x += nx * overlap; ball.y += ny * overlap; // Ball velocity ball.vx += nx * 2; ball.vy += ny * 2; lastTeamTouched = 0; } var p2 = teamB[i]; dx = ball.x - p2.x; dy = ball.y - p2.y; dist = Math.sqrt(dx * dx + dy * dy); if (dist < ball.radius + p2.radius) { var overlap = ball.radius + p2.radius - dist + 1; var nx = dx / dist; var ny = dy / dist; ball.x += nx * overlap; ball.y += ny * overlap; ball.vx += nx * 2; ball.vy += ny * 2; lastTeamTouched = 1; } } // Ball-wall collision (field boundaries) if (ball.x < field.left + ball.radius) { ball.x = field.left + ball.radius; ball.vx = -ball.vx * 0.7; } if (ball.x > field.right - ball.radius) { ball.x = field.right - ball.radius; ball.vx = -ball.vx * 0.7; } if (ball.y < field.top + ball.radius) { ball.y = field.top + ball.radius; ball.vy = -ball.vy * 0.7; } if (ball.y > field.bottom - ball.radius) { ball.y = field.bottom - ball.radius; ball.vy = -ball.vy * 0.7; } // Check for goals if (isGoal(ball, leftGoal)) { scoreB++; scoreTxt.setText(scoreA + " - " + scoreB); resetPositions(); return; } if (isGoal(ball, rightGoal)) { scoreA++; scoreTxt.setText(scoreA + " - " + scoreB); resetPositions(); return; } // Check for throw-in/corner if (!throwInActive && !cornerActive) { checkOutOfBounds(); } // Win condition (first to 5) if (scoreA >= 5) { LK.showYouWin(); } if (scoreB >= 5) { LK.showGameOver(); } };
===================================================================
--- original.js
+++ change.js
@@ -104,9 +104,10 @@
// Draw field (rectangle, lines, center circle, etc.)
var fieldAsset = LK.getAsset('field', {
width: field.width,
height: field.height,
- color: 0x1a8f3c,
+ color: 0x2e7d32,
+ // More realistic football field green
shape: 'box',
x: field.left,
y: field.top
});
@@ -120,19 +121,98 @@
x: field.left,
y: field.top + field.height / 2 - 5
});
game.addChild(centerLine);
+// Penalty areas (left and right)
+var penaltyWidth = 500;
+var penaltyHeight = 1100;
+var leftPenalty = LK.getAsset('penaltyAreaLeft', {
+ width: penaltyWidth,
+ height: penaltyHeight,
+ color: 0xffffff,
+ shape: 'box',
+ x: field.left - 5,
+ y: 2732 / 2 - penaltyHeight / 2
+});
+leftPenalty.alpha = 0.12;
+game.addChild(leftPenalty);
+var rightPenalty = LK.getAsset('penaltyAreaRight', {
+ width: penaltyWidth,
+ height: penaltyHeight,
+ color: 0xffffff,
+ shape: 'box',
+ x: field.right - penaltyWidth + 5,
+ y: 2732 / 2 - penaltyHeight / 2
+});
+rightPenalty.alpha = 0.12;
+game.addChild(rightPenalty);
+// Goal areas (left and right)
+var goalAreaWidth = 250;
+var goalAreaHeight = 500;
+var leftGoalArea = LK.getAsset('goalAreaLeft', {
+ width: goalAreaWidth,
+ height: goalAreaHeight,
+ color: 0xffffff,
+ shape: 'box',
+ x: field.left - 5,
+ y: 2732 / 2 - goalAreaHeight / 2
+});
+leftGoalArea.alpha = 0.18;
+game.addChild(leftGoalArea);
+var rightGoalArea = LK.getAsset('goalAreaRight', {
+ width: goalAreaWidth,
+ height: goalAreaHeight,
+ color: 0xffffff,
+ shape: 'box',
+ x: field.right - goalAreaWidth + 5,
+ y: 2732 / 2 - goalAreaHeight / 2
+});
+rightGoalArea.alpha = 0.18;
+game.addChild(rightGoalArea);
+// Penalty spots
+var penaltySpotRadius = 18;
+var leftPenaltySpot = LK.getAsset('penaltySpotLeft', {
+ width: penaltySpotRadius * 2,
+ height: penaltySpotRadius * 2,
+ color: 0xffffff,
+ shape: 'ellipse',
+ x: field.left + 120,
+ y: 2732 / 2 - penaltySpotRadius
+});
+leftPenaltySpot.alpha = 0.7;
+game.addChild(leftPenaltySpot);
+var rightPenaltySpot = LK.getAsset('penaltySpotRight', {
+ width: penaltySpotRadius * 2,
+ height: penaltySpotRadius * 2,
+ color: 0xffffff,
+ shape: 'ellipse',
+ x: field.right - 120 - penaltySpotRadius * 2,
+ y: 2732 / 2 - penaltySpotRadius
+});
+rightPenaltySpot.alpha = 0.7;
+game.addChild(rightPenaltySpot);
// Center circle
var centerCircle = LK.getAsset('centerCircle', {
- width: 300,
- height: 300,
+ width: 320,
+ height: 320,
color: 0xffffff,
shape: 'ellipse',
- x: 2048 / 2 - 150,
- y: 2732 / 2 - 150
+ x: 2048 / 2 - 160,
+ y: 2732 / 2 - 160
});
-centerCircle.alpha = 0.2;
+centerCircle.alpha = 0.25;
game.addChild(centerCircle);
+// Center spot
+var centerSpot = LK.getAsset('centerSpot', {
+ width: 24,
+ height: 24,
+ color: 0xffffff,
+ shape: 'ellipse',
+ x: 2048 / 2 - 12,
+ y: 2732 / 2 - 12
+});
+centerSpot.alpha = 0.7;
+game.addChild(centerSpot);
// Corner arcs (for visual, not used in logic)
for (var i = 0; i < 4; i++) {
var cx = i % 2 === 0 ? field.left : field.right;
var cy = i < 2 ? field.top : field.bottom;