From d8eda24809c4f17f30abafd97b7bfac513573ff1 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Sat, 22 Aug 2020 22:41:04 -0500 Subject: [PATCH] Playground now has more control; Implemented framework changes. Live framerate and update rate changing commands added. --- .../Commands/GraphicalPlaygroundCommand.cs | 26 ++++++++++++++++--- .../Utilities/Playground/MainState.cs | 3 ++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/SlatedGameToolkit.Tools/Commands/GraphicalPlaygroundCommand.cs b/src/SlatedGameToolkit.Tools/Commands/GraphicalPlaygroundCommand.cs index 0d09707..b8c66b9 100644 --- a/src/SlatedGameToolkit.Tools/Commands/GraphicalPlaygroundCommand.cs +++ b/src/SlatedGameToolkit.Tools/Commands/GraphicalPlaygroundCommand.cs @@ -14,7 +14,7 @@ namespace SlatedGameToolkit.Tools.Commands public bool Execute(IInteractable interactable, string[] args) { - if (args.Length != 1) return false; + if (args.Length < 1) return false; args[0] = args[0].ToLower(); if (args[0].Equals("start")) { if (GameEngine.IsRunning()) { @@ -34,7 +34,7 @@ namespace SlatedGameToolkit.Tools.Commands interactable.Tell("Running: " + GameEngine.IsRunning()); interactable.Tell("Target FPS: " + (GameEngine.targetFPS <= 0 ? "Not bounded." : GameEngine.targetFPS.ToString())); interactable.Tell("Update Step: " + (GameEngine.UpdatesPerSecond <= 0 ? "Not Locked." : GameEngine.UpdatesPerSecond.ToString())); - interactable.Tell("Debug logging: " + logListener.Debug); + interactable.Tell("Debug logging: " + ((logListener == null) ? "false" : "true")); return true; } else if (args[0].Equals("debug")) { if (logListener == null) { @@ -56,13 +56,31 @@ namespace SlatedGameToolkit.Tools.Commands interactable.Tell("Stopped listening to game engine's logging."); } return true; + } else if (args[0].Equals("updates")) { + int updates; + if (args.Length < 2 || !int.TryParse(args[1], out updates)) { + interactable.Tell("Missing numerical value dictating updates per second."); + } else { + GameEngine.UpdatesPerSecond = updates; + interactable.Tell("Target updates per second set to: " + updates); + } + return true; + } else if (args[0].Equals("framerate")) { + int frames; + if (args.Length < 2 || !int.TryParse(args[1], out frames)) { + interactable.Tell("Missing numerical value dictating framerate."); + } else { + GameEngine.targetFPS = frames; + interactable.Tell("Target framerate set to: " + frames); + } + return true; } return false; } public string getDescription() { - return "Starts and stops the graphical playground."; + return "Controls the playground engine status."; } public string[] GetInvokers() @@ -72,7 +90,7 @@ namespace SlatedGameToolkit.Tools.Commands public string getUsage(string arg) { - return "Usage: \"playground [start | stop | status]\" the required argument being whether to start, stop or get the current status of the game engine."; + return "\"playground [start | stop | status | log | debug | framerate | updates ]\""; } public void Dispose() diff --git a/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs b/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs index 9886258..540d597 100644 --- a/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs +++ b/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs @@ -84,7 +84,8 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground public void Render(double delta) { - renderer.Begin(Matrix4x4.Identity, delta); + camera.InterpolatePosition(delta); + renderer.Begin(Matrix4x4.Identity); renderer.Draw(logo); renderer.Draw(textureTester); renderer.Draw(untextured);