rockout ship control with keyboard

BlitzMax Forums/BlitzMax Beginners Area/rockout ship control with keyboard

Hi !
Is it possible to adapt the rockout mouse ship control code to keyboard ?
Thanks !

Mouse
Graphics 800,600

Const cte_div = 5

HideMouse()

MoveMouse GraphicsWidth()/2, GraphicsHeight() / 2

PosX = MouseX()
PosY = MouseY()


While Not KeyDown (KEy_ESCAPE)
								
            xdist# = MouseX() - Posx
            ydist# = MouseY() - Posy
            xs = xdist / cte_div
            ys = ydist / cte_div
            Posx = Posx + xs
            Posy = Posy + ys
	
Cls
SetColor 255,255,255
DrawOval PosX-25, PosY-25, 50,50
SetColor  255,0,0
DrawOval MouseX()-3, MouseY()-3,6,6

Flip

Wend

ShowMouse()


My poor keyboard conversion ;-( Not produce the same effect !
Graphics 800,600

Const cte_div = 5

destx = GraphicsWidth()/2
desty = GraphicsHeight() / 2

PosX = destx
PosY = desty

While Not KeyDown (KEy_ESCAPE)
								
	xdist# = destx - Posx
	ydist# = desty - Posy
	xs = xdist / cte_div
	ys = ydist / cte_div
	Posx = Posx + xs
	Posy = Posy + ys

	If KeyDown (KEy_UP) Then desty = desty - 3
	If KeyDown (KEy_DOWN) Then desty = desty + 3
	If KeyDown (KEy_LEFT) Then destx = destx - 3
	If KeyDown (KEy_RIGHT) Then destx = destx + 3
	
Cls
SetColor 255,255,255
DrawOval PosX-25, PosY-25, 50,50
SetColor  255,0,0
DrawOval destx-3, desty-3,6,6

Flip

Wend