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?
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)