Skip to content

Commit e529d99

Browse files
committed
Fix example bouncy ball
1 parent 4a616bd commit e529d99

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

bootcamp_content/projects/breakout/exercises/bouncy-ball/example.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ body {
1414
height: 4%;
1515
position: absolute;
1616
left: 50%;
17-
top: 96%;
18-
transform: translateX(-5%);
17+
top: 98%;
18+
transform: translateX(-50%) translateY(-50%);
1919
background: white;
2020
}

bootcamp_content/projects/breakout/exercises/bouncy-ball/example.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const ball = {
2-
speed: 0.5,
2+
speed: 0.1,
33
size: 4,
4-
left: 50,
5-
top: 96,
4+
left: 48,
5+
top: 98,
66
}
77
ball.velocityX = -1 * ball.speed
88
ball.velocityY = -1 * ball.speed
@@ -11,16 +11,16 @@ function updateBallCoordinates() {
1111
ball.left += ball.velocityX
1212
ball.top += ball.velocityY
1313

14-
if (ball.left < 0) {
14+
if (ball.left < 0 + ball.size / 2) {
1515
ball.velocityX = 1 * ball.speed
1616
}
17-
if (ball.left > 100 - ball.size) {
17+
if (ball.left > 100 - ball.size / 2) {
1818
ball.velocityX = -1 * ball.speed
1919
}
20-
if (ball.top < 0) {
20+
if (ball.top < 0 + ball.size / 2) {
2121
ball.velocityY = 1 * ball.speed
2222
}
23-
if (ball.top > 100 - ball.size) {
23+
if (ball.top > 100 - ball.size / 2) {
2424
ball.velocityY = -1 * ball.speed
2525
}
2626
return true

0 commit comments

Comments
 (0)