Getting started running NetAF in Blazor is easy!
- Clone the repo.
- Build and run NetAF.Blazor.Example.
- The app will be served at https://localhost:7295/. Navigate to https://localhost:7295/ in your browser to start the game.
Simply add the GameComponent to your page and then set up and start a game.
@page "/"
@using NetAF.Assets
@using NetAF.Blazor.Components
@using NetAF.Rendering.FrameBuilders
@using NetAF.Targets.Html
<PageTitle>NetAF</PageTitle>
<GameComponent @ref="gameComponent" />
@code {
private GameComponent? gameComponent;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
if (GameExecutor.IsExecuting)
GameExecutor.CancelExecution();
HtmlAdapter htmlAdapter = new(gameComponent);
gameComponent?.SetAdapter(htmlAdapter);
GameConfiguration configuration = new(htmlAdapter, FrameBuilderCollections.Html, new Size(50, 30));
GameExecutor.Execute(ExampleGame.Create(configuration));
await InvokeAsync(StateHasChanged);
}
}
The ExampleGame is included in the repo.
Please visit https://benpollarduk.github.io/NetAF-docs/ to view the NetAF documentation.