Okay so I’m pretty good at Java but I’ve never really made a game before using it. So my friends and I are making a game (do not go on a rant and tell me how thats a bad idea and stuff) and so the game is going to be an MMORPG game (3D) and so I wanted someone to check this out and see if this will work for what I’m doing…
So I have a class called Items.java, and it handles all of the ingame items, I also have separate classes for each type of item. I have the class Armor.class, Weapons.class, and Misc.class (that handles money, tickets, counters etc.). So I have my Armor class here…
class Armor {
public Armor(String aTitle, int itemID, int defBonus, String itemDescription, int itemPrice, int defItemLevel) {
itemID = 0;
defBonus = 0;
}
I then have my ItemHandler.java which handles ALL of the items in the game and gives the name, item id, bonuses etc. so that I can control each item by a whole bunch of different variables that suite the situation…
Here is a chunck of my ItemHandler.java (ps. I compiled it already and it runs just fine)…
//***ARMOR***\\
// Armor ARMORNAME = new Armor("ARMOR NAME", ID, DBONUS, "ITEM DESCRIPTION", PRICE, LEVEL);
Armor clayChainbody = new Armor("Clay Chainbody", 2, 1, "A chainbody made from clay", 15, 1);
Armor clayPlatebody = new Armor("Clay Platebody", 3, 2, "A platebody made from clay", 20, 1);
Armor clayPlatelegs = new Armor("Clay Platelegs", 4, 1, "Some platelegs made from clay", 10, 1);
Armor clayHelmet = new Armor("Clay Helmet", 5, 1, "A helmet made from clay", 5, 1);
Armor clayFullhelmet = new Armor("Clay Full helmet", 6, 1, "A full helmet made from clay", 7, 1);
Armor clayPlateshoes = new Armor("Clay Plateshoes", 7, 0, "Some plateshoes made from clay", 3, 1);
Armor clayBuckler = new Armor("Clay Buckler", 8, 1, "A buckler made from clay", 10, 1);
Armor clayKitesheild = new Armor("Clay Kitesheild", 9, 2, "A kitesheild made from clay", 15, 1);
The reason I chose that section is because it is related to the first part in Item.java…
So this allows me to have a simplified version of creating new types of armor and controlling the price, name, level required, bonuses and item id.
The points that I’m curious about are
- The itemID int. I created that so that I could have this for when I click on an item (this isn’t in the game yet and I know it’s wrong)
switch(itemID) {
case 2: // clay chainbody
if(defLevel >= defItemLevel) {
// equip item
...
}
else {
// don't equip item and say
p.setString(.. "You need a higher defence level to equip that item");
}
break;
default:
...
break;
I want to know if itemID will work for that situation (and what it does is it creates a case for the ItemID and if the defence level of the player is greater than or equal to the defence item level then the person can wear that item, but if it isn’t (thats the else statement) then it doesn’t allow the person to weild the item…
- My second perdicament is “How will I get it to use the right model and icon?” So I want to ask you if this would work…
I change the public Armor class and make it this
public Armor(String aTitle, int itemID, int defBonus, String itemDescription, int itemPrice, int defItemLevel, Image itemIcon, ?? itemModel)
The ?? are there because I don’t know what I would make the itemModel be…
So if you would answer these question I would greatly appreciate it…
Thanks,
- Mimz


