DInput_Retrieve_Keyboard_Input();
if(KEYDOWN(g_keyboard, DIK_RIGHT))
{
//spcman->facingl = false;
spcman->facingr = true;
spcman->width = 6;
spcman->moving = true;
//spcman->xv = 3;
spcman->Set_Animation_Sprite(Runr, Runrp);
//return true;
}
else if(KEYDOWN(g_keyboard, DIK_LEFT))
{
spcman->facingr = false;
//spcman->facingl = true;
spcman->width = 6;
spcman->moving = true;
//spcman->xv = 3;
spcman->Set_Animation_Sprite(Runl, Runlp);
//return true;
}
else
{
spcman->moving = false;
}
if(spcman->facingr == true && !KEYDOWN(g_keyboard, DIK_RIGHT) && !KEYDOWN(g_keyboard, DIK_LEFT) && !KEYDOWN(g_keyboard, DIK_DOWN) && !KEYDOWN(g_keyboard, DIK_UP) && spcman->moving == false)
{
spcman->width = 3;
spcman->Set_Animation_Sprite(Standr, Standrp);
//return true;
}
else if(spcman->facingr == false && !KEYDOWN(g_keyboard, DIK_RIGHT) && !KEYDOWN(g_keyboard, DIK_LEFT) && !KEYDOWN(g_keyboard, DIK_DOWN) && !KEYDOWN(g_keyboard, DIK_UP) && spcman->moving == false)
{
spcman->width = 3;
spcman->Set_Animation_Sprite(Standl, Standlp);
//return true;
}
Uh huh - and that''s supposed to make sense to you ?
No - so I will begine to explain...
I assure that DirectX and Direct Input and Direct Draw all are working and initialized. That function right at the beginning merely sets the global (g_keyboard - an unsigned char [256]) to hold the keyboard values. The macro KEYDOWN is defined like so
#define KEYDOWN(name, key) (name[key] & 80)
Yes this was taken straight from the DirectX8 docs.
The spcman is just part of class that works perfectly fine. The Set_Animation_Sprite just takes an array and a point where to read the animation... Of course some of the animations differ in width and height.
Now the big ol'' function is called in the main game loop - so it''s called over and over again... unfortunately it runs into a problem after a few keys are pressed which makes these errors :
Invalid Rectangle - from the blit function
Could not retrieve Keyboard Input - from the function right at the beginning...
This is probably because of unfortunate ambiguities of the width and height and possibly whether he''s facing left or right... hmmm...
This is what is supposed to happen
He presses right - the width is set to the right number and the Animation set to the right animation and he faces right
He presses left - the same as above except he faces left.
He presses nothing - Just plays the animation standing there depending on whether hes facing right or left.
Is there any way around this logic or a more precise way of doing this?
I need help!
Thanks,
Destroyer
Ugly Direct Input and Direct Draw problems... help please
Hi,
Well I got my Direct Draw system working adn I gota good Direct Input library that I wrote myself also that also works. When I combined the two - that''s when terror stuck...
Duh duh duuh... (*Scary cheesy music plays*)
Well I can guarentee you that the functions themselves work perfectly fine - but before I go into any explination take a look at the code first.
Well one problem your going to have, is that this loop or sequence is getting called 100 pre millisecond, that''s pretty damn fast. So you guy could be moving at incredible speed. say off the sceen in under half a sec. And once off the screen it would explain why your getting the invalid rect fromt he blit, because your trying to blit to something that dosen''t exsist. I recommend, decreses the speed he moves at to a literal crawl say while key down, move by 0.00001. also make that function that checks keys also check to see if dinput is open and the device you created to the keyboard is also still there. I haven''t worked under DX 8 alot so, i don''t know if your seeing those errors in the debugger or as pop up msgs. but if your alt tabing to the debugger, remeber that dinput set to exclusive will be lost if the window is not the focus. you must ->Restore the device.
-Scott
-Scott
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement