Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 DirectInput Problems...

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
Krisc Posted - May 30 2004 : 10:46:14 AM
Hey, I have been working on my game and ran into a road block... My DirectInput works, but it is erroneous...the problem is when I move my ship left (Key.LeftArrow) and then fire the weapon (Key.SpaceBar) the ship decides to stop all together and the weapon fires. I was wondering how I make DirectInput work in a way so that I can hit many keys at once and have them all register and make it so the ship moves and fires the weapon at the same time. Here is the code for detecting key hits...if you would like to see my DirectInput class just ask and I'll put it up...Thanks!

By the way, I know the code is in C# but it is very simple to read...
myInput is my DirectInput class and
myInput.checkKey(Key k) just returns a true if k is pressed and false if it isn't.

  
private void checkKeys()  
{  
    if(myInput.InputCount <= 0)  
    {  
        if(bMenu)  
        {  
            if(myInput.checkKey(DI.Key.Escape))  
            {  
                bMenu = !bMenu;  
                myInput.InputCount = 50;  
            }  
            else if(myInput.checkKey(DI.Key.Pause))  
                app.Dispose();  
        }  
        else  
        {  
            if(myInput.checkKey(DI.Key.LeftArrow))  
                myPlayer.MoveLeft();  
            else if(myInput.checkKey(DI.Key.RightArrow))  
                myPlayer.MoveRight();  
            else if(myInput.checkKey(DI.Key.UpArrow))  
                myPlayer.MoveUp();  
            else if(myInput.checkKey(DI.Key.DownArrow))  
                myPlayer.MoveDown();  
            else if(myInput.checkKey(DI.Key.Escape))  
            {  
                bMenu = !bMenu;  
                myInput.InputCount = 50;  
            }  
            else if(myInput.checkKey(DI.Key.Pause))  
                app.Dispose();  
            else  
                myPlayer.ReturnToCenter();  
  
            if(myInput.checkKey(DI.Key.Space))  
            {  
                //tW.Fire(512,500);  
                myPlayer.Fire();  
                myInput.InputCount = 50;  
            }  
        }  
    }  
}  
  


Again much thanks if you can help my fix this.

EDIT: Hmm...the code tag doesn't recognize tabs. I am sorry for that. Ok, well basically what InputCount does is it makes sure that there are pauses before certain key presses, so the weapon doesn't fire off all 10 rounds in a second for instance. Well I made a separate counter for the weapon and it was fixed...but I still think the way I am going about getting input is wrong. Any advice or insight would be greatly appreciated! Thanks.
1   L A T E S T    R E P L I E S    (Newest First)
sdw Posted - May 30 2004 : 11:18:41 AM
Looks to me that it's your conditional statements. Looks like the check for movement is in the If statements and the check for firing is in an Else If statement. And you're right, it's kinda hard to see without tabs but I tried to tab them in myself with notepad. See if this will work:

  
private void checkKeys() {  
    if(myInput.InputCount <= 0) {  
        if(bMenu) {  
            if(myInput.checkKey(DI.Key.Escape)) {  
                bMenu = !bMenu;  
                myInput.InputCount = 50;  
            }  
            else if(myInput.checkKey(DI.Key.Pause))  
                app.Dispose();  
            else {  
                if(myInput.checkKey(DI.Key.LeftArrow))  
                    myPlayer.MoveLeft();  
                else if(myInput.checkKey(DI.Key.RightArrow))  
                    myPlayer.MoveRight();  
                else if(myInput.checkKey(DI.Key.UpArrow))  
                    myPlayer.MoveUp();  
                else if(myInput.checkKey(DI.Key.DownArrow))  
                    myPlayer.MoveDown();  
                else if(myInput.checkKey(DI.Key.Escape)) {  
                    bMenu = !bMenu;  
                    myInput.InputCount = 50;  
                }  
                else if(myInput.checkKey(DI.Key.Pause))  
                    app.Dispose();  
                else  
                    myPlayer.ReturnToCenter();  
            }  
  
            if(myInput.checkKey(DI.Key.Space)) {  
                //tW.Fire(512,500);  
                myPlayer.Fire();  
                myInput.InputCount = 50;  
            }  
        }  
    }  
}  
  

VBGamer © Go To Top Of Page
This page was generated in 0.09 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.