Skip to content

Commit 9404e9d

Browse files
committedFeb 9, 2024
Fixed ball positioning and removed randomness to prevent loops early on
1 parent 1a972a7 commit 9404e9d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
 

‎index.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@
162162
}
163163
}
164164

165-
day.ball.x = Ball.RADIUS + Math.ceil(numSquaresX / 4) * Square.SIZE;
166-
day.ball.y = Ball.RADIUS + Math.floor(numSquaresY / 2) * Square.SIZE;
167-
day.ball.dx = getRandomSign();
168-
day.ball.dy = getRandomSign();
169-
170-
night.ball.x = Ball.RADIUS + Math.floor(3 * numSquaresX / 4) * Square.SIZE;
171-
night.ball.y = Ball.RADIUS + Math.floor(numSquaresY / 2) * Square.SIZE;
172-
night.ball.dx = getRandomSign();
173-
night.ball.dy = getRandomSign();
165+
day.ball.x = (numSquaresX / 4) * Square.SIZE;
166+
day.ball.y = (numSquaresY / 4) * Square.SIZE;
167+
day.ball.dx = 1;
168+
day.ball.dy = 1;
169+
170+
night.ball.x = (3 * numSquaresX / 4) * Square.SIZE;
171+
night.ball.y = (3 * numSquaresX / 4) * Square.SIZE;
172+
night.ball.dx = -1;
173+
night.ball.dy = 1;
174174

175175
function calculateDistance(p1, p2) {
176176
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2))

0 commit comments

Comments
 (0)