File tree Expand file tree Collapse file tree
fsd-projects/bouncing-box Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 < title > Bouncing Box</ title >
66 < script src ="jquery.min.js "> </ script >
77 < style >
8+ body {
9+ background-image : url ("https://cdnb.artstation.com/p/assets/images/images/043/396/311/large/eugene-ball-animation-background.jpg?1637151506" );
10+ background-color : # 555 ;
11+ }
812 .box {
9- width : 70px ;
10- height : 70px ;
11- background-color : teal;
13+ width : 200px ;
14+ height : 200px ;
15+ background-image : url ("https://pngimg.com/uploads/birds/birds_PNG115.png" );
16+ background-color : # 5B9C99 ;
1217 font-size : 300% ;
1318 text-align : center;
1419 user-select : none;
6974 //////////////////////////////////////////////////////////////////
7075
7176 // TODO 2 - Variable declarations
72-
73-
74-
77+ var positionX = 0 ;
78+ var points = 0 ;
79+ var speed = 10 ;
7580
7681
7782 /**
8085 * If the box drifts off the screen, turn it around!
8186 */
8287 function update ( ) {
83-
84-
85-
88+ moveBoxTo ( positionX ) ; //Moves the box to x-position 200
89+ positionX = positionX += speed ;
90+ if ( positionX > boardWidth ) {
91+ speed *= - 1 ;
92+ }
93+
94+ else if ( positionX < 0 ) {
95+ speed *= - 1 ;
96+ }
8697
8798 }
8899
93104 * - increase the speed
94105 * - move the box to the left side of the screen.
95106 */
96- function handleBoxClick ( ) {
97-
98-
99-
100-
107+ function handleBoxClick ( ) {
108+ positionX = 0 ;
109+ changeBoxText ( points ) ;
110+ points ++ ;
111+ speed = 3 * points + 10 ;
101112 }
102113
103114
You can’t perform that action at this time.
0 commit comments