• Advertisement

Archived

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

Inventory question/ weapon selection

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