Browse Source

add jump action and update instructions (#8654)

Hu Jiulong 9 years ago
parent
commit
508e4d6314
1 changed files with 5 additions and 1 deletions
  1. 5 1
      examples/misc_fps.html

+ 5 - 1
examples/misc_fps.html

@@ -30,7 +30,7 @@
 	<body>
 	<body>
 
 
 		<div id="container"></div>
 		<div id="container"></div>
-		<div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - platformer demo. cubemap by <a href="http://www.zfight.com/" target="_blank">Jochum Skoglund</a>.<br />Use arrow keys to look around and WASD to move.</div>
+		<div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - platformer demo. cubemap by <a href="http://www.zfight.com/" target="_blank">Jochum Skoglund</a>.<br />Use arrow keys to look around, WASD to move and SPACE to jump.</div>
 
 
 		<script src="../build/three.js"></script>
 		<script src="../build/three.js"></script>
 
 
@@ -101,6 +101,10 @@
 						if( Math.abs( combined.x ) >= Math.abs( motion.velocity.x ) ) motion.velocity.x = combined.x;
 						if( Math.abs( combined.x ) >= Math.abs( motion.velocity.x ) ) motion.velocity.x = combined.x;
 						if( Math.abs( combined.y ) >= Math.abs( motion.velocity.y ) ) motion.velocity.y = combined.y;
 						if( Math.abs( combined.y ) >= Math.abs( motion.velocity.y ) ) motion.velocity.y = combined.y;
 						if( Math.abs( combined.z ) >= Math.abs( motion.velocity.z ) ) motion.velocity.z = combined.z;
 						if( Math.abs( combined.z ) >= Math.abs( motion.velocity.z ) ) motion.velocity.z = combined.z;
+
+						//jump
+ 						var vy = keysPressed[keys.SP] ? 0.7 : 0;
+ 						motion.velocity.y += vy;
 					}
 					}
 				};
 				};
 			})();
 			})();