• Advertisement

Archived

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

Directinput and rapid fire?

This topic is 5494 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

when the player fires a bullet, it is a steady stream of rapid fire bullets. this is because as of right now i only check to see if space bar is down and then create a bullet. thusly:
  
#define KEYDOWN(name,key) (name[key] & 0x80) 
BYTE state[256];

if (KEYDOWN(state, DIK_SPACE))
{
     //Create and Fire Bullet

}

  
how would i have it so that it only fires one bullet, and they cant fire another bullet until the spacebar is let up, then pressed again? i code therefore i am.

Share this post


Link to post
Share on other sites
Advertisement

  
static bool firing=false;

#define KEYDOWN(name,key) (name[key] & 0x80) BYTE state[256];

if (KEYDOWN(state, DIK_SPACE) )
{
if (!firing)
{
//Create and Fire Bullet


firing=true;
}
}
else
firing = false;


i think this will do the trick




To be considered a genius you just have to say what everybody knows in a way very few understand

Share this post


Link to post
Share on other sites

  • Advertisement