Why doesn't it go left or right?

Blitz3D Forums/Blitz3D Beginners Area/Why doesn't it go left or right?

I'll try and explain whats going on in:

rec_y=rec_y+(KeyDown(208)-KeyDown(200))*5


When you use KeyDown() to test the status of a key Blitz will return a value of 1 if the key being pressed. Otherwise it returns a value of 0

Ok, lets make the above code a little clearer by replacing the 208 and 200 with CURSORDOWN and CURSORUP:
rec_y=rec_y+(KeyDown(CURSORDOWN)-KeyDown(CURSORUP))*5


Here is what happens when you hold the 'cursor down' key:
rec_y=rec_y+(KeyDown(CURSORDOWN)-KeyDown(CURSORUP))*5

becomes

rec_y=rec_y+(1-0)*5

This results in a value of 5


Here is what happens when you hold the 'cursor up' key:
rec_y=rec_y+(KeyDown(CURSORDOWN)-KeyDown(CURSORUP))*5

becomes

rec_y=rec_y+(0-1)*5

This results in a value of -5

So, holding cursor DOWN gives 5 and holding cursor UP gives -5.
Hope that helps.