NewPeregruzkaDlyDraw

This commit is contained in:
Timofey06 2023-08-16 19:17:10 +03:00
parent 9f8e7bcbd4
commit 469050e4cd

View file

@ -146,6 +146,28 @@ namespace DangerousD.GameCore.Graphics
}
_spriteBatch.Draw(texture,
destinationRectangle, sourceRectangle, Color.White);
}
public void DrawAnimation(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
{
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
float scale;
if (currentAnimation.Offset.X != 0)
{
destinationRectangle.X -= (int)currentAnimation.Offset.X;
scale = destinationRectangle.Height / sourceRectangle.Height;
destinationRectangle.Width = (int)(sourceRectangle.Width * scale);
}
else if (currentAnimation.Offset.Y != 0)
{
destinationRectangle.Y -= (int)currentAnimation.Offset.Y;
scale = destinationRectangle.Width / sourceRectangle.Width;
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
}
_spriteBatch.Draw(texture,
destinationRectangle, sourceRectangle, Color.White);
}