Page 1 of 1
How Should I Handle Items?
Posted: Wed Apr 29, 2009 6:53 pm
by davidthefat
Should I make a class like this?
Code: Select all
class Items
{
int Cost;
char ItemName[15];
int SpriteID;
int ThumbID;
char iType[10];
void SetItem(int TempCost, char TempName[15], intTempSprite, int TempThumb, char TempType);
};
Re: How Should I Handle Items?
Posted: Wed Apr 29, 2009 7:04 pm
by MarauderIIC
Something like that. Although your class name should probably be singular and your member names should probably start with a lowercase letter and be indented.
Re: How Should I Handle Items?
Posted: Thu Apr 30, 2009 5:55 pm
by thejahooli
MarauderIIC wrote:Something like that. Although your class name should probably be singular and your member names should probably start with a lowercase letter and be indented.
Your code is fine I would would just change your naming of variables and classes to make them like this
Code: Select all
class Item // take away 's' to not make it plural
{
int cost; // for all variables I have the first letter of the first word lowercase
char itemName[15];
int spriteID;
int thumbID;
char itemType[10]; // I changed it from iType to itemType as this is easier to read and use
void SetItem(int tempCost, char tempName[15], int tempSprite, int tempThumb, char tempType);
};
sorry for telling you how you should write your code but this is the normal, or at least widely used, so others can easily read and use your code.