User prompt
add a small flash of text that says “+1” every time there is a score
User prompt
Change the background to a basketball court
User prompt
Make each obstacle have its own radius of damage
User prompt
Make obstacles move in randomly sized circular patterns
User prompt
Allow obstacles to move both clockwise and counterclockwise
User prompt
Obstacles must initially appear at least 3 squares away from the ball
User prompt
Randomize obstacle positions
User prompt
Spread out the obstacles more
User prompt
Make the obstacles only move around inside of the screen limit
User prompt
Make each obstacle move asynchronously
User prompt
Make 9 more obstacles
User prompt
Make the obstacles move around the screen
User prompt
Add obstacles that end the game when hit
User prompt
Randomize the position of the goal each game
Initial prompt
Basketball Bangers
===================================================================
--- original.js
+++ change.js
@@ -41,8 +41,9 @@
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.radius = Math.random() * 50 + 50; // radius of damage, random between 50 and 100
});
/****
* Initialize Game
@@ -95,20 +96,22 @@
}
// Check for collision with obstacles
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
- if (ball.intersects(obstacle)) {
+ var dx = ball.x - obstacle.x;
+ var dy = ball.y - obstacle.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < obstacle.radius) {
LK.showGameOver();
}
- // Move the obstacle around the screen in randomly sized circular patterns
+ // Move the obstacle around the screen asynchronously
// Alternate between clockwise and counterclockwise movement for each obstacle
- var radius = Math.random() * 100 + 50; // Random radius between 50 and 150
if (i % 2 == 0) {
- obstacle.x += radius * Math.cos((LK.ticks + i * 6) / 60);
- obstacle.y += radius * Math.sin((LK.ticks + i * 6) / 60);
+ obstacle.x += Math.cos((LK.ticks + i * 6) / 60) * 5;
+ obstacle.y += Math.sin((LK.ticks + i * 6) / 60) * 5;
} else {
- obstacle.x -= radius * Math.cos((LK.ticks + i * 6) / 60);
- obstacle.y -= radius * Math.sin((LK.ticks + i * 6) / 60);
+ obstacle.x -= Math.cos((LK.ticks + i * 6) / 60) * 5;
+ obstacle.y -= Math.sin((LK.ticks + i * 6) / 60) * 5;
}
// Restrict obstacle movement within screen limits
if (obstacle.x < 0) {
obstacle.x = 0;