Sign in to follow this  
baseball435

2D RPG Inventory

Recommended Posts

baseball435    286
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 this post


Link to post
Share on other sites
Ravyne    14300
That's a pretty broad question --

What part is confusing you?

[list][*]Creating the GUI for item management?[*]Creating the data structure to store the items?[*]How to represent different items in the first place?[/list]
A few questions to consider:

[list][*]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?[/list]

Share this post


Link to post
Share on other sites
Andy474    694
An Inventory is a simple collection of items.
[code]
class Inventory : List of items
{
//Fields
maxCapacity = 100 item;


//Methods
RemoveItem(Item) { return item from inventory }
AddItem(Item) {attempts to add item to inventory }

}
[/code]

Share this post


Link to post
Share on other sites
baseball435    286
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 this post


Link to post
Share on other sites
Ravyne    14300
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 this post


Link to post
Share on other sites
baseball435    286
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 this post


Link to post
Share on other sites
Ravyne    14300
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this