File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
bootcamp_content/projects/breakout/exercises/bouncy-ball Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 14
14
height : 4% ;
15
15
position : absolute;
16
16
left : 50% ;
17
- top : 96 % ;
18
- transform : translateX (-5 % );
17
+ top : 98 % ;
18
+ transform : translateX (-50 % ) translateY ( -50 % );
19
19
background : white;
20
20
}
Original file line number Diff line number Diff line change 1
1
const ball = {
2
- speed : 0.5 ,
2
+ speed : 0.1 ,
3
3
size : 4 ,
4
- left : 50 ,
5
- top : 96 ,
4
+ left : 48 ,
5
+ top : 98 ,
6
6
}
7
7
ball . velocityX = - 1 * ball . speed
8
8
ball . velocityY = - 1 * ball . speed
@@ -11,16 +11,16 @@ function updateBallCoordinates() {
11
11
ball . left += ball . velocityX
12
12
ball . top += ball . velocityY
13
13
14
- if ( ball . left < 0 ) {
14
+ if ( ball . left < 0 + ball . size / 2 ) {
15
15
ball . velocityX = 1 * ball . speed
16
16
}
17
- if ( ball . left > 100 - ball . size ) {
17
+ if ( ball . left > 100 - ball . size / 2 ) {
18
18
ball . velocityX = - 1 * ball . speed
19
19
}
20
- if ( ball . top < 0 ) {
20
+ if ( ball . top < 0 + ball . size / 2 ) {
21
21
ball . velocityY = 1 * ball . speed
22
22
}
23
- if ( ball . top > 100 - ball . size ) {
23
+ if ( ball . top > 100 - ball . size / 2 ) {
24
24
ball . velocityY = - 1 * ball . speed
25
25
}
26
26
return true
You can’t perform that action at this time.
0 commit comments