From 469050e4cd5f8e2dbff49bb0262efc2ae9c74994 Mon Sep 17 00:00:00 2001 From: Timofey06 Date: Wed, 16 Aug 2023 19:17:10 +0300 Subject: [PATCH] NewPeregruzkaDlyDraw --- .../GameCore/Graphics/GraphicsComponent.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index c5834ab..27c66a0 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -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); }