<pre>
/*
File: gameworms.h
Uploaded by joecheng on Sun Dec 16 20:37:56 PST 2001
*/

#ifndef GAMEWORMS
#define GAMEWORMS

#include "game.h"
#include "critterwall.h" /* Lee added 11-04-01 */
//#include "critterarmed.h" /* Lee added 11-11-01 */
// changed critter.h made radius() virtual  Joe 11-29

//=== cGameWorms Critters ====================================

const int possibleLocations = 20;
static int changeInRadius = -0.75;
const static int hatchTime = 20;

class cGameWorms;
class cCritterWormsSnake;

class cCritterMazeWall : public cCritterWall
{
DECLARE_SERIAL(cCritterMazeWall);
public:
	cCritterMazeWall(){}
	cCritterMazeWall(const cVector &enda, const cVector &endb, 
						Real thickness = cCritterWall::THICKNESS);
   virtual BOOL collide( cCritter * pcritter );
};

class cCritterWormsBase : public cCritter
{
public:
   cCritterWormsBase()
      : _pPreviousSection( NULL ), _pSnake( NULL ) {}
   void setSnake( cCritterWormsSnake * snake )
   { _pSnake = snake; }
   void setPrevious( cCritterWormsBase * prev )
   { _pPreviousSection = prev; }
   cCritterWormsBase * getPrevious()
   { return _pPreviousSection; }
   cCritterWormsSnake * getSnake()
   { return _pSnake; }
   // Overloads
   virtual void drawHighlight( cGraphics * pgraphics, Real highlightratio );
   virtual Real radius()
   { return cCritter::radius() + changeInRadius; }//* 0.75; }
protected:
   cCritterWormsBase * _pPreviousSection;
   cCritterWormsSnake * _pSnake;
};

class cCritterWormsSnake 
{
public:
   cCritterWormsSnake( cGameWorms * game );
   //cCritterWormsSnake( cGameWorms * game, int size );
   cCritterWormsBase * getTail()
   { return _pTail; }
   cCritterWormsBase * getHead()
   { return _pHead; }
   void addSegment( cCritterWormsBase * newSeg )
   {  _pTail = newSeg;
      _size++; }
   void setHead( cCritterWormsBase * head )
   { _pHead = head; }
   void setTail( cCritterWormsBase * tail )
   { _pTail = tail; }
   int getSize()
   { return _size; }
   cGameWorms * getGame()
   { return _pGame; }
   void growSnake();
   void dropEgg( Real dt, bool & dropped );
   void setLength( int length );
   void moveTo( const cVector2 & newposition );
   void eatenHead();
   void eatenTail();
   void deleteTail();
protected:
   void deleteAll();
   int _size;
   cGameWorms * _pGame;
   cCritterWormsBase * _pHead;
   cCritterWormsBase * _pTail;
   Real _timeUntilEgg;
};

class cCritterWormsPlayer : public cCritterWormsBase	/* 11-5 Joe */
{
DECLARE_SERIAL(cCritterWormsPlayer);
public:
	cCritterWormsPlayer();
   void dropEgg();
   void seedRandomFood( Real dt );
   void setScore( int addAmount )
   { _score += addAmount; }
   void damagePlayer();

	//overloads
	virtual void reset();
	virtual BOOL collide(cCritter *pcritter); 
	virtual void update(Real dt, CPopView *pview);
   virtual void die();
protected:
   bool _eggDropped;
   bool _calledByPlayer;
};

class cCritterWormsSeg : public cCritterWormsBase	/* Lee 11-11-01 */
{
DECLARE_SERIAL(cCritterWormsSeg);					/* Lee 11-11-01 */
public:
	cCritterWormsSeg(cCritterWormsBase * pcritter = NULL); 
	//overloads
   virtual void die();
	virtual BOOL collide(cCritter *pcritter); 
	virtual void update(Real dt, CPopView *pview);
};

class cCritterPlayerWormsSeg : public cCritterWormsBase		/* Lee 11-11-01 */
{
DECLARE_SERIAL(cCritterPlayerWormsSeg);						/* Lee 11-11-01 */
public:
	cCritterPlayerWormsSeg(cCritterWormsBase * pcritter = NULL); 
	//overloads
	virtual BOOL collide(cCritter *pcritter); 
	virtual void update(Real dt, CPopView *pview);
};


class cCritterWormsEnemyHead : public cCritterWormsBase		/* 11-12 Joe */
{
DECLARE_SERIAL( cCritterWormsEnemyHead );
public:
   virtual void update( Real dt, CPopView * pview );
   virtual BOOL collide(cCritter * pcritter);
   virtual void die();
   cCritterWormsEnemyHead( cCritter * pcritter = NULL );
protected:
   Real _timeUntilEgg;
};

class cCritterWormsPlayerEgg : public cCritterWormsBase
{
DECLARE_SERIAL( cCritterWormsPlayerEgg );
public:
   cCritterWormsPlayerEgg() {}
protected:
};

class cCritterWormsEnemyEgg : public cCritterWormsBase
{
DECLARE_SERIAL( cCritterWormsEnemyEgg );
public:
   cCritterWormsEnemyEgg( cGameWorms * game = NULL )
      :_pGame( game ), _timeTillHatch( hatchTime )
   { setSprite( new cSpriteIcon(IDB_EARTH) );}

   //Overloads
   virtual void die();
   virtual void update( Real dt, CPopView * pview );
protected:
   Real _timeTillHatch;
   cGameWorms * _pGame;
};

class cCritterWormsFood : public cCritterWormsBase
{
DECLARE_SERIAL( cCritterWormsFood );
public:
   cCritterWormsFood();
   // Overloads
   virtual BOOL collide( cCritter * pcritter );
};

//======================= cGameWorms ================

class cGameWorms : public cGame
{
DECLARE_SERIAL(cGameWorms);

//Name your statics here
static int PLAYERHEALTH;
static int WORMCOUNT;
static int LEVEL;

private:
	int _rivalcount; //possible params, don't have to use these.
   int _playerLength;
   int _playerseedcount;
   Real _timeUntilFood;
   cVector2 startLocations[possibleLocations];
   void initializeLocations();
public:
	cGameWorms();
    void initiatePlayer( int _playerseedcount );
    void initiatePlayerSegs( int seedcount, cCritterWormsSnake * snake );
    //void initiateEnemySnake( int length );
    void initiateEnemySnake( int length, cVector2 location ); 
	void initiateMap1();                            /* 11-12 Joe */
	void initiateMap2();                            /* 12-6 Lee */
   int playerSize()
   { return pbiota()->count(RUNTIME_CLASS(cCritterPlayerWormsSeg)); }
   int playerLevel()
   { return LEVEL; }
//   int playerHealth()
//   { return pbiota()->count(RUNTIME_CLASS(cCritterPlayerWormsSeg)); }
   int numberOfWalls()
   { return pbiota()->count(RUNTIME_CLASS(cCritterMazeWall)); }
 
    //overloads
   virtual void step(Real dt, CPopView *pactiveview);
	virtual void Serialize(CArchive& ar);
	virtual void reset();
	virtual void adjustGameParameters();
	virtual CString statusMessage();
	virtual void initializeView(CPopView *pview);
	virtual void seedCritters();
	virtual BOOL collide(cCritter *pcriti, cCritter *pcritj); //Lets the cCritterBasket
};

#endif //GAMEWORMS
</pre>

