Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Wondering if this will work... Please give me a heads up  (Read 2411 times)
0 Members and 1 Guest are viewing this topic.
Offline Mimz

Junior Newbie





« Posted 2009-01-02 00:15:19 »

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...
1  
2  
3  
4  
5  
6  
7  
8  
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)...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   //***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)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
 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




Offline irreversible_kev

Junior Duke





« Reply #1 - Posted 2009-01-02 00:41:57 »

One thing that I think would greatly help you is using more object oriented style of programming.

IE have a class Item:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public class Item {
   protected int itemID = itemIDCounter++;
   protected String itemTitle;
   protected String itemDescription;
   protected int itemPrice;
   protected int itemDefenceLevelRequired = 0;
   protected 3DModel item3DModel = null;
   protected Icon itemIcon = null;

   private static int itemIDCounter = 0;
}


Then have all your item classes such as Armor extend this class:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
public class Armor extends Item {

   public static final int CLAY_HELMET = 0;
   public static final int CLAY_PLATELEGS = 1;
   public static final int METAL_FACE = 2;

   public Armor(int armorType) {

      switch(armorType) {
      case CLAY_HELMET : {
         itemTitle = "Clay Helmet";
         itemDescription = "A helmet made from clay";
         itemPrice = 5;
         itemDefenceLevelRequired = 1;
         item3DModel = 3DModelLoader.load("/models/clayHelmet.3dm");
         itemIcon = IconLoader.load("/icons/clayHelmet.ico");

      }
      case METAL_FACE : {
         itemTitle = "Metal Face";
         itemDescription = "A face made of metal";
         itemPrice = 100;
         itemDefenceLevelRequired = 3;
         item3DModel = 3DModelLoader.load("/models/metalFace.3dm");
         itemIcon = IconLoader.load("/icons/metalFace.ico");
      }
      }
   }

}


Then:

1  
2  
Armor clayChainbody = new Armor(Armor.CLAY_HELMET);
Armor metalFace = new Armor(Armor.METAL_FACE);


I realise this might not help your defence levels question directly but it should still be usefull...
Offline Mr_Light

Senior Duke


Medals: 1


shiny.


« Reply #2 - Posted 2009-01-02 01:48:46 »

Use Enum's instead of freaky icky weird ints.

Separate presentation from logic in any non-trivial situation.

As far as talking you out of it, I better qoute Mr Glass: "just do it"
see: http://www.java-gaming.org/index.php?action=post;quote=145635;topic=18545.0;num_replies=159;sesc=d89d39022b9724e7bf19ede5635ec123
Feel free to ask any question - though the quality of the answer will depend on how well you formulate it and how narrow the question is.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline irreversible_kev

Junior Duke





« Reply #3 - Posted 2009-01-02 02:16:32 »

Use Enum's instead of freaky icky weird ints.

I had better check out enums then lol
Offline Renoria

Junior Duke




...


« Reply #4 - Posted 2009-01-03 02:23:27 »

i'm using DOM XML for my data files, what I aim to achieve is let the datafiles control what the game does. Eg, you can put what you like in the data files, without editing the java files and it just loads it through XML.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #5 - Posted 2009-01-03 09:24:58 »

I had better check out enums then lol

Just like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
//The int way.
public static final int ANIMAL_DOG = 0;
public static final int ANIMAL_CAT = 1;
public static final int ANIMAL_FISH = 2;

//Doing it the same, but with an Enum.
public enum Animal
{
     DOG,
     CAT,
     FISH
};


Then instead of saying if (animal == ANIMAL_DOG) you would say if (animal == Animal.DOG). Enums automatically handle iteration for you, are much cleaner, when printed out display the enum name (so instead of "1" printed you'd get "CAT" printed), and can also contain any number of variables and information.

More info:
Java Enum Tutorial

Plus I won't say that making a game in Java is a bad idea, but making a 3D MMORPG is. I still rarely bother with 3D, because things get so much more complicated, and I've been making games in Java for going on 6 years now. Similarly networking can get gruesomely difficult and will no doubt be the cause of mountains of headaches and errors. Give it a go if you want - I think everyone has grand ideas the first time they make a game - but certainly don't expect to ever finish.

See my work:
OTC Software
Offline Renoria

Junior Duke




...


« Reply #6 - Posted 2009-01-03 11:09:51 »

I've started my MMO, 10% done ^_^
Offline Abuse

JGO Knight


Medals: 13


falling into the abyss of reality


« Reply #7 - Posted 2009-01-03 19:51:13 »

I've started my MMO, 10% done ^_^

Only another 99.99% to go! Good Luck  Wink

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #8 - Posted 2009-01-03 21:09:33 »

Only another 99.99% to go! Good Luck  Wink
99.9999999%
 Grin


See my work:
OTC Software
Offline ewjordan

Junior Duke





« Reply #9 - Posted 2009-01-03 21:34:52 »

Plus I won't say that making a game in Java is a bad idea, but making a 3D MMORPG is. I still rarely bother with 3D, because things get so much more complicated, and I've been making games in Java for going on 6 years now.
Just to expand on this - the real problem with 3D stuff has little to do with Java, or even getting the engine working (Java actually performs fine for this stuff, and there are many off-the-shelf solutions for doing this in any language).  It's really the content creation that tends to bottleneck you, something coders rarely consider until they run into it head-on.  It's very difficult and time consuming to produce high quality 3D art.  You have to be a good modeler, and you also have to have excellent 2D skills to get your textures right, and then you have to be familiar enough with the content creation tools to put the two together.  On top of that you'd better have a spot on visual sense so that you come out with a consistent look and feel, otherwise your game will look like crap.  Add in the sheer amount of content that you need to fill a 3D world (O(N^3) instead of O(N^2) in the size of the world), and it quickly becomes a task so complex that you really need a dedicated team to handle it all - a massive percentage of the money put into commercial games is dedicated to this stuff, so bear that in mind!.

The code is the least of your concerns, so don't think for a minute that if you've got the code almost working you're anywhere near done!  2D content is probably a tenth the effort (not that it doesn't also require skill!), which makes 2D games a lot more attractive for any sort of indie developer.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #10 - Posted 2009-01-04 01:41:34 »

Well that's certainly true, but I'm more referring to the fact that instead of just populating a 2D screen as you would draw a picture (easy for everyone to visualize), you now have to do it all from a 3D perspective which can be very hard to grasp when it's being represented on a 2D plane (i.e. the monitor). It's basically the difference between pre-renaissance art and post-renaissance art. You need to have a keen understand of shading, vanishing point, perspective, and any other number of complicated concepts.

Programming in 2D is like drawing this:


Whereas programming in 3D is like drawing this:


It's not making the model that's the hardest part, it's being able to visualize the very complicated difference between the two mediums.

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (13 views)
2014-10-25 15:46:29

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (45 views)
2014-10-16 15:22:06

Norakomi (34 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!