Can anyone shed a little light on this?

Just starting out? Need help? Post your questions and find answers here.
mrbicrevise
User
User
Posts: 14
Joined: Thu Aug 21, 2003 2:58 pm
Contact:

Can anyone shed a little light on this?

Post by mrbicrevise »

Below is a fragment of code from a really simple program that moves a sprite across the screen, which is sped up by pressing the right shift key. What's driving me nuts is the fact that, while this works fine for all combinations of up (W), down (S) and left (A), it doesn't work at all for right (D) and down when pressed at the same time.

Could anyone explain why this is?

Code: Select all


    ExamineKeyboard()
    ExamineMouse() 
    
    speed = 10
    If KeyboardPushed(#PB_Key_RightShift)
    speed = 30
    EndIf
    
    
     If KeyboardPushed(#PB_Key_W)
        y = y + speed
      EndIf
      
     If KeyboardPushed(#PB_Key_S)   
        y = y - speed
      EndIf
      
     If KeyboardPushed(#PB_Key_D)  
        x = x - speed
      EndIf 
      
        If KeyboardPushed(#PB_Key_A)   
        x = x + speed
      EndIf
Life is too important to be taken seriously.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Some combinations of Keys doesn't work on all Keyboards.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
mrbicrevise
User
User
Posts: 14
Joined: Thu Aug 21, 2003 2:58 pm
Contact:

Post by mrbicrevise »

Just tried it with the directional arrows, works fine now. Thanks :D
Life is too important to be taken seriously.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply