Jump to content

  • Log In with Google      Sign In   
  • Create Account

RPG Inventory HUD


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Djfix   Members   -  Reputation: 237

Like
0Likes
Like

Posted 31 August 2012 - 07:37 AM

Hello again gentlemen!

As the title of the topic suggests I have a bit of a problem with a drag-and-drop,Diablo 2-like inventory HUD/GUI.
I figured out how to handle the data part of the inventory (using an array) but my main problem is Linking the data part to a GUI.
Any ideas on that?

I am just asking for ideas,suggestions (not plain solutions, i want something to challenge my brain not take them by granted)...i can accept pseudocode, Python,Java,and C++ ideas because i can relate the solutions to my language of choice.

Thank you in advance!

Sponsor:

#2 SimLabDevelopments   Members   -  Reputation: 205

Like
0Likes
Like

Posted 31 August 2012 - 10:41 AM

Actually, your title *doesn't* suggest anything. Perhaps if you present an actual problem and answerable question, you might get a better response.

I'll help you get started...

What language are you working in? Graphics library? GUI library?
What have you tried?
What is the result?

#3 Djfix   Members   -  Reputation: 237

Like
0Likes
Like

Posted 31 August 2012 - 11:48 AM

Ahem...i'm sorry if I didn't make myself clear (i still think i did).

I have a bit of a problem with a drag-and-drop,Diablo 2-like inventory HUD/GUI.


I said

.i can accept pseudocode, Python,Java,and C++ ideas


Still my language of choice is Python (PyGame library) but i honestly think this does not make any difference because i can handle myself in each language
so i would have been able to port anything you gave me to Python.

What have you tried?

I figured out how to handle the data part of the inventory (using an array)


The result: A working inventory system...only that it accepts string commands (it's all text)

My Main problem: Linking my already working inventory system to a Heads Up Display (If you have played Diablo 2 you know what kind of inventory i am looking for)

#4 Mussi   Crossbones+   -  Reputation: 2099

Like
0Likes
Like

Posted 31 August 2012 - 03:58 PM

Are you having difficulty displaying images? associating items with them? handling UI interaction?

#5 Djfix   Members   -  Reputation: 237

Like
0Likes
Like

Posted 01 September 2012 - 03:15 AM

I am having difficulty with handling the UI interaction (like arranging items in the inventory, equiping them and so forth)
As i have told you before i've already made an inventory but it works with string commands...Now i want to Make all that into a GUI.

#6 stitchs   Crossbones+   -  Reputation: 1309

Like
1Likes
Like

Posted 01 September 2012 - 03:39 AM

In all honesty, it's still limited subject information for anyone to work with.

It sounds like (to me personally) that you don't even have a handle on displaying graphical images on the screen which, as basic as it sounds, you won't understand any of the possible suggestions provided.

Let's try and start again: You say you have a data based inventory using an array to store the objects (string representations if I gather correctly) which is effectively a list of words. What does your current logic allow you to do with this?
  • Does your inventory allow for items to be added/removed on the fly.
  • Are your items made from class derived objects, or are they literally just string names?
  • Is it a fixed size inventory?

This is just some of the information needed to be able to help present a suggestion that might work with your current system.

Now, secondly, Graphics related:
  • What is your experience with graphics thus far?
  • How much experience have you had with Pygame?
  • What are your attempts in combining Pygame and your current Inventory?
  • Does your current implementation display (even as words) in a visual environment? (SCREENSHOTS are incredibly useful here!)

Again, this is just some of the information needed to be able to help. With a question such as yours, it helps to break it down, not just for us, but for you to be able to actually think about different portions of such a system. Like you said, you are having problems with a drag and drop (which is ONE component of a Diablo 2 style system) and I'm sure you mentioned equipping, which would be different as it could deal with Inventory to character, as opposed to Inv to Inv. Other parts to consider: stackable items, being able to remove items in favor of new. There are so many potential components that it really does help to break down what you want the system to do.

I hope this helps,

Regards,

Stitchs

Edited by stitchs, 01 September 2012 - 03:42 AM.


#7 Djfix   Members   -  Reputation: 237

Like
0Likes
Like

Posted 01 September 2012 - 05:05 AM

Ok...I'll try my best explaining my current situation (I am not a native english speaker so that could make it harder for me).

To begin with...I have implemented a 2d top-down tile based game. It works perfectly until now (basic tilemaps,a bit of AI for mosters, Random map generation using Perlin Noise)

So to describe the logic behind my inventory:
- It currently allows adding, and removing items (when the character walks over the sprite of a dropped item and presses P the item is picked up and added to the inventory.If the player presses I a list of items shows up and he can select the item he wishes to drop and presses R to drop it)
- My items are class based (references of a base Item class which passes a Use() (a sword gets and attack function,a potion a healing function and so on) function which i load from a .txt file for every item i want.
- Yes it is a fixed sized inventory system (16 items)

Graphics experience:
Now I think I was harshly misinterpreted at this part...i think i may have expressed myself wrongly and that led to wrong conclusions (in my head I thought that you must have read my previous posts but now I realise that I must provide the necessary details).


- My experience with graphics (+1 year of 2d graphics programming)
- My experience with PyGame: about 9 months
I'll try to attach a screenshot of my first level
.screen.png

#8 EngineProgrammer   Members   -  Reputation: 295

Like
1Likes
Like

Posted 01 September 2012 - 09:16 AM

Hi Djfix,

You should have some classes with inheritance I suppose?
Class Item -> Class ItemSword, class ItemRing, class ItemPotion which all use the class Item.

If you have this I should recommend you to make 2 classes, class ItemList, class Inventory.

The ItemList class keeps every item, a dropped item and an item in the inventory. So all your items will be stored in this class using a vector.
The Inventory class only hold what you have picked up. To receive all the picked up items you want to say something like:

m_pInventory = m_pItemList->GetAllStoredItems();

So what this means if each item needs to have a bool which says it is stored or not stored.
Then to receive all the stored items you do something like this:
vector<Items*> ItemList::GetAllStoredItems()
{
	vector<Items*> tempVec;
	for(/* look through the vector */)
	{
		if(m_VecItems.at(i)->IsStored() {
		tempVec.pushback(m_VecItems.at(i));
	}
	}
}

This is how I should do it. Certainly there are better ways but this should do also.

EDIT: Ah you are working in Python? I have no idea how it works so I'm doubting Python uses classes. But you say you can handle each language so I won't edit the code I've written. :D Good luck.

~EngineProgrammer

Edited by EngineProgrammer, 01 September 2012 - 09:18 AM.


#9 nfries88   Members   -  Reputation: 259

Like
1Likes
Like

Posted 01 September 2012 - 03:55 PM

rather than use a flat array of inventory tiles, use a linked-list of items. Since the inventory will presumably be small like in Diablo (fitting maybe 50 small items, max); iteration will not be a bottleneck. This not only probably saves on memory usage, but will prevent from having to update each inventory tile occupied by an item when adding or removing it.

From there, items in the inventory will need a position and size, measured in inventory tiles. This will allow you to detect whether or not you can add the item to the inventory.

class InventoryItem
{
   [...]

   Sprite* m_visual;
   int m_x;
   int m_y;
   int m_w;
   int m_h;
};
[...]
std::vector<InventoryItem*> inventory;
[...]
bool AddItemToInventory(Item* item, int x, int y)
{
	InventoryItem* iitem = new InventoryItem(item, x, y);
	for(std::vector<InventoryItem*>::iterator it = inventory.begin(); it != inventory.end(); ++it)
	{
	   if(Rects_Intersect(make_rect((*it), make_rect(item))
		  return false;
	}
	inventory.push_back(iitem);
	return true;
}

Edited by nfries88, 01 September 2012 - 03:58 PM.

Looking for paid or open-source C++ programming work. Been programming since 2005. No degree.

#10 Djfix   Members   -  Reputation: 237

Like
0Likes
Like

Posted 03 September 2012 - 04:08 AM

Thanks for your help...I've managed to put together an algorithm and i've also integrated a small GUI for the inventory.

Cheers!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS