Engine-Pong/Shared/Behaviours/ShapeBehaviour.cs

27 lines
754 B
C#

using System.Collections.Generic;
using Syntriax.Engine.Core;
using Syntriax.Engine.Integration.MonoGame;
namespace Pong.Behaviours;
public class ShapeBehaviour : Syntriax.Engine.Physics2D.Collider2DShapeBehaviour, IDrawableTriangle
{
private readonly IList<Triangle> triangles = [];
public ColorRGBA Color { get; set; } = new ColorRGBA(255, 255, 255);
public void Draw(ITriangleBatch triangleBatch)
{
Recalculate();
ShapeWorld.ToTrianglesConvex(triangles);
foreach (Triangle triangle in triangles)
triangleBatch.Draw(triangle, Color);
}
public ShapeBehaviour(Shape2D shape) : base(shape) { }
public ShapeBehaviour(Shape2D shape, ColorRGBA color) : base(shape) { Color = color; }
}