In some games, we just let the main() loop be the Player object or Table object?

Posted by ???? on Game Development See other posts from Game Development or by ????
Published on 2012-04-15T18:57:20Z Indexed on 2012/04/15 23:47 UTC
Read the original article Hit count: 162

Filed under:
|
|

I was thinking that let's say if there is a game of Blackjack or MasterMind, then we should have a class called Dealer or ComputerPal, which is how the computer interact with us (as a dealer for Blackjack or as the person giving hints for MasterMind).

And then there should be a Player object, and the way to play one game is

aPlayer.playGame

but I noticed that a book was just using the main() loop to act as the player (or as the Controller of the game), calling the Dealer methods to dealer the cards, ask for player's action, etc...

1) Is this just a lazy way to model all the proper objects?

2) If more objects are to be added, who should call the aDealer.dealCards and then ask for aPlayer.askForAction? (because it is strange to let the Player handle all the logical steps). Should there be a Table object that handle all these logic and then to play one round of game, use aTable.playGame? What is a good object design for such game?

© Game Development or respective owner

Related posts about design-patterns

Related posts about gameloop