User prompt
aim alma süresini biraz daha kısalt
User prompt
aim almayı bekleme süresini kısalt
User prompt
scoretext arttıkça kaleci sağa ve sola daha hızlı gitsin
User prompt
gol skoru arttıkça kaleci hızlansın
User prompt
kaleciyi nete yaklaştır
User prompt
kaleciyi nete yaklaştır
User prompt
kaleyi ve kaleciyi biraz aşağı götür
User prompt
topu birazcık daha aşağı götür
User prompt
topu ekranın biraz daha aşşağısına götür
User prompt
oyun bittiği zaman skor da yazsın
User prompt
game over olunca final score da yaz
User prompt
kaleci topu tutarsa kırmızı ışık yak ve oyunu bitir
User prompt
top net'e değdiği an gol say
User prompt
gol olursa yeşil ışık yak
User prompt
ScoreText de sadece atılan gol sayısını yaz
User prompt
kaleci direkler arasında dursun dışarı çıkmasın ve takılmasın
User prompt
top aim ile seçtiğimiz yere direkt olarak gitsin
User prompt
eğer top nete değerse gol say
User prompt
kaleyi biraz daha büyük ve orataya yakın şekilde yap
User prompt
topu ekranın ortasına koy knk
User prompt
topu ortadan vuralım
User prompt
top biraz daha ortaya yaklaşsın.
User prompt
top kaleye ulaşsın
Code edit (1 edits merged)
Please save this source code
User prompt
Goal Shooter - Beat the Keeper
/**** * 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.gravity = -0.5; self.friction = 0.98; self.shoot = function (targetX, targetY) { var deltaX = targetX - self.x; var deltaY = targetY - self.y; var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); self.velocityX = deltaX / distance * 30; // Increase speed for direct aim self.velocityY = deltaY / distance * 30; // Increase speed for direct aim self.isMoving = true; LK.getSound('kick').play(); }; self.reset = function () { self.x = 1024; self.y = 1366; self.velocityX = 0; self.velocityY = 0; self.isMoving = false; }; self.update = function () { if (self.isMoving) { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += self.gravity; self.velocityX *= self.friction; self.velocityY *= self.friction; if (Math.abs(self.velocityX) < 0.5 && Math.abs(self.velocityY) < 0.5) { self.isMoving = false; } } }; return self; }); var Goalkeeper = Container.expand(function () { var self = Container.call(this); var keeperGraphics = self.attachAsset('goalkeeper', { anchorX: 0.5, anchorY: 1.0 }); self.direction = 1; self.speed = 3; self.minX = 800; self.maxX = 1248; self.reactDistance = 400; self.update = function () { self.x += self.direction * self.speed; if (self.x <= self.minX) { self.x = self.minX; self.direction = 1; } else if (self.x >= self.maxX) { self.x = self.maxX; self.direction = -1; } if (ball.isMoving && ball.y < self.y + self.reactDistance) { if (ball.x < self.x - 20) { self.direction = -1; self.speed = 5; } else if (ball.x > self.x + 20) { self.direction = 1; self.speed = 5; } } else { self.speed = 3; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228b22 }); /**** * Game Code ****/ var goalWidth = 800; // Increased width var goalHeight = 400; // Increased height var goalX = 1024 - goalWidth / 2; // Centered horizontally var goalY = 300; // Moved closer to the center vertically var net = game.addChild(LK.getAsset('net', { x: goalX + 20, y: goalY + 20, alpha: 0.3 })); var leftPost = game.addChild(LK.getAsset('goalpost', { x: goalX, y: goalY, anchorX: 0.5, anchorY: 0 })); var rightPost = game.addChild(LK.getAsset('goalpost', { x: goalX + goalWidth, y: goalY, anchorX: 0.5, anchorY: 0 })); var crossbar = game.addChild(LK.getAsset('crossbar', { x: goalX, y: goalY, anchorX: 0, anchorY: 0.5 })); var ball = game.addChild(new Ball()); ball.reset(); var goalkeeper = game.addChild(new Goalkeeper()); goalkeeper.x = 1024; goalkeeper.y = goalY + goalHeight; var aimLine = game.addChild(LK.getAsset('aimLine', { anchorX: 0.5, anchorY: 0, alpha: 0 })); var isAiming = false; var shotCount = 0; var goalCount = 0; var scoreTxt = new Text2('Goals: 0/0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var instructionTxt = new Text2('Tap and drag to aim, release to shoot!', { size: 60, fill: 0xFFFF00 }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 1024; instructionTxt.y = 2400; game.addChild(instructionTxt); function updateScore() { scoreTxt.setText('Goals: ' + goalCount); } function resetForNextShot() { LK.setTimeout(function () { ball.reset(); isAiming = false; aimLine.alpha = 0; if (shotCount >= 10) { var finalScore = Math.round(goalCount / shotCount * 100); if (finalScore >= 70) { LK.showYouWin(); } else { LK.showGameOver(); } } }, 2000); } function checkGoal() { if (ball.intersects(net)) { if (!ball.intersects(goalkeeper)) { goalCount++; LK.getSound('goal').play(); LK.effects.flashScreen(0x00ff00, 500); // Trigger green light effect } else { LK.getSound('save').play(); LK.effects.flashScreen(0xff0000, 500); // Trigger red light effect LK.showGameOver(); // End the game when goalkeeper saves the ball } updateScore(); resetForNextShot(); return true; } return false; } game.down = function (x, y, obj) { if (!ball.isMoving && shotCount < 10) { isAiming = true; aimLine.x = ball.x; aimLine.y = ball.y; aimLine.alpha = 0.8; var deltaX = x - ball.x; var deltaY = y - ball.y; var angle = Math.atan2(deltaY, deltaX); aimLine.rotation = angle - Math.PI / 2; var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); aimLine.height = Math.min(distance * 0.5, 200); } }; game.move = function (x, y, obj) { if (isAiming) { var deltaX = x - ball.x; var deltaY = y - ball.y; var angle = Math.atan2(deltaY, deltaX); aimLine.rotation = angle - Math.PI / 2; var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); aimLine.height = Math.min(distance * 0.5, 200); } }; game.up = function (x, y, obj) { if (isAiming && !ball.isMoving) { shotCount++; ball.shoot(x, y); isAiming = false; aimLine.alpha = 0; if (shotCount === 1) { instructionTxt.alpha = 0; } } }; var ballLastY = ball.y; var ballLastInGoal = false; game.update = function () { var currentInGoal = ball.x > goalX && ball.x < goalX + goalWidth && ball.y > goalY && ball.y < goalY + goalHeight; if (!ballLastInGoal && currentInGoal && ball.isMoving) { checkGoal(); } if (ball.y < -100) { updateScore(); resetForNextShot(); } if (ball.x < 0 || ball.x > 2048) { updateScore(); resetForNextShot(); } ballLastY = ball.y; ballLastInGoal = currentInGoal; };
===================================================================
--- original.js
+++ change.js
@@ -171,9 +171,10 @@
LK.getSound('goal').play();
LK.effects.flashScreen(0x00ff00, 500); // Trigger green light effect
} else {
LK.getSound('save').play();
- LK.effects.flashScreen(0xff0000, 500);
+ LK.effects.flashScreen(0xff0000, 500); // Trigger red light effect
+ LK.showGameOver(); // End the game when goalkeeper saves the ball
}
updateScore();
resetForNextShot();
return true;