Limiting KeyDown

BlitzPlus Forums/BlitzPlus Programming/Limiting KeyDown

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The below code limits movement to a single axis giving preference to the y axis. Arrange it with left and right first and you will give preference to the x axis.

; I make UP, DOWN, LEFT, RIGHT global variables that can be defined as any key. 
;This is great as it allows for user defined keyboard set ups.

If keydown(UP) Then
 ; add code here to move object accordingly
ElseIf keydown(DOWN) Then
 ; add code here to move object accordingly
ElseIf keydown(LEFT) Then
 ; add code here to move object accordingly
ElseIf keydown(RIGHT) Then
 ; add code here to move object accordingly
EndIf