rem First-person camera: WASD - OpenDBC tutorial (DarkBASIC Professional) sync on : sync rate 60 autocam off color backdrop rgb(140, 180, 225) make object box 1, 600, 1, 600 color object 1, rgb(70, 115, 70) for n = 2 to 40 make object cube n, 10 + rnd(10) position object n, rnd(400) - 200, 8, rnd(400) - 200 color object n, rgb(150 + rnd(60), 120 + rnd(40), 80) next n position camera 0, 12, -150 do rem Left and right arrows turn; W and S walk, A and D step sideways if leftkey() = 1 then yaw# = wrapvalue(yaw# - 2) if rightkey() = 1 then yaw# = wrapvalue(yaw# + 2) speed# = 0.0 : side# = 0.0 if keystate(17) = 1 then speed# = 1.5 if keystate(31) = 1 then speed# = -1.5 if keystate(30) = 1 then side# = -1.5 if keystate(32) = 1 then side# = 1.5 x# = camera position x() + sin(yaw#) * speed# + cos(yaw#) * side# z# = camera position z() + cos(yaw#) * speed# - sin(yaw#) * side# position camera x#, 12, z# yrotate camera yaw# text 10, 10, "W A S D: walk Left and right: turn" sync loop