experiments-monogame/Dakota/Dakota/Renderables/StaticBox.cs

35 lines
950 B
C#

using Dakota.Data;
using Microsoft.Xna.Framework;
using Nez;
namespace Dakota.Renderables
{
public class StaticBox : RenderableComponent
{
public override float Width => _width;
public override float Height => _height;
private int _width;
private int _height;
public StaticBox(int width, int height, Color color)
{
_width = width;
_height = height;
Color = color;
RenderLayer = GameConstants.UiRenderLayerBg;
}
public override void Render(Batcher batcher, Camera camera)
{
for (var x = 0; x < Width; ++x)
for (var y = 0; y < Height; ++y)
if (Random.Chance(0.2f))
batcher.DrawPixel(
Entity.Position.X + LocalOffset.X + x,
Entity.Position.Y + LocalOffset.Y + y,
Color);
}
}
}