Inventory Item Exist checker
Posted
by
Annalyne
on Game Development
See other posts from Game Development
or by Annalyne
Published on 2012-09-20T10:20:16Z
Indexed on
2012/09/20
15:52 UTC
Read the original article
Hit count: 208
c++
I have a question regarding declaring my inventory. I made it a string named inventory, with a constant number as its max value. The thing is, I want the user to use an item if he / she gains an item. The problem is, I do not know what syntax should I use to determine if the user has an item and use that item. Here's my code I just started:
so declaring the inventory:
const int MAX_ITEMS = 15;
string game_inventory [MAX_ITEMS];
int itemnum = 0;
I have some items like potion, antidote, gems and others. I use the:
game_inventory[itemnum++] = "Potion"
to place items in my inventory. If I want to use the potion, IF I HAVE one, how can i make a function to check whether I have a potion or anything and use it?
© Game Development or respective owner