Problems with keys?

BlitzMax Forums/BlitzMax Programming/Problems with keys?

orgos(Posted 2006) [#1]
Strict

SetGraphicsDriver GLMax2DDriver()

Graphics 640, 480, 16, 60

Global img:tImage = LoadImage("images/1.png")

Global x:Int
Global y:Int

Repeat


If (KeyDown(KEY_RIGHT))
x:+2
End If


If (KeyDown(KEY_LEFT))
x:-2
End If

If (KeyDown(KEY_UP))
y:-2
End If

If (KeyDown(KEY_DOWN))
y:+2
End If


DrawImage img, x, y


Flip
Cls

Until (KeyHit(KEY_ESCAPE))

EndGraphics()
End


When i Press simultaneous, (Up and Left) and (Up and Rigth) and (Down and Left ) and space key the image move well. In the code i don't chek the space key but when i press Down and Right and Space keys the image don't move. Any idea?.

Only happen with space key.


skidracer(Posted 2006) [#2]
Which is why I think PC games tend to use Ctrl/Alt for fire as this is a hardware problem with the way standard PC keyboard is designed (pull your keyboard apart and you will find keys are connected to a membrane that is a multiplexed 8x8 matrix or some such).


xlsior(Posted 2006) [#3]
Yup... Some keys combinations mean other keys don't work. If you keep them pressed anyway, your computer will start beeping (through the PC bleeper)

Happens in any program, just try to press that combination in notepad for example... Like skidracer said, that's why many keyboard games use the CTRL and ALT keys, since the modifier keys (ctrl, alt, shift, etc.) don't lock out any of the 'normal' keys.

So... long story short, it's the same hardware limitation that has plagued PC's for the past 20 years... Nothing you can do about it, other than to pick your key assignments carefully to minimize possible conflicts.


Grey Alien(Posted 2006) [#4]
yeah I found this out years ago with Doom when I made some different key assignment. I couldn't strafe and walk backwards at the same time. It's cropped up in a couple of games since with weird keys, but some keyboards seem better than others.


orgos(Posted 2006) [#5]
Thanks for the answers.