Image scale/rotation works

This commit is contained in:
Maddy Thorson 2021-02-08 22:43:25 -08:00
parent 9f1f04358b
commit 6e1c8c7558
2 changed files with 11 additions and 7 deletions

View File

@ -15,12 +15,12 @@ namespace Strawberry
Offset = offset;
}
public Point DrawPosition => Entity.Position + Offset - Origin;
public Point DrawPosition => Entity.Position + Offset;
public void Draw()
{
if (Texture != null)
Game.Batcher.Tex(Texture, DrawPosition);
Game.Batcher.Tex(Texture, DrawPosition, Origin, Scale, Rotation);
}
}
}

View File

@ -102,12 +102,16 @@ namespace Strawberry
public void Tex(Texture texture, Vector pos, Vector origin, Vector scale, float rotation)
{
//TODO!
Mat3x2 mat = Mat3x2.CreateTranslation(-origin)
* Mat3x2.CreateScale(scale)
* Mat3x2.CreateRotation(rotation)
* Mat3x2.CreateTranslation(pos);
PushQuad(.TextureTint, texture,
.Tex(.(pos.X, pos.Y), .(0, 0), Color.White),
.Tex(.(pos.X + texture.Width, pos.Y), .(1, 0), Color.White),
.Tex(.(pos.X + texture.Width, pos.Y + texture.Height), .(1, 1), Color.White),
.Tex(.(pos.X, pos.Y + texture.Height), .(0, 1), Color.White));
.Tex(.(0, 0) * mat, .(0, 0), Color.White),
.Tex(.(texture.Width, 0) * mat, .(1, 0), Color.White),
.Tex(.(texture.Width, texture.Height) * mat, .(1, 1), Color.White),
.Tex(.(0, texture.Height) * mat, .(0, 1), Color.White));
}
}
}