File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 33}
44
55div .clouds {
6- padding-top : 100px ;
6+ padding-top : 0px ;
7+ position : absolute;
8+
79}
810
911div .cloud {
Original file line number Diff line number Diff line change 11var cylinder ;
2+ var screenHeight = screen . height ;
3+ var jumpBy = 10 ;
24
35function startGame ( ) {
46 cylinder = $ ( "#cylinder" ) ;
57 jump ( 10 ) ;
68}
79
8- function jump ( jumpBy ) {
9- var currentPosition = cylinder . css ( 'top' ) ;
10- alert ( currentPosition ) ;
10+ function jump ( ) {
11+ var cylinderDimension = cylinder . offset ( ) ;
12+ var currentPosition = cylinderDimension . top ;
13+ var bottomPosition = 320 + currentPosition ;
14+ var newPosition = currentPosition + jumpBy ;
15+
16+ if ( bottomPosition >= screenHeight ) {
17+ cylinder . css ( 'top' , '0px' ) ;
18+ } else {
19+ cylinder . css ( 'top' , newPosition + "px" ) ;
20+ }
21+ setTimeout ( jump , 30 ) ;
1122}
1223
1324startGame ( ) ;
You can’t perform that action at this time.
0 commit comments