Cleaned up entity tracking. Scene.Camera. Matrix struct.

This commit is contained in:
Matt Thorson
2020-05-22 23:39:46 -07:00
parent 292213dae5
commit fe3672f30c
5 changed files with 582 additions and 72 deletions

View File

@ -4,10 +4,12 @@ namespace Strawberry
{
static public class Draw
{
static public Point Camera => Game.Scene != null ? Game.Scene.Camera.Round() : Point.Zero;
static public void Rect(int x, int y, int w, int h, Color color)
{
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
SDL.RenderFillRect(Game.Renderer, &SDL.Rect((int32)x, (int32)y, (int32)w, (int32)h));
SDL.RenderFillRect(Game.Renderer, &SDL.Rect((int32)(x - Camera.X), (int32)(y - Camera.Y), (int32)w, (int32)h));
}
static public void Rect(Rect rect, Color color)
@ -18,7 +20,7 @@ namespace Strawberry
static public void HollowRect(int x, int y, int w, int h, Color color)
{
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
SDL.RenderDrawRect(Game.Renderer, &SDL.Rect((int32)x, (int32)y, (int32)w, (int32)h));
SDL.RenderDrawRect(Game.Renderer, &SDL.Rect((int32)(x - Camera.X), (int32)(y - Camera.Y), (int32)w, (int32)h));
}
static public void HollowRect(Rect rect, Color color)
@ -28,8 +30,11 @@ namespace Strawberry
static public void Line(Point from, Point to, Color color)
{
let fromn = (Point)(from - Camera);
let ton = (Point)(to - Camera);
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
SDL.RenderDrawLine(Game.Renderer, (int32)from.X, (int32)from.Y, (int32)to.X, (int32)to.Y);
SDL.RenderDrawLine(Game.Renderer, (int32)fromn.X, (int32)fromn.Y, (int32)ton.X, (int32)ton.Y);
}
}
}