Tuesday, December 15, 2009

New RPG

So now that school is over, I am recoding a new RPG from the ground up, focusing specifically on the features that I could not do last time.

First up I have been coding the inventory system. The problem is that I do not know how to make classes or dynamic arrays.

That means all lists of items have to have a set size before hand and must be made entirely of the same type of data.

So first step to solve that is simply a limited inventory. That is simple enough on its own. Now the problem of different data types was dealt with in an interesting way…

Code Snippet
  1. struct inventoryItem{
  2.     itemType item_Type; //This will be used to determine which array the item is located
  3.     int indexValue; //This is used to determined which element in the array it is
  4.     bool isHere; //This is used mainly in the player's inventory, if it is false, Then it is treated as an empty slot
  5. };

The main inventory is instead a list of this single data type.

This data type basically serves as a reference to the actual item.

item_Type labels what type of item it is thus which of the master lists its located in.

indexValue is where in the master list it is located.

Example: when item_Type = WEAPON, and indexValue = 3. The program will know it refers to the item located WEAPON_INDEX[3]

This is still far from perfect, I have yet to choose a method to handle items being equipped by the player.

I also have yet to set up the monster list or data types, to be fair I am going to wait on that till I determine just what the battle system will be like, what stats will be used, what formulas…

Feel free to offer suggestions on that.

No comments:

Post a Comment