Skip to content

Commit 508e4d6

Browse files
hujiulongmrdoob
authored andcommitted
add jump action and update instructions (mrdoob#8654)
1 parent ba397e1 commit 508e4d6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/misc_fps.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<body>
3131

3232
<div id="container"></div>
33-
<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>
33+
<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>
3434

3535
<script src="../build/three.js"></script>
3636

@@ -101,6 +101,10 @@
101101
if( Math.abs( combined.x ) >= Math.abs( motion.velocity.x ) ) motion.velocity.x = combined.x;
102102
if( Math.abs( combined.y ) >= Math.abs( motion.velocity.y ) ) motion.velocity.y = combined.y;
103103
if( Math.abs( combined.z ) >= Math.abs( motion.velocity.z ) ) motion.velocity.z = combined.z;
104+
105+
//jump
106+
var vy = keysPressed[keys.SP] ? 0.7 : 0;
107+
motion.velocity.y += vy;
104108
}
105109
};
106110
})();

0 commit comments

Comments
 (0)