Powerup::Powerup(char* type, SPRITE sprite, int x, int y, int stayTime) { width = height = 64; powerupType = type; texture = DuplicateSprite(sprite); MoveSprite(texture, (float)x, (float)y); SetSpriteScale(texture, width, height); this->x = x; this->y = y; timeLeft = stayTime; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CSprite::ExpandThink( void ) { float frametime = gpGlobals->curtime - m_flLastTime; SetSpriteScale( m_flSpriteScale + m_flSpeed * frametime ); int sub = (int)(m_iHealth * frametime); if ( sub > GetRenderAlpha() ) { SetRenderAlpha( 0 ); Remove( ); } else { SetRenderAlpha( GetRenderAlpha() - sub ); SetNextThink( gpGlobals->curtime ); m_flLastTime = gpGlobals->curtime; } }
Projectile::Projectile(SPRITE sprite, int x, int y, int xDir, int yDir, float rotation, float speed, float stayTime, SColour color, int length, bool special, IParent* parent) { scale = 1; width = 10 * scale; height = length * scale; this->x = (float)x; this->y = (float)y; this->xDir = xDir; this->yDir = yDir; this->rotation = rotation; currentRotation = rotation; this->speed = speed; isSpecial = special; pixelsTravellable = (int)(stayTime * getApplication()->getTickLimit()); texture = DuplicateSprite(sprite); SetSpriteScale(texture, width, height); SetSpriteColour(texture, color); MoveSprite(texture, this->x, this->y); this->parent = parent; }
void CSprite::SetScale( float scale, float time ) { m_flScaleTime = time; SetSpriteScale( scale ); // The surrounding box is based on sprite scale... it changes, box is dirty }