Jump to content
  • Advertisement

Archived

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

computer_guy

Inventory question/ weapon selection

This topic is 5674 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 2d side-scroller and i wan''t the player to beable to choose a weapon but when the player presses a key to select a weapon i''ts only selected when the key is down. My code is as follows, void Select_Weapon(void) { if(KEY_DOWN(''VK_1'')) { weapon = arm; } else if(KEY_DOWN(''VK_2'')) { weapon = gun; } } void Use_Weapon(void) { if(weapon == arm) { //animate bottle Animate_BOB16(&bottle); // Show bottle Show_BOB16(&bottle); } else if(weapon == gun) { //animate handgun Animate_BOB16(&handgun); // Show handgun Show_BOB16(&handgun); } }

Share this post


Link to post
Share on other sites
Advertisement
There is nothing in the code you posted which would cause such a problem, so I''d guess that you are resetting weapon somewhere else in your code.

Share this post


Link to post
Share on other sites
They are declared as bellow,

// weapon selection defines //
#define arm 1
#define gun 2

// weapon selection variables //
int weapon = gun;



I kinda'' know the problem the weapon is only ''arm/gun'' when the key is down, when it is released it goes back to what it was initialized at.

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!