Update TestGame, load fonts from memory.
This commit is contained in:
@@ -51,6 +51,11 @@ public class TestGame : Game
|
||||
if (_resourceManager.TryLoad<Font>("inter_regular", "fonts/Inter-Regular.ttf"))
|
||||
{
|
||||
_resourceManager.TryGetResource("inter_regular", out _font);
|
||||
|
||||
if (_font is not null)
|
||||
{
|
||||
_font.Size = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +64,8 @@ public class TestGame : Game
|
||||
_inputHandler.AddInputMapping("play", new InputAction[] { new KeyInputAction(KeyboardKey.Spacebar) });
|
||||
_inputHandler.AddInputMapping("sprint", new InputAction[] { new KeyInputAction(KeyboardKey.LeftShift) });
|
||||
|
||||
_fontHandle = _renderer.LoadFont(_font);
|
||||
|
||||
_scene.AddLayer("World", _worldLayer);
|
||||
// _scene.AddLayer("UI", _uiLayer);
|
||||
|
||||
// _worldLayer.AddEntity(new World());
|
||||
_worldLayer.AddEntity(new World());
|
||||
_worldLayer.AddEntity(new TestPlayer());
|
||||
|
||||
_scene.Start();
|
||||
@@ -79,7 +80,11 @@ public class TestGame : Game
|
||||
double frameTimeMs = _renderer.FrameTime * 1000f;
|
||||
|
||||
_renderer.SetTransform(Vector2.One * 32f, Vector2.Zero, 0f);
|
||||
_renderer.DrawText(_fontHandle, $"{frameTimeMs:0.0} ms", 20, new Color(1f, 1f, 1f, 0.5f));
|
||||
|
||||
if (_font is not null)
|
||||
{
|
||||
_renderer.DrawText(_font, $"{frameTimeMs:0.0} ms", new Color(1f, 1f, 1f, 0.5f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +92,6 @@ public class TestGame : Game
|
||||
private ResourceManager _resourceManager = new();
|
||||
private Sound? _testSound;
|
||||
private Font? _font;
|
||||
private int _fontHandle;
|
||||
private FmodAudioBackend _audioBackend;
|
||||
private InputHandler _inputHandler;
|
||||
private Scene _scene;
|
||||
|
||||
Reference in New Issue
Block a user