n0mad at March 3rd, 2010 22:57 — #1
I hope I'm putting this into the right place, but I was wondering if someone could help me out with a game I'm making.
I am using Visual Studio C# to make an RPG, right now so far i have the program give you items when you "open a treasure chest" and these items are put into an array. After these items are put into an array and you open your inventory form the items stored in the array are put into labels (Short sword = array and that is in slot 1; so on and so forth). I now want to know how to, when slot1 is clicked on (it is a label with "Short Sword" written in it due to an array loading it) i want it to be equiped to a certain place, like to the left hand for example.
If this isn't too confusing and someone could give me some guidance on a way to do this that would be great.
samuraicrow at March 4th, 2010 21:41 — #2
When doing weapons classes you want them to typically be that: classes. You want a weapon class that is abstract that describes what types of information about the weapon are known. Then you can make more specific classifications such as a one-handed weapon. If it is a one-handed weapon you can have an "equip" method that will check if it is being equipped in the proper location on the character.
I hope this helps,
n0mad at March 4th, 2010 21:57 — #3
What i thought of after i made this post and was wondering if it would work was using databases (through microsoft office access) that had all the information like that, or would classes still be better than using databases. I would love to EVENTUALLY have maaaany items (weapons, armors, potions, etc.) that could be used but i will still look into classes.
Many items after i have the base game coded.. just keep expanding.
reedbeta at March 5th, 2010 01:19 — #4
Databases are huge overkill for a game that's not an MMO.
You should probably have a class hierarchy for items, like maybe a CItem class and a CWeapon class that derives from CItem; then maybe CMeleeWeapon and CRangedWeapon would be subclasses of CWeapon. These classes would have various methods allowing them to be picked up, dropped, etc. and properties indicating weight, damage, etc.
Then you could have a CCharacter class, and as a field in that, have an array of (references to) CItems representing the character's inventory. You could also have a field holding a reference to the currently wielded weapon on the left hand, and another for the right hand. A method on CCharacter would exist to equip a CWeapon from the inventory, which would check which hand(s) it is for and set the references appropriately.
n0mad at March 5th, 2010 08:20 — #5
Mmmmmmmkay... i didn't understand most of that but i will get my computer science teacher to help me out with that. Thanks Reed.
vrnunes at March 5th, 2010 17:44 — #6
Not to bash you but... that is why people always suggest beginners to start with simpler games (tic-tac-toe, tetris, etc).
After you make some simple games, you get enough knowledge to at least understand what people are saying above.
n0mad at March 5th, 2010 18:28 — #7
I've made tic-tac-toe, pong, a small scale RPG, asteroid dodge, copter, and games of the such but, in my class we did not have the time to go over classes.
reedbeta at March 5th, 2010 18:55 — #8
Heh. That's fine, but you really need to slow down and take a few more basic CS courses before you think seriously about doing a large project. Learning the tools of the trade actually is important. Right now it's kind of like you're trying to build a car with just a wrench and a screwdriver, if you see what I mean.
n0mad at March 5th, 2010 23:42 — #9
Oh i see exactly what you mean, but i am a very ambitious(if thats the right word) young man and I do rather enjoy just jumping into the larger things then taking it slow.