Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Piksel

DirectInput trouble

This topic is 6920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m making a simple space invaders game so I can learn Directdraw and DirectInput, but the DInput is working. The spaceship kinda jitters around (like it is randomly changing the x-position by 1 and -1). ANyone know what the problem could be? Also it doesn''t change its jittering at all, when I press the keys. The game only uses the keyboard, thanx in advance.

Share this post


Link to post
Share on other sites
Advertisement
If you are storing the ships position in integers, the rounding off error will carry on to the next calculation. Try storing them as floats and it might get better.

Unless of course you''re already doing that...

*Sparkle*

Share this post


Link to post
Share on other sites
Try running the game without direct input and see if the jittering stops, this way you can tell weather the problem is with your direct input code or direct draw code.

+AA_970+

Share this post


Link to post
Share on other sites
Here''s some of my code:
if( g_pdidKeyboard )
{
HRESULT hRet;
BYTE diks[256]; // DInput keyboard state buffer

hRet = g_pdidKeyboard->GetDeviceState( sizeof(diks), &diks );
if( hRet == DIERR_INPUTLOST )
{
// DirectInput is telling us that the input stream has been
// interrupted. Re-acquire and try again.
hRet = g_pdidKeyboard->Acquire();
if( SUCCEEDED(hRet) )
return;
}
if( diks[DIK_LEFT] & 0x80 ) yourx = yourx - 1;
if( diks[DIK_RIGHT] & 0x80 ) yourx = yourx + 1;
}
When I take out the last 2 lines (about diks[DIK_LEFT} and diks[DIK_RIGHT]), the space ship just stays in one place, so it is a problem with the directinput.

Share this post


Link to post
Share on other sites
I think that should be

hRet = g_pdidKeyboard->GetDeviceState( sizeof(diks), diks );

&diks is a BYTE **, whereas the function wants a BYTE *.

Whoops, looks like I made that mistake in my code, too...

Share this post


Link to post
Share on other sites
I think I''m going to just rewrite all the DirectInput stuff (or rather cut and paste it from somewhere). Thanx anyways though.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!