# 2D RPG Inventory

This topic is 2650 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey everyone, well I'm making a 2D rpg but I cant think of a way to make the inventory. I don't need like the full code, just some logic behind it. Thanks!

~baseball435

##### Share on other sites
That's a pretty broad question --

What part is confusing you?

• Creating the GUI for item management?
• Creating the data structure to store the items?
• How to represent different items in the first place?
A few questions to consider:

• Can some items "stack" in the inventory so that a number of said item can be combined to take only one inventory slot? Think arrows, keys, potions.
• Can some items contain other items? For example, perhaps the player might be able to carry a pouch which lets them carry additional items inside.
• Do you want the carrying capacity to be slot-based (as in most eastern-style RPGs like final fantasy) or weight-based (as in many western-style RPGs like Fallout or D&D).
• Is the carrying capacity static, or will it change over time?

##### Share on other sites
An Inventory is a simple collection of items.
 class Inventory : List of items { //Fields maxCapacity = 100 item; //Methods RemoveItem(Item) { return item from inventory } AddItem(Item) {attempts to add item to inventory } } 

##### Share on other sites
Well I guess my two main questions are how do I make the GUI and how do I organize the items. Like I want a sword to have attack but not armor or a potion. Like I need to figure out how to organize the items and I want to find the most efficient way

##### Share on other sites
I cover one way of doing this in my book.

##### Share on other sites
Sadly my parents wont let me purchase anything so I will need a different resource

##### Share on other sites
To be honest, it sounds like you are young and getting ahead of yourself. An inventory isn't a terribly complicated thing -- neither in terms of the data structures necessary, nor in the GUI. My best advice is to slow down and develop a better grasp of programming -- once you have that, you ought to have no problem coming up with a solution to this, and many more, problems.

That's not to say that you can't or shouldn't ask questions, but as it stands you seem to have no thoughts on how to do this if left to your own devices. For me, that's something of a red-flag that you wouldn't be able to apply what was told to you, even if someone explained it in detail (in other words, that you would not yet be capable of taking their description, turning that into code that works for your game, and working out a reasonable majority of the inevitable kinks in the system without intervention.)

That's not meant as a slight against you or your skills, obviously you are young, and no one magically knows how to program from birth (some take to it readily and learn easily and others simply find that they cannot take to it at all). Its just an observation that you are most likely trying to run before you can walk.

What language are you programming in?
How long have you been using it?
Are you self-taught, or have you gotten some level of formal introduction/training?
What is the most advanced language feature you know about? Have a good command of?
What level of mathematics have you taken in school, and how are your grades?
What other programs have you made?

##### Share on other sites
Yeah I am young and I also think I'm getting ahead of myself as I just started programming using xna so I don't know most advanced things yet. Anyone have a project I could work on to help me learn xna a little more?

##### Share on other sites
Some of the big "starter" projects are little games like Pong and Tetris.

##### Share on other sites
Set XNA aside for a little while -- its better to have a grasp of the language itself before bringing in additional libraries, especially domain-specific ones.

Go make sure you know all the C# control structures. Learn what data types are available, learn what boxing and unboxing mean, learn how the CLR garbage collector works, learn all the CLR data structures like List and Dictionary -- and what generics are.

While you're doing all that, make some simple, text-based apps like guess-the-number, some kind of interactive number cruncher or even a simple text adventure or interactive story. I know this all may seem mundane, but its something nearly all of us have done at some point, and its necessary for development.

If you say "well that sounds boring", and at this stage the simple joy of discovering how this all works is not enough to keep you interested, then you may find it difficult to stick with game development when all the "fun" parts are done. Generally speaking, if you car about quality, then you're only about half-way finished once all the fun parts are working -- something else has to keep you going once the fun is over, and for most people that's the sick joy they get from programming combined with the drive to see quality through.

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633416
• Total Posts
3011779
• ### Who's Online (See full list)

There are no registered users currently online

×