Jump to content

  • Log In with Google      Sign In   
  • Create Account

The Magical Pot

Member Since 09 Aug 2011
Offline Last Active Jul 22 2014 08:17 AM

#5086171 Using cosine, sine, tangent etc. in C++

Posted by on 15 August 2013 - 10:50 AM

I asked a very simple question and I got the answer that I needed 5 minutes after posting. I know that you shouldn't ask stuff that you can easily find on google or whatever, but for some reason i did and someone was nice enough to answer my question. I'll gladly take delete this post if anyone says that I have to because I already got my answer.

This conversation is pointless.

#4974214 RPG Items management

Posted by on 28 August 2012 - 01:45 PM

Let's say that you have 2 integer variable class members, one is called 'ItemID' and the other one is called 'ItemCategory'. ItemID is the identity and has a unique number to any other item type, this is the variable that you use if you want to spawn an item. ItemCategory is the keeps track of what operations the item can perform, if ItemCategory stands for armor you will equip the item, If ItemCategory stands for potion you will consume the item etc.
So, you spawn an item using ItemID, this will tell your program that it should add an item with the attributes of item type X. You must have set instructions for what the game should do depending on what item category it is, if the item is a piece of armor: Do this, if the item is a potion: Do that. You basically just have 1 if statement for each item category and then you write the behaviors of each individual category, for example if the category is 'Potion': add this amount of health to the player and then remove the potion from the inventory.

I have the Inventory>Slot>Item system set up in the way that the inventory's job is to hold the slots and keep track of when it should be shown on the screen, the item's job is to carry every bit of information about an item. The slots are the ones who are doing the actual work, they can delete items, add items, swap items between different slots, keep track of how to stack items and so on. It works really well.

I'm not sure if that's a good explanation of it, so let me know if I forgot something :)

#4974049 RPG Items management

Posted by on 28 August 2012 - 04:24 AM

It depends on how you design your Inventory>Slot>Item system, but I think that it's generally easier to just have one class for every item in the game. I only have 1 item class in my RPG, I differentiate each item with 1 variable class member and that variable is used to add a specific item to something (for example inventory.additem(48)). I then have another variable class member that determines the type of the item (Armor, potion etc.) which directly determines how the item operates when it's used.
I don't know if it's an optimal way to handle it, but my Inventory>Slot>Item system is designed so that the inventory holds slots and the slots holds the items, this design works for my game at least.