Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Zobah Mizrachi   on Feb 26 In Java Category.

  
Question Answered By: Botan Suzuki   on Feb 26

I can see a couple ways to do what you're trying. One way is to make
a base abstract class  for everything. Maybe call it GameObject.
GameObject would have a member variable  such as isPassable.

Another way is to make two interfaces: Passable and Impassable. If
an object  is Passable, it implements the Passable interface. You
could just check if it's passable by doing something like:

if (myObject instanceof Passable) ...

I would personally stick with the first method because the second
method allows you to have an object that's both passable and
impassable and the two interfaces would be blank. Try to think of
the things that each object in your game would need, regardless of
whether it's passable or not, and store that stuff in GameObject.

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on More about StackableBoard Or get search suggestion and latest updates.

Related Topics:

Tagged: