[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pbmserv-dev] about board2d.cpp and multiple boards
Shogi does something like this. It uses three Board objects: the one
inherited from Board2d, and two more it instantiates itself. But it
actually uses GetPiece/PutPiece to access the boards, putting the
characters from each board together into a single string.
It would probably be easiest to just subclass ReadWriteStringList, and
copy the needed routines from Board2D to your new class. (You cannot have
another Board2D member in your game, because it inherits from the Game
class.) Then access the main board with GetAt(), and the other board with
boardbombs.GetAt().
~ John Williams
On Mon, 29 Jul 2002, Douglas Zander wrote:
> I was wondering if it would be advantageous to create a set of functions
> like those found in board2d but only make it possible to access other
> boards than just the one named 'board' for example, I am writing a
> game (BattleShip) and I wish to keep two identically-sized boards but one
> I wish to use for the fleets of the two players and the other I wish to
> use for the bombed-out locations where the players had attacked each other.
> I realize that I could just place everything on one board with special
> characters for each object (a digit for the player's ships and something
> else for bombed out locations) but I think it would be neat if I could
> use several boards and simply pass a parameter to the functions to
> determine which [ReadWriteStringList] I wish to use.
>
> I tried to figure out how to write this by looking at the lists.h and
> lists.cpp files and I found something like where it used the variable
> '*this' plus there were some functions like abc::abc and abc::~abc
> and abc::&abc etc...
>
> I was wondering how easy it would be to rewrite these functions so
> that they could be used for a board that was named, like, board2 or
> boardbombs instead of just using 'board' only.
>
> Could this be done and then the default is to use the variable named,
> 'board', and if someone wanted to overwrite them using a different
> variable name they could? Is this advisable?
>
>
>
>
>
> To unsubscribe, send a message to esquire@gamerz.net with
> unsubscribe pbmserv-dev@gamerz.net
> as the BODY of the message. The SUBJECT is ignored.
>