Game Implementation

P

pek

I have a Game class which has all the information about the current
state of the game (players, card state, player turn etc.). Then I have
an Engine class which does all the game logic (draw card, throw card
etc) and finally I have theGameGUI class which is basically a JFrame.
Now..the Engine class needs an EngineListener in his constructor which
it adds it to a List of listeners to inform every listener about
changes and events the game has. For example, if player1 throws a card
in the middle of the table, the Engine will use the method
middleDeckUpdated() of the EngineListener to inform every player of the
game that the middle deck has updated therefore every GameGUI should
remove all it's middle cards and call Engine's getMiddleCards()
function to basically updated the GUI or sometimes the Engine will use
EngineListener's addMiddleCard(Card card) method to send to all the
players the new card (everything in the GUI is cloned for security).

Question 1: Is simply updating the GUI every 2 seconds without
listeners better..?

Question 2: Is this possible to implement in J2EE..? Can the Engine
class be a bean that uses the listeners to update there GUI..? And if
it can be implemented, again, is it better..?

Questin 3: If updating is better after all, why..? I think that using
listeners would use less bandwidth because the server will inform the
client when to update and therefore the client won't have to blindly
update every 2 (or more) seconds..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top