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 3
3
}
4
4
5
5
div .clouds {
6
- padding-top : 100px ;
6
+ padding-top : 0px ;
7
+ position : absolute;
8
+
7
9
}
8
10
9
11
div .cloud {
Original file line number Diff line number Diff line change 1
1
var cylinder ;
2
+ var screenHeight = screen . height ;
3
+ var jumpBy = 10 ;
2
4
3
5
function startGame ( ) {
4
6
cylinder = $ ( "#cylinder" ) ;
5
7
jump ( 10 ) ;
6
8
}
7
9
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 ) ;
11
22
}
12
23
13
24
startGame ( ) ;
You can’t perform that action at this time.
0 commit comments