Namespace AlphaFramework.Presentation
Provides a basis for building presenters that visualize AlphaFramework.World-based game worlds using OmegaEngine.Graphics.Renderables.
Note
NuGet package: AlphaFramework.Presentation
Presenter
The Presenter (see PresenterBase<TUniverse>) handles visual representation. It bridges the game world and the rendering engine:
- Creates renderables - Converts entities to Renderables
- Manages the scene - Adds/removes objects from the Scene
- Handles view updates - Keeps visual representation synchronized with world state
Different presenter implementations can provide different visualization modes (e.g., in-game, editor, menu background) without changing the underlying world data.
public class Presenter(Engine engine, Universe universe) : PresenterBase<Universe>
{
public Presenter(Engine engine, Universe universe) : base(engine, universe)
{
View = new(Scene, new FreeFlyCamera());
}
public override void Initialize()
{
if (Initialized) return;
// Add PositionableRenderables to Scene.Positionables
base.Initialize();
}
}
GameBase
GameBase provides the application shell. It extends RenderHost with game-specific features:
- Settings management - Loads and saves game configuration
- GUI system - Integrates OmegaGUI for menus and HUD
- Lifecycle management - Handles initialization, main loop, and cleanup
Your game class derives from GameBase and coordinates the other components:
public class MyGame(Settings settings)
: GameBase(settings, "My game")
{
private Session? _session;
private Presenter? _presenter;
protected override bool Initialize()
{
if (!base.Initialize()) return false;
// Load universe
var universe = Universe.Load("Level1.xml");
// Create session
_session = new Session(universe);
// Create presenter
_presenter = new(Engine, universe);
_presenter.HookIn();
return true;
}
protected override void Render(double elapsedTime)
{
_session!.Update(elapsedTime);
base.Render(elapsedTime);
}
}
API
Namespaces
Classes
- Arguments
An immutable class representing command-line arguments passed to an application.
- CoordinatePresenter<TUniverse, TCoordinates>
Uses the Engine to present a CoordinateUniverse<TCoordinates> game world.
- GameBase
Base class for building a game using AlphaFramework. Handles basic engine and GUI setup.
- TerrainExtensions
Contains extension methods for Terrain<TTemplate>.