mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2024-11-28 16:58:56 +08:00
Camera stack
This commit is contained in:
parent
272ec43e69
commit
5fdc34c610
|
@ -205,7 +205,11 @@ namespace Strawberry
|
|||
public virtual void Draw()
|
||||
{
|
||||
if (Scene != null)
|
||||
{
|
||||
Draw.PushCamera(Scene.Camera.Round());
|
||||
Scene.Draw();
|
||||
Draw.PopCamera();
|
||||
}
|
||||
|
||||
if (Console.Enabled)
|
||||
Strawberry.Console.Draw();
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace Strawberry
|
|||
|
||||
static public void Draw()
|
||||
{
|
||||
Calc.Log();
|
||||
Draw.Rect(0, 0, Game.Width, Game.Height, .Black * 0.4f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
using SDL2;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Draw
|
||||
{
|
||||
static public Point Camera => Game.Scene != null ? Game.Scene.Camera.Round() : Point.Zero;
|
||||
static public Point Camera => cameraStack.Count > 0 ? cameraStack.Back : Point.Zero;
|
||||
|
||||
static private List<Point> cameraStack = new List<Point>() ~ delete _;
|
||||
|
||||
static public void PushCamera(Point camera, bool relative = true)
|
||||
{
|
||||
if (relative)
|
||||
cameraStack.Add(Camera + camera);
|
||||
else
|
||||
cameraStack.Add(camera);
|
||||
}
|
||||
|
||||
static public void PopCamera()
|
||||
{
|
||||
if (cameraStack.Count == 0)
|
||||
Runtime.FatalError("Cannot Pop empty Camera Stack!");
|
||||
cameraStack.PopBack();
|
||||
}
|
||||
|
||||
static public void Rect(int x, int y, int w, int h, Color color)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user