NetAF.Blazor
1.0.5
dotnet add package NetAF.Blazor --version 1.0.5
NuGet\Install-Package NetAF.Blazor -Version 1.0.5
<PackageReference Include="NetAF.Blazor" Version="1.0.5" />
<PackageVersion Include="NetAF.Blazor" Version="1.0.5" />
<PackageReference Include="NetAF.Blazor" />
paket add NetAF.Blazor --version 1.0.5
#r "nuget: NetAF.Blazor, 1.0.5"
#:package NetAF.Blazor@1.0.5
#addin nuget:?package=NetAF.Blazor&version=1.0.5
#tool nuget:?package=NetAF.Blazor&version=1.0.5
NetAF.Blazor
A Blazor implementation of NetAF. This repo demonstrates how NetAF can be used in a Blazor app by making use of the various classes in NetAF.Targets.Html.
Getting Started
Running the Example
Getting started running NetAF in Blazor is easy!
- Clone the repo.
- Build and run NetAF.Blazor.
- The app will be served at https://localhost:7295/. Navigate to https://localhost:7295/ in your broswer to start the game.
How it Works
The Blazor app provides a single page for rendering and interacting with the game. NetAF provides frame builders to generate the HTML for your game, which is then displayed directly in the page using:
<div>
@((MarkupString)frameAsHtml)
</div>
The page itself is an implementation of IFramePresenter, when an update occurs in the game the Present method is called, which allows the page to receive the generated HTML content.
Besides the generated content the page displays a simple acknowledge button and a input box that allow the user to interact with the game. Based on the games current mode these elements are either visible or hidden.
The game itself is executed as a background task.
@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);
}
}
Example Game
The ExampleGame is included in the repo.
Documentation
Please visit https://benpollarduk.github.io/NetAF-docs/ to view the NetAF documentation.
For Open Questions
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.1)
- NetAF (>= 3.6.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated NetAF.