User prompt
Engelleri büyült
User prompt
Change background
User prompt
Engelleri büyült ve topuda biraz
User prompt
Topu sağ tarafa dokunduğumuz zaman sağa sola dokunduğumuz zaman ise sola gitsin ve skor ekle ve engeller büyük ve rastgele olmasın en üstden gelsin
User prompt
Yukaran aşağı engeller gelsin ve ona dokunduğumuz zaman ölüyorum
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: drawing is not defined' in or related to this line: 'var lines = drawing.getLines();' Line Number: 94
User prompt
Please fix the bug: 'ReferenceError: drawing is not defined' in or related to this line: 'var lines = drawing.getLines();' Line Number: 94
User prompt
94 numaralı kodu düzelt
User prompt
Please fix the bug: 'ReferenceError: drawing is not defined' in or related to this line: 'var lines = drawing.getLines();' Line Number: 94
User prompt
Please fix the bug: 'ReferenceError: drawing is not defined' in or related to this line: 'var lines = drawing.getLines();' Line Number: 94
User prompt
Elimizle çizgi çizip kaleye gol atmak
Code edit (1 edits merged)
Please save this source code
User prompt
Futbol Keepie-Uppie Challenge
Initial prompt
Futbol oyunu yarat
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Goal = Container.expand(function () {
var self = Container.call(this);
// Goal frame
var goalFrame = self.attachAsset('goal', {
anchorX: 0.5,
anchorY: 1.0
});
goalFrame.alpha = 0.3;
// Left post
var leftPost = self.attachAsset('goalPost', {
anchorX: 0.5,
anchorY: 1.0,
x: -200
});
// Right post
var rightPost = self.attachAsset('goalPost', {
anchorX: 0.5,
anchorY: 1.0,
x: 200
});
// Top bar
var topBar = self.attachAsset('goalPost', {
anchorX: 0.5,
anchorY: 0.5,
width: 400,
height: 20,
y: -300
});
self.checkGoal = function (ball) {
var ballRadius = 40;
return ball.x > self.x - 200 && ball.x < self.x + 200 && ball.y > self.y - 300 && ball.y < self.y;
};
return self;
});
var SoccerBall = Container.expand(function () {
var self = Container.call(this);
// Create ball graphics
var ballBase = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
var ballPattern = self.attachAsset('ballPattern', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.7
});
// Physics properties
self.velocityY = 0;
self.velocityX = 2;
self.gravity = 0.4;
self.bounceDamping = 0.9;
self.maxVelocityY = 20;
self.maxVelocityX = 15;
// Game state
self.isGrounded = false;
self.lastY = 0;
self.lastGoalCheck = false;
self.update = function () {
// Store last position
self.lastY = self.y;
// Apply gravity
self.velocityY += self.gravity;
// Limit velocities
if (self.velocityY > self.maxVelocityY) {
self.velocityY = self.maxVelocityY;
}
if (self.velocityX > self.maxVelocityX) {
self.velocityX = self.maxVelocityX;
}
if (self.velocityX < -self.maxVelocityX) {
self.velocityX = -self.maxVelocityX;
}
// Check line collisions
var lines = drawing.getLines();
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (self.checkLineCollision(line)) {
self.bounceOffLine(line);
break;
}
}
// Update position
self.x += self.velocityX;
self.y += self.velocityY;
// Screen boundaries
var ballRadius = 40;
// Left/right wall bouncing
if (self.x - ballRadius <= 0) {
self.x = ballRadius;
self.velocityX = Math.abs(self.velocityX) * self.bounceDamping;
LK.getSound('bounce').play();
} else if (self.x + ballRadius >= 2048) {
self.x = 2048 - ballRadius;
self.velocityX = -Math.abs(self.velocityX) * self.bounceDamping;
LK.getSound('bounce').play();
}
// Ground collision detection
if (self.y + ballRadius >= groundY) {
if (!self.isGrounded) {
self.isGrounded = true;
if (!goal.checkGoal(self)) {
gameOver();
} else {
scoreGoal();
}
}
}
// Goal check
var currentGoalCheck = goal.checkGoal(self);
if (!self.lastGoalCheck && currentGoalCheck && !self.isGrounded) {
scoreGoal();
}
self.lastGoalCheck = currentGoalCheck;
// Add rotation for visual effect
ballBase.rotation += self.velocityX * 0.02;
ballPattern.rotation += self.velocityX * 0.02;
};
self.checkLineCollision = function (line) {
var ballRadius = 40;
var dist = self.pointToLineDistance(self.x, self.y, line.x1, line.y1, line.x2, line.y2);
return dist <= ballRadius;
};
self.pointToLineDistance = function (px, py, x1, y1, x2, y2) {
var dx = x2 - x1;
var dy = y2 - y1;
var length = Math.sqrt(dx * dx + dy * dy);
if (length === 0) return Math.sqrt((px - x1) * (px - x1) + (py - y1) * (py - y1));
var t = ((px - x1) * dx + (py - y1) * dy) / (length * length);
t = Math.max(0, Math.min(1, t));
var projX = x1 + t * dx;
var projY = y1 + t * dy;
return Math.sqrt((px - projX) * (px - projX) + (py - projY) * (py - projY));
};
self.bounceOffLine = function (line) {
var dx = line.x2 - line.x1;
var dy = line.y2 - line.y1;
var length = Math.sqrt(dx * dx + dy * dy);
var normalX = -dy / length;
var normalY = dx / length;
var dotProduct = self.velocityX * normalX + self.velocityY * normalY;
self.velocityX -= 2 * dotProduct * normalX;
self.velocityY -= 2 * dotProduct * normalY;
self.velocityX *= self.bounceDamping;
self.velocityY *= self.bounceDamping;
LK.getSound('bounce').play();
};
self.reset = function () {
self.x = 200;
self.y = 1000;
self.velocityX = 2 + Math.random() * 3;
self.velocityY = -2 - Math.random() * 3;
self.isGrounded = false;
self.lastGoalCheck = false;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x4CAF50
});
/****
* Game Code
****/
// Game variables
var ball;
var goal;
var ground;
var score = 0;
var gameStarted = false;
var groundY = 2632;
// UI elements
var scoreTxt = new Text2('Goals: 0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var instructionTxt = new Text2('DRAW LINES TO GUIDE THE BALL INTO THE GOAL!', {
size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.x = 1024;
instructionTxt.y = 400;
game.addChild(instructionTxt);
// Initialize game objects
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0.5,
anchorY: 0,
x: 1024,
y: groundY
}));
goal = game.addChild(new Goal());
goal.x = 1700;
goal.y = groundY;
ball = game.addChild(new SoccerBall());
ball.x = 200;
ball.y = 1000;
function updateScore() {
scoreTxt.setText('Goals: ' + score.toString());
}
function scoreGoal() {
score++;
updateScore();
LK.getSound('goal').play();
// Flash screen green for goal
LK.effects.flashScreen(0x00FF00, 500);
// Reset ball for next attempt
LK.setTimeout(function () {
ball.reset();
drawing.clearLines();
}, 1000);
// Win condition
if (score >= 10) {
LK.showYouWin();
}
}
function gameOver() {
LK.showGameOver();
}
function startGame() {
if (!gameStarted) {
gameStarted = true;
instructionTxt.visible = false;
ball.velocityX = 2 + Math.random() * 3;
ball.velocityY = -2 - Math.random() * 3;
}
}
// Event handlers
var isDrawing = false;
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
} else {
isDrawing = true;
drawing.startLine(x, y, {
color: 0xFFFFFF,
width: 8,
maxLength: 300
});
}
};
game.move = function (x, y, obj) {
if (isDrawing && gameStarted) {
drawing.updateLine(x, y);
}
};
game.up = function (x, y, obj) {
if (isDrawing && gameStarted) {
isDrawing = false;
drawing.endLine();
}
};
game.update = function () {
// Remove old lines after some time
if (LK.ticks % 300 === 0) {
drawing.removeOldestLine();
}
};
// Initial score display
updateScore(); ===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,42 @@
/****
* Classes
****/
+var Goal = Container.expand(function () {
+ var self = Container.call(this);
+ // Goal frame
+ var goalFrame = self.attachAsset('goal', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ goalFrame.alpha = 0.3;
+ // Left post
+ var leftPost = self.attachAsset('goalPost', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: -200
+ });
+ // Right post
+ var rightPost = self.attachAsset('goalPost', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 200
+ });
+ // Top bar
+ var topBar = self.attachAsset('goalPost', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 400,
+ height: 20,
+ y: -300
+ });
+ self.checkGoal = function (ball) {
+ var ballRadius = 40;
+ return ball.x > self.x - 200 && ball.x < self.x + 200 && ball.y > self.y - 300 && ball.y < self.y;
+ };
+ return self;
+});
var SoccerBall = Container.expand(function () {
var self = Container.call(this);
// Create ball graphics
var ballBase = self.attachAsset('ball', {
@@ -20,17 +54,17 @@
scaleY: 0.7
});
// Physics properties
self.velocityY = 0;
- self.velocityX = 0;
- self.gravity = 0.6;
- self.bounceDamping = 0.8;
- self.tapForce = -18;
- self.maxVelocityY = 25;
- self.maxVelocityX = 8;
+ self.velocityX = 2;
+ self.gravity = 0.4;
+ self.bounceDamping = 0.9;
+ self.maxVelocityY = 20;
+ self.maxVelocityX = 15;
// Game state
self.isGrounded = false;
self.lastY = 0;
+ self.lastGoalCheck = false;
self.update = function () {
// Store last position
self.lastY = self.y;
// Apply gravity
@@ -44,8 +78,17 @@
}
if (self.velocityX < -self.maxVelocityX) {
self.velocityX = -self.maxVelocityX;
}
+ // Check line collisions
+ var lines = drawing.getLines();
+ for (var i = 0; i < lines.length; i++) {
+ var line = lines[i];
+ if (self.checkLineCollision(line)) {
+ self.bounceOffLine(line);
+ break;
+ }
+ }
// Update position
self.x += self.velocityX;
self.y += self.velocityY;
// Screen boundaries
@@ -60,44 +103,65 @@
self.velocityX = -Math.abs(self.velocityX) * self.bounceDamping;
LK.getSound('bounce').play();
}
// Ground collision detection
- if (self.y + ballRadius >= 2732) {
+ if (self.y + ballRadius >= groundY) {
if (!self.isGrounded) {
self.isGrounded = true;
- gameOver();
+ if (!goal.checkGoal(self)) {
+ gameOver();
+ } else {
+ scoreGoal();
+ }
}
}
- // Add slight rotation for visual effect
+ // Goal check
+ var currentGoalCheck = goal.checkGoal(self);
+ if (!self.lastGoalCheck && currentGoalCheck && !self.isGrounded) {
+ scoreGoal();
+ }
+ self.lastGoalCheck = currentGoalCheck;
+ // Add rotation for visual effect
ballBase.rotation += self.velocityX * 0.02;
ballPattern.rotation += self.velocityX * 0.02;
};
- self.applyTapForce = function () {
- if (!self.isGrounded) {
- self.velocityY = self.tapForce;
- // Add slight horizontal randomness
- self.velocityX += (Math.random() - 0.5) * 2;
- // Visual feedback
- tween(self, {
- scaleX: 1.2,
- scaleY: 1.2
- }, {
- duration: 100
- });
- tween(self, {
- scaleX: 1.0,
- scaleY: 1.0
- }, {
- duration: 200
- });
- LK.getSound('tap').play();
- // Increase score
- score++;
- updateScore();
- // Increase difficulty
- increaseDifficulty();
- }
+ self.checkLineCollision = function (line) {
+ var ballRadius = 40;
+ var dist = self.pointToLineDistance(self.x, self.y, line.x1, line.y1, line.x2, line.y2);
+ return dist <= ballRadius;
};
+ self.pointToLineDistance = function (px, py, x1, y1, x2, y2) {
+ var dx = x2 - x1;
+ var dy = y2 - y1;
+ var length = Math.sqrt(dx * dx + dy * dy);
+ if (length === 0) return Math.sqrt((px - x1) * (px - x1) + (py - y1) * (py - y1));
+ var t = ((px - x1) * dx + (py - y1) * dy) / (length * length);
+ t = Math.max(0, Math.min(1, t));
+ var projX = x1 + t * dx;
+ var projY = y1 + t * dy;
+ return Math.sqrt((px - projX) * (px - projX) + (py - projY) * (py - projY));
+ };
+ self.bounceOffLine = function (line) {
+ var dx = line.x2 - line.x1;
+ var dy = line.y2 - line.y1;
+ var length = Math.sqrt(dx * dx + dy * dy);
+ var normalX = -dy / length;
+ var normalY = dx / length;
+ var dotProduct = self.velocityX * normalX + self.velocityY * normalY;
+ self.velocityX -= 2 * dotProduct * normalX;
+ self.velocityY -= 2 * dotProduct * normalY;
+ self.velocityX *= self.bounceDamping;
+ self.velocityY *= self.bounceDamping;
+ LK.getSound('bounce').play();
+ };
+ self.reset = function () {
+ self.x = 200;
+ self.y = 1000;
+ self.velocityX = 2 + Math.random() * 3;
+ self.velocityY = -2 - Math.random() * 3;
+ self.isGrounded = false;
+ self.lastGoalCheck = false;
+ };
return self;
});
/****
@@ -111,59 +175,100 @@
* Game Code
****/
// Game variables
var ball;
+var goal;
+var ground;
var score = 0;
-var baseGravity = 0.6;
-var baseTapForce = -18;
var gameStarted = false;
+var groundY = 2632;
// UI elements
-var scoreTxt = new Text2('0', {
+var scoreTxt = new Text2('Goals: 0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
-var instructionTxt = new Text2('TAP TO KEEP THE BALL UP!', {
- size: 80,
+var instructionTxt = new Text2('DRAW LINES TO GUIDE THE BALL INTO THE GOAL!', {
+ size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.x = 1024;
instructionTxt.y = 400;
game.addChild(instructionTxt);
-// Initialize ball
+// Initialize game objects
+ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: 1024,
+ y: groundY
+}));
+goal = game.addChild(new Goal());
+goal.x = 1700;
+goal.y = groundY;
ball = game.addChild(new SoccerBall());
-ball.x = 1024;
+ball.x = 200;
ball.y = 1000;
function updateScore() {
- scoreTxt.setText(score.toString());
+ scoreTxt.setText('Goals: ' + score.toString());
}
-function increaseDifficulty() {
- // Slightly increase gravity and reduce tap effectiveness as score increases
- var difficultyMultiplier = Math.min(1 + score * 0.01, 1.5);
- ball.gravity = baseGravity * difficultyMultiplier;
- ball.tapForce = baseTapForce * (1 / Math.sqrt(difficultyMultiplier));
+function scoreGoal() {
+ score++;
+ updateScore();
+ LK.getSound('goal').play();
+ // Flash screen green for goal
+ LK.effects.flashScreen(0x00FF00, 500);
+ // Reset ball for next attempt
+ LK.setTimeout(function () {
+ ball.reset();
+ drawing.clearLines();
+ }, 1000);
+ // Win condition
+ if (score >= 10) {
+ LK.showYouWin();
+ }
}
function gameOver() {
LK.showGameOver();
}
function startGame() {
if (!gameStarted) {
gameStarted = true;
instructionTxt.visible = false;
- ball.applyTapForce();
+ ball.velocityX = 2 + Math.random() * 3;
+ ball.velocityY = -2 - Math.random() * 3;
}
}
// Event handlers
+var isDrawing = false;
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
} else {
- ball.applyTapForce();
+ isDrawing = true;
+ drawing.startLine(x, y, {
+ color: 0xFFFFFF,
+ width: 8,
+ maxLength: 300
+ });
}
};
+game.move = function (x, y, obj) {
+ if (isDrawing && gameStarted) {
+ drawing.updateLine(x, y);
+ }
+};
+game.up = function (x, y, obj) {
+ if (isDrawing && gameStarted) {
+ isDrawing = false;
+ drawing.endLine();
+ }
+};
game.update = function () {
- // Game loop handled by ball's update method
+ // Remove old lines after some time
+ if (LK.ticks % 300 === 0) {
+ drawing.removeOldestLine();
+ }
};
// Initial score display
updateScore();
\ No newline at end of file
Anything . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A rocket . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Thunder logo. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A sign . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Robotic door metal exit door. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A stone. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat