Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  designing and writing my own game from scratch. am i doing this right so far?  (Read 552 times)
0 Members and 1 Guest are viewing this topic.
Offline psiphre

Innocent Bystander





« Posted 2013-03-07 01:54:48 »

I am taking on a project way bigger than my britches for my first project because i believe in baptism by fire.  this is to be an RPG with similarities to final fantasy tactics.

I identified the need to have a class for actors, and i think i need subclasses for all of the different characters and character types.  this is what i wrote up, it is the first part of my program (i don't even have a game loop yet).  did i do this right/intelligently/usably/extensibly or should i go back to the drawing board?

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  
31  
32  
33  
34  
35  
public class Actor {
   private int level;
   private int hp, maxhp;
   private int mp, maxmp;
   private int patk, pdef;
   private int matk, mdef;
   private int[] elementArray;

}

 class PC extends Actor{
   private int xp;
   private int[] jobs;
   private int rosterNumber;
   private int partyNumber;
   private int partyPos;
   private String lhand, rhand, armor, jewelry, acc1, acc2;
   
}
 
 class monster extends Actor{
    private int xpValue;
    private int goldValue;
    private String loot;
    private String[] Abilities;
   
 }
 
 class npc extends Actor{
    private String job;
    private String level;
    private int energy;
    private String project;
   
 }
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #1 - Posted 2013-03-07 02:02:51 »

Well that looks ok, but I think you really should your classes out among files instead of having them all in one file. I cant really say if its a good start or not!

Offline ctomni231

JGO Ninja


Medals: 71
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #2 - Posted 2013-03-07 02:42:06 »

I believe the fact that you are asking on this forum is a huge indicator that you should be starting a smaller project, but I digress.

When designing an tile based game, everything has to do with how objects interact. At the moment, you just have a bunch of variables all in the same spot. I'm not saying it isn't going to work, but there is a huge chance that if you don't write the objects first you'll have a bunch of problems.

That being said, here is a different version of tackling the same problem. It completely depends on your game though...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
//This class holds common elements for all characters in the game
public class Character{

         private int HP; //Holds the HP of an object
        private int maxHP; //Holds the maximum HP of an object
        private int MP; //Holds the MP of an object
        private int maxMP; //Holds the maximum MP of an object

         private int locx; //The x-axis location of the unit
        private int locy; //The y-axis location of the unit
}


1  
2  
3  
4  
5  
6  
7  
//This class holds all the abilities for warrior classes in the game
public class Warrior extends Character{
         private int attack; //Physical attack for warrior class
        private int defense;//Physical defense for warrior class
        private int magicAtk;//Magic attack for warrior class
        private int magicDef;//Magic defense for warrior class
}


then, you can structure your classes from there.

 public class Monster extends Warrior 

 public class NPC extends Character 


I would actually put the inventory and jobs in a separate classes to avoid it being mixed up with the player character.

 public class inventory 

 public class jobs 


Make sure the classes are split up by type in packages. Then you'll realize that you have leagues more code you need to write to make this game functional.

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.

xsi3rr4x (54 views)
2014-04-15 18:08:23

BurntPizza (52 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (150 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!