DirectInput trouble
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.
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*
Unless of course you''re already doing that...
*Sparkle*
You probably want to make sure that you have two surfaces and flip in between them.
Cool cod''n =)
Cool cod''n =)
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+
+AA_970+
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.
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.
I think that should be
&diks is a BYTE **, whereas the function wants a BYTE *.
Whoops, looks like I made that mistake in my code, too...
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement