aspose file tools*
The moose likes Game Development and the fly likes Proper class structure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Proper class structure" Watch "Proper class structure" New topic
Author

Proper class structure

brent carter
Ranch Hand

Joined: Dec 15, 2011
Posts: 34
Whenever I make a game I always run into the same problem. I create a hero object, but after doing a few things with it I run into scope problems. For example: I will create a dungeon class to make dungeons. I am not sure how my hero object should interact with this class that makes dungeons. Do I have to pass my hero object as an argument to the dungeon class? Do I forgo a dungeon class and just create a dungeon method on the same scope as where I created my hero object?

What is the best way to structure a simple game that has a hero that traverses through a dungeon?

Thanks.
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

How about making an interface like "traversable" with a method ( lets call it traverse) and write the implementation code for how to traverse a dungeon. You can pass the Hero object to this method , although I would favor the use of abstraction and pass an object of Entity ( Hero extends Entity ) and then write the implementation code of how the hero ( Hero instaceOf Entity ) would traverse the dungeon right there.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
 
 
subject: Proper class structure
 
Similar Threads
Java3D: using for loops to draw objects I can later delete
Making a class instance "current"
Refactoring
Running an application of 3 classess in JCreator
Class Practice Help