Created
January 20, 2012 20:15
-
-
Save 525c1e21-bd67-4735-ac99-b4b0e5262290/1649348 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
player = db.player | |
force = db.player.force | |
keyboard = db.devices.keyboard | |
vec3.set vec3.zero, force | |
if keyboard.keys['W'] | |
vec3.add force, vec3.zUnitInv | |
if keyboard.keys['S'] | |
vec3.add force, vec3.zUnit | |
if keyboard.keys['A'] | |
vec3.add force, vec3.xUnitInv | |
if keyboard.keys['D'] | |
vec3.add force, vec3.xUnit | |
vec3.normalize force | |
vec3.scale force, player.speed | |
quat4.multiplyVec3 camera.orientation, force | |
if (vec3.length force) > 0 | |
player.emit 'move' | |
vec3.add camera.position, force | |
vec3.set camera.position, db.player.position | |
camera.update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment