MoonWorksECSTest/src/MoonWorksECSTestGame.cs

53 lines
1.4 KiB
C#
Raw Normal View History

2022-03-07 18:58:05 +00:00
using MoonWorks.Graphics;
using MoonWorks;
using MoonTools.ECS;
namespace MoonWorksECSTest
{
class MoonWorksECSTestGame : Game
{
2022-03-07 19:46:51 +00:00
World world = new World();
2022-03-07 18:58:05 +00:00
public MoonWorksECSTestGame(
WindowCreateInfo windowCreateInfo,
PresentMode presentMode,
bool debugMode
) : base(windowCreateInfo, presentMode, 60, debugMode)
{
2022-03-07 19:46:51 +00:00
new InputSystem(world, Inputs);
new PositionSystem(world);
2022-03-07 18:58:05 +00:00
2022-03-07 19:46:51 +00:00
var entity = world.CreateEntity();
world.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(200, 200) });
2022-03-07 20:11:51 +00:00
world.Set(entity, new StaticPositionComponent());
entity = world.CreateEntity();
world.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(100, 100) });
2022-03-07 18:58:05 +00:00
}
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()
{
}
}
}