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 Obstacle = Container.expand(function () {
var self = Container.call(this);
// Create obstacle graphics
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
// Movement properties
self.speed = 5;
self.direction = 1; // 1 for down, -1 for up
self.lastIntersecting = false;
self.update = function () {
// Move obstacle up and down
self.y += self.speed * self.direction;
// Reverse direction at screen boundaries
if (self.y <= 100) {
self.direction = 1;
} else if (self.y >= 2500) {
self.direction = -1;
}
};
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 = 0;
self.gravity = 0.6;
self.bounceDamping = 0.8;
self.tapForce = -18;
self.maxVelocityY = 25;
self.maxVelocityX = 8;
// Game state
self.isGrounded = false;
self.lastY = 0;
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;
}
// 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 >= 2732) {
if (!self.isGrounded) {
self.isGrounded = true;
gameOver();
}
}
// Add slight 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();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x4CAF50
});
/****
* Game Code
****/
// Game variables
var ball;
var score = 0;
var baseGravity = 0.6;
var baseTapForce = -18;
var gameStarted = false;
var obstacles = [];
var obstacleSpawnTimer = 0;
var obstacleSpawnInterval = 180; // Spawn every 3 seconds at 60fps
// UI elements
var scoreTxt = new Text2('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,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.x = 1024;
instructionTxt.y = 400;
game.addChild(instructionTxt);
// Initialize ball
ball = game.addChild(new SoccerBall());
ball.x = 1024;
ball.y = 1000;
function updateScore() {
scoreTxt.setText(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 gameOver() {
LK.showGameOver();
}
function startGame() {
if (!gameStarted) {
gameStarted = true;
instructionTxt.visible = false;
ball.applyTapForce();
// Clear any existing obstacles
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].destroy();
}
obstacles = [];
obstacleSpawnTimer = 0;
}
}
// Event handlers
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
} else {
ball.applyTapForce();
}
};
game.update = function () {
// Game loop handled by ball's update method
if (gameStarted) {
// Spawn obstacles
obstacleSpawnTimer++;
if (obstacleSpawnTimer >= obstacleSpawnInterval) {
obstacleSpawnTimer = 0;
var obstacle = new Obstacle();
obstacle.x = Math.random() * 1800 + 124; // Random X position with margins
obstacle.y = Math.random() * 1000 + 500; // Random Y position in middle area
obstacle.direction = Math.random() > 0.5 ? 1 : -1; // Random initial direction
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Check collision with obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
var currentIntersecting = ball.intersects(obstacle);
if (!obstacle.lastIntersecting && currentIntersecting) {
// Collision detected - game over
ball.isGrounded = true;
gameOver();
break;
}
obstacle.lastIntersecting = currentIntersecting;
}
// Remove obstacles that are too old (optional cleanup)
if (obstacles.length > 6) {
var oldObstacle = obstacles.shift();
oldObstacle.destroy();
}
}
};
// Initial score display
updateScore(); ===================================================================
--- original.js
+++ change.js
@@ -5,39 +5,28 @@
/****
* Classes
****/
-var Goal = Container.expand(function () {
+var Obstacle = Container.expand(function () {
var self = Container.call(this);
- // Goal frame
- var goalFrame = self.attachAsset('goal', {
+ // Create obstacle graphics
+ var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
- anchorY: 1.0
+ anchorY: 0.5
});
- 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;
+ // Movement properties
+ self.speed = 5;
+ self.direction = 1; // 1 for down, -1 for up
+ self.lastIntersecting = false;
+ self.update = function () {
+ // Move obstacle up and down
+ self.y += self.speed * self.direction;
+ // Reverse direction at screen boundaries
+ if (self.y <= 100) {
+ self.direction = 1;
+ } else if (self.y >= 2500) {
+ self.direction = -1;
+ }
};
return self;
});
var SoccerBall = Container.expand(function () {
@@ -54,17 +43,17 @@
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;
+ self.velocityX = 0;
+ self.gravity = 0.6;
+ self.bounceDamping = 0.8;
+ self.tapForce = -18;
+ self.maxVelocityY = 25;
+ self.maxVelocityX = 8;
// Game state
self.isGrounded = false;
self.lastY = 0;
- self.lastGoalCheck = false;
self.update = function () {
// Store last position
self.lastY = self.y;
// Apply gravity
@@ -78,16 +67,8 @@
}
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
@@ -102,67 +83,44 @@
self.velocityX = -Math.abs(self.velocityX) * self.bounceDamping;
LK.getSound('bounce').play();
}
// Ground collision detection
- if (self.y + ballRadius >= groundY) {
+ if (self.y + ballRadius >= 2732) {
if (!self.isGrounded) {
self.isGrounded = true;
- if (!goal.checkGoal(self)) {
- gameOver();
- } else {
- scoreGoal();
- }
+ gameOver();
}
}
- // Goal check
- var currentGoalCheck = goal.checkGoal(self);
- if (!self.lastGoalCheck && currentGoalCheck && !self.isGrounded) {
- scoreGoal();
- }
- self.lastGoalCheck = currentGoalCheck;
- // Add rotation for visual effect
+ // Add slight 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));
+ 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();
}
- 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;
});
/****
@@ -176,100 +134,98 @@
* 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;
+var obstacles = [];
+var obstacleSpawnTimer = 0;
+var obstacleSpawnInterval = 180; // Spawn every 3 seconds at 60fps
// UI elements
-var scoreTxt = new Text2('Goals: 0', {
+var scoreTxt = new Text2('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,
+var instructionTxt = new Text2('TAP TO KEEP THE BALL UP!', {
+ size: 80,
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;
+// Initialize ball
ball = game.addChild(new SoccerBall());
-ball.x = 200;
+ball.x = 1024;
ball.y = 1000;
function updateScore() {
- scoreTxt.setText('Goals: ' + score.toString());
+ scoreTxt.setText(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 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 gameOver() {
LK.showGameOver();
}
function startGame() {
if (!gameStarted) {
gameStarted = true;
instructionTxt.visible = false;
- ball.velocityX = 2 + Math.random() * 3;
- ball.velocityY = -2 - Math.random() * 3;
+ ball.applyTapForce();
+ // Clear any existing obstacles
+ for (var i = 0; i < obstacles.length; i++) {
+ obstacles[i].destroy();
+ }
+ obstacles = [];
+ obstacleSpawnTimer = 0;
}
}
// 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
- });
+ ball.applyTapForce();
}
};
-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();
+ // Game loop handled by ball's update method
+ if (gameStarted) {
+ // Spawn obstacles
+ obstacleSpawnTimer++;
+ if (obstacleSpawnTimer >= obstacleSpawnInterval) {
+ obstacleSpawnTimer = 0;
+ var obstacle = new Obstacle();
+ obstacle.x = Math.random() * 1800 + 124; // Random X position with margins
+ obstacle.y = Math.random() * 1000 + 500; // Random Y position in middle area
+ obstacle.direction = Math.random() > 0.5 ? 1 : -1; // Random initial direction
+ obstacles.push(obstacle);
+ game.addChild(obstacle);
+ }
+ // Check collision with obstacles
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ var obstacle = obstacles[i];
+ var currentIntersecting = ball.intersects(obstacle);
+ if (!obstacle.lastIntersecting && currentIntersecting) {
+ // Collision detected - game over
+ ball.isGrounded = true;
+ gameOver();
+ break;
+ }
+ obstacle.lastIntersecting = currentIntersecting;
+ }
+ // Remove obstacles that are too old (optional cleanup)
+ if (obstacles.length > 6) {
+ var oldObstacle = obstacles.shift();
+ oldObstacle.destroy();
+ }
}
};
// 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