MoonWorksECSTest/src/MoonWorksECSTestGame.cs

53 lines
1.4 KiB
C#

using MoonWorks.Graphics;
using MoonWorks;
using MoonTools.ECS;
namespace MoonWorksECSTest
{
class MoonWorksECSTestGame : Game
{
World world = new World();
public MoonWorksECSTestGame(
WindowCreateInfo windowCreateInfo,
PresentMode presentMode,
bool debugMode
) : base(windowCreateInfo, presentMode, 60, debugMode)
{
new InputSystem(world, Inputs);
new PositionSystem(world);
var entity = world.CreateEntity();
world.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(200, 200) });
world.Set(entity, new StaticPositionComponent());
entity = world.CreateEntity();
world.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(100, 100) });
}
protected override void Update(System.TimeSpan dt)
{
world.Update(dt);
}
protected override void Draw(System.TimeSpan dt, double alpha)
{
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window);
commandBuffer.BeginRenderPass(
new ColorAttachmentInfo(swapchainTexture, Color.CornflowerBlue)
);
commandBuffer.EndRenderPass();
GraphicsDevice.Submit(commandBuffer);
}
protected override void OnDestroy()
{
}
}
}