Boardgame to Java port need help with classes

Hi,

I am currently working on a port of a boardgame into Java.

My problem is now how to really realize the game.

It is not a typical boardgame with fields I could store in an array but a tabletop game where the models could be everywhere on the board.

I thought about doing it like the following but maybe you can give me a better/easier solution.

- create a class for a model storing the coordinates and the values (e.g. lifepoints,movement range and so on)

- create a class for the graphics of the models extending JPanel so that i can use a mouselistener to check if someone clicked on the model and returning some info to an infofield.

-create a class for the board extending JComponent loading the background image

-create a modellist class storing all the graphical models in a list to keep track of them

And in the board class i would change the paintComponent to something like that:

publicvoid paintComponent(Graphics g)

{

this.drawBoard(g);

for (i=0;i<modelList.getCount();++i)

{

modelList[i].drawModel(g);

}

}

Is that the right approach to that?

And how can I implement a collision detection? I thought about using sprites is that the correct way or is there a better one?

Thanks in advance>

[1539 byte] By [JDavea] at [2007-11-27 2:26:57]
# 1

Your paintComponent() method looks fine, but:

for (i=0;i<modelList.getCount();++i)

{

modelList[i].drawModel(g);

}

Is modelList an array? Arrays don't have a getCount() method. Also, doesn't the ModelList class just hold Graphical models? I think you would want to draw Sprites instead in this for loop.>

CaptainMorgan08a at 2007-7-12 2:37:02 > top of Java-index,Other Topics,Java Game Development...
# 2

Sorry I should have mentioned that to be pseudo code.

I was planning of using a vector as a linear list and adding the graphicmodels to it then just going through all elements.

Correct the graphical model should have a method of being drawn shouldn't it?

I mean the graphical model could also be a sprite. Would that be easier for colision detection too?

Would the vector be the best way to keep track of the models since I can not tell the amount of models in the beginning? Or is that way too slow?

Sorry for asking all these questions but I'd like to create the classes once and not have to change it thousands of times after creation

JDavea at 2007-7-12 2:37:02 > top of Java-index,Other Topics,Java Game Development...