Right... So, I've been trying to implement the example you showed. It almost works. Almost
Here's what I have:
- The keystates are being stored in variables
- The program checks whether a key is pressed and stores this state as 1 or 0
- The program uses less loops to accomplish this all
Which boils down to this:
`------------------------------------------------------
` Set screen and variables for timer-based movement
`------------------------------------------------------
autocam on
color backdrop 0
sync on : sync rate 60
make matrix 1,5000,5000,50,50
set matrix height 1,25,25,500
update matrix 1
#constant StepSpeed = 10
global oldTime, difTime, key
oldTime = timer() : key = 0
`------------------------------------------------------
` Loop for displaying matrix and checking for key input
`------------------------------------------------------
do
difTime = timer() - oldTime
oldTime = timer()
text 0,0, "Use WASD or arrow-keys to move. Esc to exit."
text 0,20,"Scancode: "+str$(scancode())
text 0,30,"key : "+str$(key)
k17 = keystate(17) : k72 = keystate(72) : k200 = keystate(200) ` forward
k31 = keystate(31) : k45 = keystate(45) : k80 = keystate(80) : k208 = keystate(208) ` backward
k30 = keystate(30) : k75 = keystate(75) : k203 = keystate(203) ` left
k32 = keystate(32) : k72 = keystate(72) : k205 = keystate(205) ` right
k16 = keystate(16) : k71 = keystate(71) ` turn left
k18 = keystate(18) : k73 = keystate(73) ` turn right
if key = 0
if k17 or k72 or k200 then MoveForward(difTime) : key = 1
if k31 or k45 or k80 or k208 then MoveBackward(difTime) : key = 2
if k30 or k75 or k203 then MoveLeft(difTime) : key = 8
if k32 or k77 or k205 then MoveRight(difTime) : key = 4
else
if k17 = 0 and k72 = 0 and k200 = 0 then key = 0
if k31 = 0 and k45 = 0 and k80 = 0 and k208 = 0 then key = 0
if k30 = 0 and k75 = 0 and k203 = 0 then key = 0
if k32 = 0 and k77 = 0 and k205 = 0 then key = 0
endif
xrotate camera 0,x#:yrotate camera 0,y#:zrotate camera 0,z#
sync
loop
delete matrix 1
autocam off
end
`------------------------------------------------------
` Functions for movement
`------------------------------------------------------
Function MoveForward(difTime)
move camera 0,StepSpeed*difTime
endfunction
Function MoveBackward(difTime)
move camera 0,StepSpeed*-difTime
endfunction
Function MoveLeft(difTime)
move camera left 0,StepSpeed*difTime
endfunction
Function MoveRight(difTime)
move camera right 0,StepSpeed*difTime
endfunction
For some reason though, the step-by-step part isn't functioning anymore. I've spend a lot of time going over your examples and trying stuff.. but to no avail. I think I'm missing something quite small, but also quite essential