File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ scene.add( plane );
5252
5353scene . background = new THREE . Color ( 0x99ffff ) ;
5454
55- var jumping = false ;
55+ var jumping = doublejumping = false ;
5656var jump_distance = 0.1 ;
5757var acceleration = 0.0025 ;
5858var acceleration_step = 0.0025 ;
@@ -97,10 +97,16 @@ var animate = function () {
9797 }
9898
9999 if ( keyboard . pressed ( "space" ) ) {
100+ if ( jumping && ! doublejumping && jump_distance < 0.07 ) {
101+ jump_distance = 0.1 ;
102+ acceleration_step = acceleration ;
103+ doublejumping = true ;
104+ }
105+
100106 jumping = true ;
101107 }
102108
103- if ( jumping ) {
109+ if ( jumping || doublejumping ) {
104110 acceleration_step = acceleration_step * ( 1 + acceleration ) ;
105111
106112 jump_distance -= acceleration_step ;
@@ -109,7 +115,7 @@ var animate = function () {
109115 }
110116
111117 if ( player . position . y < initial_y ) { // hit the "ground"
112- jumping = false ;
118+ jumping = doublejumping = false ;
113119
114120 // reset our acceleration calculations
115121 jump_distance = 0.1 ;
You can’t perform that action at this time.
0 commit comments