開発環境
- macOS Sierra - Apple (OS)
- Emacs (Text Editor)
- JavaScript (プログラミング言語)
- three.js (JavaScript Library)
- Safari (Web Browser)
3D Game Programming for Kids: Create Interactive Worlds with JavaScript (Chris Strom(著)、Pragmatic Bookshel)の Chapter 6(Project: Moving Hands and Feet)の Challenge: Better Acrobatics Controls を取り組んでみる。
コード(Emacs)
document.addEventListener('keydown', (event) => { let code = event.keyCode; if (code === 37) { // left marker.position.x -= 5; isMovingLeft = true; } else if (code === 38) { // up marker.position.z -= 5; isMovingForward = true; } else if (code === 39) { // right marker.position.x += 5; isMovingRight = true; } else if (code === 40) { // down marker.position.z += 5; isMovingBack = true; } else if (code === 67) { // c isCartwheeling = true; } else if (code === 70) { // f isFlipping = true; } }); document.addEventListener('keyup', (event) => { let code = event.keyCode; if (code === 37) { // left isMovingLeft = false;; } else if (code === 38) { // up isMovingForward = false;; } else if (code === 39) { // right isMovingRight = false;; } else if (code === 40) { // down isMovingBack = false;; } else if (code === 67) { // c isCartwheeling = false;; } else if (code === 70) { // f isFlipping = false;; } });
0 コメント:
コメントを投稿