is there any way to simplify your coding using constants and loops?
example:
constants.h:
Code:
enum ItemTypes { POTION, BOTTLE, BOX, THING, TABLE, NUMITEMS };
const char ItemNames[NUMITEMS][32]=
{
"Potion",
"Bottle",
"Box",
"Thing",
"Table"
};
const int ItemPrices[NUMITEMS]=
{
50,
25,
5,
1,
20
};
game.cpp
Code:
#include <iostream.h>
#include <constants.h>
int main()
{
cout << "Items you can purchase and their prices: " << endl;
for(int a=0;a<NUMITEMS;a++)
cout << ItemNames[a] << " Gold: " << ItemPrices << endl;
getch();
return 0;
}
might be some bugs in that code, i just now wrote it, but you should get what i'm trying to say. This allows you to easily add new items just by adding one more ID and updating the names and prices. Kind of like a database. I'm not sure if you've already done this or know about it, cuz i haven't seen your code, but it sounds like you could benefit from doing something like this...Most programs shouldn't really have that many if-else statements as to overflow the stack
or just use a switch statement