Add new methods to input handler, add RectangleShape2d, modify test game.
This commit is contained in:
@@ -12,7 +12,7 @@ namespace DaggerFramework.SceneGraph
|
||||
renderer.DrawCircle(_radius, _color);
|
||||
}
|
||||
|
||||
private float _radius;
|
||||
private Color _color;
|
||||
private float _radius = 16;
|
||||
private Color _color = Color.White;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Numerics;
|
||||
using DaggerFramework.Rendering;
|
||||
|
||||
namespace DaggerFramework.SceneGraph;
|
||||
|
||||
public class RectangleShape2d : Drawable2d
|
||||
{
|
||||
public Vector2 Size { get; set; } = Vector2.One * 32;
|
||||
public Color Color { get; set; } = Color.White;
|
||||
public override void OnDraw(Renderer renderer)
|
||||
{
|
||||
renderer.DrawRectangle(Size, Color);
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,41 @@ namespace DaggerFramework.SceneGraph
|
||||
{
|
||||
public class Text2d : Drawable2d
|
||||
{
|
||||
public string Contents { get => _contents; set => _contents = value; }
|
||||
public string Text { get => _text; set => _text = value; }
|
||||
public int FontSize { get => _fontSize; set => _fontSize = value; }
|
||||
public Color FontColor { get => _fontColor; set => _fontColor = value; }
|
||||
public Font Font
|
||||
{
|
||||
get => _font; set
|
||||
{
|
||||
_isDirty = true;
|
||||
_font = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDraw(Renderer renderer)
|
||||
{
|
||||
renderer.DrawDebugText(_contents, _fontSize, _fontColor);
|
||||
if (_isDirty)
|
||||
{
|
||||
_fontHandle = renderer.LoadFont(_font);
|
||||
_isDirty = false;
|
||||
}
|
||||
|
||||
if (_font == null)
|
||||
{
|
||||
renderer.DrawDebugText(_text, _fontSize, _fontColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.DrawText(_fontHandle, _text, _fontSize, _fontColor);
|
||||
}
|
||||
}
|
||||
|
||||
private string _contents = string.Empty;
|
||||
private string _text = string.Empty;
|
||||
private int _fontSize = 16;
|
||||
private Color _fontColor = Color.White;
|
||||
private Font _font;
|
||||
private int _fontHandle;
|
||||
private bool _isDirty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user