Moving Diagonally

Blitz3D Forums/Blitz3D Beginners Area/Moving Diagonally

Mr. Shen(Posted 2004) [#1]
Hello hello,

I was wondering how one would get a sprite to move diagonally. I tried doing a "If keydown(up) and keydown(right) then..." type thing, but that doesn't seem to work.

Right now it's just one large if statement determining what direction you're pressing and will later include a "fire" button as well as a "bomb" button.



Thanks!


SoggyP(Posted 2004) [#2]
Greetings Puppies,

Try splitting the If statement above into two sections, one dealing with ship_y and one dealing with ship_x.

Peace,

Jes


Mr. Shen(Posted 2004) [#3]
Thanks! Works great and makes sense.


Drekinn(Posted 2004) [#4]
You can do away with all those DrawImage commands.
You only need to put it once before Flip.


xMicky(Posted 2004) [#5]
It works also on that way:


Graphics3D 640,480

cam = CreateCamera()
MoveEntity cam,0,0,-5

sp = CreateSprite()
RotateSprite sp,20

While Not KeyDown(1)

If KeyDown(200) And KeyDown(205) Then
;this statement first, otherweise each of those two
; would be catched either by
; If KeyDown(200)... or
; If KeyDown(205)...
MoveEntity sp,.1,.1,0

ElseIf KeyDown(200) Then ; up
MoveEntity sp,0,.1,0
ElseIf KeyDown(203) Then ;left
MoveEntity sp,-.1,0,0


ElseIf KeyDown(205) Then ;right
MoveEntity sp,.1,0,0

ElseIf KeyDown(208) Then ;down
MoveEntity sp,0,-.1,0
EndIf

RenderWorld
Text 10,10, "UP : " +Str$(KeyDown(200))
Text 10,30, "RIGHT : " +Str$(KeyDown(205))
Text 10,50, "DOWN : " +Str$(KeyDown(208))
Text 10,70, "LEFT : " +Str$(KeyDown(203))


Flip

Wend
End