Пример #1
0
        public void Draw(SpriteBatch batch)
        {
            float deg       = MathHelper.ToDegrees(attackAngle);
            float drawAngle = attackAngle;
            bool  flip      = false;

            if (deg <= 180 && deg > 90)
            {
                drawAngle = MathHelper.ToRadians(deg - 180);
                flip      = true;
            }

            int       x      = (int)Math.Floor(index) % framesX;
            int       y      = (int)Math.Floor(index) / framesX;
            Rectangle dest   = new Rectangle((int)Position.X, (int)Position.Y, (int)frameSize.X, (int)frameSize.Y);
            Rectangle source = new Rectangle((int)(x * frameSize.X), (int)(y * frameSize.Y), (int)frameSize.X, (int)frameSize.Y);

            batch.Draw(spriteSheet,
                       dest,
                       source,
                       Color.White,
                       drawAngle,
                       new Vector2(frameSize.X / 2, frameSize.Y / 2),
                       (flip) ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
                       0);
            xpgen.Draw(batch);
        }
Пример #2
0
 public void Draw(SpriteBatch batch)
 {
     if (Visible)
     {
         DrawFrame(batch);
     }
     if (Shooting)
     {
         fireball.Draw(batch);
     }
     xpgen.Draw(batch);
 }