Mail Archives: djgpp/1997/06/03/09:41:45
Further to my previous posting, think about this...
A tank similar to those found in C&C...
class tankObject : public gameObject
{
protected:
int CurrentPositionX, CurrentPositionY, direction,
requiredPositionX, requiredPositionY;
// some pointers to hold the bit maps of the tank
int requestedOrders;
public;
tankObject( mapObject *currentMapPtr; bitmapList
*listOfTankBitmapsPtr; int startingX, int startingY );
// the tank object is instanciated with a pointer to the map, a
list of bitmap pointers, and its position on the map
// at instanciation time the tank selects the pointer to the
starting bitmap, that say of a tank pointing north
void setOrders( int orderPositionX, int orderPositionY, int action
);
// the orders given to the tank are: where we want the tank to go,
and what we want it to do when it gets there..
// in this method the tank will evaluate the direction that it must
take, select the appropriate bitmap image of itself
// as well as perhaps do some other calculations, and posibly play
a "ready sir" type WAV file
void dutyCycle();
// in the duty cycle the tank the tank will move along its route,
check for items on the map within an area that may be of interest
// such as enemy objects, obsticles etc and blit its current bitmap
to the screen buffer
....
};
Now if we set a number of these tanks off in life...
typedef tankObject * tankObjectPtr;
int main()
{
....
tankObjectPtr a, b, c, d, e, f;
a = new tankObject( &map, bitmapsPtr, 10, 10 );
// set up b - f
a->setOrders( 100, 200, ATTACK );
b->setOrders( 20, 200, GUARD );
....
// then in the game loop
for( i=xxx; i=0; i--)
{
...
a->dutyCycle();
b->dutyCycle();
etc.
The tanks would move around the screen quite nicely thank-you very much
I know that this is not a proovable game, but I though that I would put
my money where my mouth is and show
what I meant
Rob Humphris
>
- Raw text -