Jump to content
  • Advertisement

Archived

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

Neen10do

Directinput and rapid fire?

This topic is 5733 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
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!