/* $Id: avatarworm.hpp,v 1.16 2005/10/11 16:06:09 chfreund Exp $ */ #ifndef _AVATARWORM_HPP_ #define _AVATARWORM_HPP_ /**********************************************************/ #include "constants.hpp" #include "avatar.hpp" #include "scorekeeper.hpp" #include /********************************************************** * The worm avatar **********************************************************/ //! avatar class for worms class AvatarWorm : public Avatar { public: AvatarWorm(); ~AvatarWorm(); // implementation of the pure virtual function inherited from // class Object, returns the constant defined in constants.hpp Sint32 getID() const { return AVATAR_WORM; } /*! \name functions concerning the graphic of the avatar * \brief Besides the implementation of the functions * Object::getColors() and Object::getNumColors class Avatar * must provide an interface to set and get the skin color and * the team color and the player color. This does not mean * that these three colors */ //@{ /*! \brief sets the personal player color. In team play games * this also sets the gun color, in single play games the * skin color. */ void setPlayerColor( const Uint32 color ) { m_Colors[PLAYER_COLOR] = m_Colors[ m_worldPointer->getScorekeeper()->isTeamPlay() ? GUN_COLOR : SKIN_COLOR ] = color; } /*! sets explicitely only the skin color. NOTE: this function * is a relict, and it is not clear, when it should be used. * Before you use it, please check, if not setPlayerColor or * setTeamColor is the function you want to use. */ void setSkinColor( const Uint32 color ) { m_Colors[SKIN_COLOR] = color; } //! sets the team color void setTeamColor( const Uint32 color ) { m_Colors[TEAM_COLOR] = m_Colors[ m_worldPointer->getScorekeeper()->isTeamPlay() ? SKIN_COLOR : GUN_COLOR] = ( color == TPLCOL_DONT_USE || ! m_worldPointer->getScorekeeper()->isTeamPlay()) ? TPLCOL_RGB(0,100,230) // the default gun color : color; } //! returns the presonal player color Uint32 getPlayerColor() const { return m_Colors[PLAYER_COLOR]; } //! returns the skin color Uint32 getSkinColor() const { return m_Colors[SKIN_COLOR]; } //! returns the team color Uint32 getTeamColor() const { return m_Colors[TEAM_COLOR]; } //! implementation of the routine inherited from class Object const Uint32* getColors() const { return m_Colors; } /*! \brief implementation of the routine inherited from class * Object. Returns (NUM_COLORS-1), since the player color is * only an administrative color, but not a seperate color in * this object. Note that getNumColors is used by the drawing * routines of class WopSprites. */ Sint32 getNumColors() const { return NUM_COLORS-2; } //! selects the correct sequence index for the current state /*! This function selects the correct sequence index. Call this * function, whenever you change the state of the avatar, to * make sure that the correct graphics are selected. */ void updateSpriteSelection(); //@} // void update() {} protected: //! indices of the different colors in the worm avatar enum { SKIN_COLOR = 0, //!< the personal skin color EYE_COLOR = 1, //!< the eye color (TPLCOL_DONT_COL) GUN_COLOR = 2, //!< the gun color PLAYER_COLOR = 3, //!< the personal player color TEAM_COLOR = 4, //!< the team color NUM_COLORS }; //! colors for the graphic instance //! must have RGB format from TPLCOL macros in spriteset.hpp Uint32 m_Colors[NUM_COLORS]; static const int N_INJURED_SAMPLES = 6, N_DIE_SAMPLES = 13; Mix_Chunk* m_injuredSample[N_INJURED_SAMPLES]; Mix_Chunk* m_dieSample[N_DIE_SAMPLES]; virtual int applyDamage( const Particles::ParticleData& p ); virtual int applyDamage( const int damage, Player* shooter ); }; /**********************************************************/ #endif // _AVATARWORM_HPP_