TinyGameEngine.Core
0.0.2-alpha
This is a prerelease version of TinyGameEngine.Core.
dotnet add package TinyGameEngine.Core --version 0.0.2-alpha
NuGet\Install-Package TinyGameEngine.Core -Version 0.0.2-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TinyGameEngine.Core" Version="0.0.2-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TinyGameEngine.Core" Version="0.0.2-alpha" />
<PackageReference Include="TinyGameEngine.Core" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TinyGameEngine.Core --version 0.0.2-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TinyGameEngine.Core, 0.0.2-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TinyGameEngine.Core@0.0.2-alpha
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TinyGameEngine.Core&version=0.0.2-alpha&prerelease
#tool nuget:?package=TinyGameEngine.Core&version=0.0.2-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TinyGameEngine.Core
A lightweight, opinionated game engine core designed for Azure Container Apps with state persistence via Azure Blob Storage and telemetry via Azure Application Insights.
Features
- State Management: Automatic load/save game state via Azure Blob Storage
- Periodic Sync: State synced automatically at most once per second with hash-based change detection
- High Scores: Blob-based high score tracking with leaderboards
- Telemetry: Integrated Azure Application Insights for metrics and events
- Container Ready: Designed for Azure Container Apps with scale-to-zero
- Restart Tolerance: Containers can spin up/down seamlessly and recover last known state
Quick Start
1. Install the Package
dotnet add package TinyGameEngine.Core
2. Create Your Game Engine
Inherit from TinyEngine
and implement the DoGameTickAsync
method:
using TinyGameEngine.Core.Engine.Interfaces;
using TinyGameEngine.Core.Engine.Models;
using TinyGameEngine.Core.Engine.Services;
public class MyGameEngine : TinyEngine
{
public MyGameEngine(
IGameStateService gameStateService,
ITelemetryService telemetryService,
IGameIdProvider gameIdProvider,
ILogger<TinyEngine> logger)
: base(gameStateService, telemetryService, gameIdProvider, logger)
{
}
public override string GameMode => "My Awesome Game";
public override async Task DoGameTickAsync(
GameState currentState,
UpdateGameRequest updateAction,
CancellationToken cancellationToken = default)
{
// Your game logic here!
// Example: Update score based on action data
if (updateAction.Data?.TryGetValue("points", out var points) == true)
{
currentState.Score += Convert.ToInt64(points);
}
// Track telemetry
_telemetryService.TrackEvent("GameTick", new Dictionary<string, string>
{
["gameId"] = currentState.GameId,
["playerId"] = currentState.PlayerId
});
_logger.LogDebug("Game tick processed for {GameId}", currentState.GameId);
}
}
3. Configure Your Application
In your Program.cs
:
using TinyGameEngine.Core.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Add TinyGameEngine services
builder.Services.AddTinyGameEngine(builder.Configuration, options =>
{
options.StorageAccountName = "your-storage-account"; // Production
options.BlobStorageConnectionString = "UseDevelopmentStorage=true"; // Development
options.ApplicationInsightsConnectionString = "your-app-insights-connection";
});
// Register your game engine
builder.Services.AddGameEngine<MyGameEngine>();
var app = builder.Build();
// Configure pipeline
app.UseCors();
app.MapControllers();
app.MapHealthChecks("/health");
app.Run();
4. Configure Settings
appsettings.Development.json:
{
"ConnectionStrings": {
"BlobStorage": "UseDevelopmentStorage=true",
"ApplicationInsights": ""
}
}
appsettings.json:
{
"ConnectionStrings": {
"BlobStorage": "",
"ApplicationInsights": ""
},
"Azure": {
"StorageAccountName": "your-storage-account"
}
}
API Endpoints
The framework automatically provides these REST endpoints:
Game Management
POST /api/game/start
- Start a new game sessionGET /api/game/state
- Get current game statePOST /api/game/update
- Update game state (calls yourDoGameTickAsync
)POST /api/game/end
- End current game sessionPOST /api/game/sync
- Force state synchronization
Health
GET /health
- Application health check
Architecture
Core Components
- TinyEngine: Abstract base class for your game implementation
- GameController: REST API controller for game operations
- IGameStateService: Manages state persistence (Azure Blob Storage)
- IHighScoreService: Handles high score tracking and leaderboards
- ITelemetryService: Application Insights integration
- IGameIdProvider: Generates unique game identifiers
Game State Model
public class GameState
{
public string GameId { get; set; }
public string GameMode { get; set; }
public string PlayerId { get; set; }
public long Score { get; set; }
public int Level { get; set; }
public bool IsActive { get; set; }
public DateTimeOffset StartTime { get; set; }
public DateTimeOffset LastUpdated { get; set; }
public Dictionary<string, object> CustomData { get; set; }
}
Configuration Options
builder.Services.AddTinyGameEngine(configuration, options =>
{
// Azure Storage account name (production with managed identity)
options.StorageAccountName = "mystorageaccount";
// Connection string for development
options.BlobStorageConnectionString = "UseDevelopmentStorage=true";
// Application Insights connection string
options.ApplicationInsightsConnectionString = "your-connection-string";
// CORS origins (null allows any origin)
options.AllowedOrigins = new[] { "https://yourdomain.com" };
// Initialize blob containers on startup
options.InitializeBlobContainers = true;
});
Development
Prerequisites
- .NET 9.0 SDK
- Azurite for local development
- Azure Storage Account and Application Insights for production
Local Development
Install Azurite:
npm install -g azurite
Start Azurite:
azurite --silent --location c:\azurite
Run your application:
dotnet run
Testing Your Game
# Start a game
curl -X POST http://localhost:5000/api/game/start \
-H "Content-Type: application/json" \
-d '{"playerId":"player1"}'
# Update game state
curl -X POST http://localhost:5000/api/game/update \
-H "Content-Type: application/json" \
-d '{"playerId":"player1","gameId":"game-123","data":{"points":100}}'
# Get current state
curl http://localhost:5000/api/game/state
Production Deployment
Azure Container Apps
The framework is optimized for Azure Container Apps with:
- Scale-to-zero capability
- Managed Identity for secure Azure resource access
- Automatic state persistence and recovery
- Built-in health checks
Required Azure Resources
- Azure Container Apps Environment
- Azure Storage Account (with blob containers:
gamestate
,highscores
) - Azure Application Insights
- Azure Container Registry (for your custom game image)
License
MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Azure.Identity (>= 1.14.2)
- Azure.Storage.Blobs (>= 12.25.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 2.23.0)
- Microsoft.Extensions.Azure (>= 1.12.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.OpenApi (>= 1.6.14)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.0.2-alpha | 179 | 8/5/2025 |
0.0.1-alpha | 121 | 8/4/2025 |