Update Game, add IGame.
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
using Voile;
|
||||
using Voile.Resources;
|
||||
using Voile.Utils;
|
||||
using Voile.Input;
|
||||
using Voile.Systems.Particles;
|
||||
using System.Numerics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics;
|
||||
using Voile.Rendering;
|
||||
|
||||
public class TestGame : BaseGame
|
||||
public class TestGame : Game
|
||||
{
|
||||
public override string Name => "Jump Adventures 2";
|
||||
public override string ResourceRoot => "Resources/";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
InitializeSystemsDefault();
|
||||
|
||||
_particleSystem = new ParticleSystem();
|
||||
AddSystemToUpdate(_particleSystem);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
ShutdownDefault();
|
||||
}
|
||||
|
||||
protected override void LoadResources()
|
||||
{
|
||||
ResourceManager.AddResourceLoaderAssociation(new ParticleEmitterSettingsResourceLoader());
|
||||
@@ -30,19 +43,14 @@ public class TestGame : BaseGame
|
||||
|
||||
protected override void Ready()
|
||||
{
|
||||
_particleSystem = new ParticleSystem();
|
||||
Input.AddInputMapping("reload", new InputAction[] { new KeyInputAction(KeyboardKey.R) });
|
||||
_particleSimStopwatch = new Stopwatch();
|
||||
|
||||
_emitterId = _particleSystem.CreateEmitter(Renderer.WindowSize / 2, _fireEffect);
|
||||
}
|
||||
|
||||
|
||||
protected override void Update(double deltaTime)
|
||||
{
|
||||
_particleSimStopwatch = Stopwatch.StartNew();
|
||||
_particleSystem!.Update(deltaTime);
|
||||
_particleSimStopwatch.Stop();
|
||||
|
||||
}
|
||||
|
||||
protected override void Render(double deltaTime)
|
||||
@@ -70,18 +78,16 @@ public class TestGame : BaseGame
|
||||
}
|
||||
|
||||
Renderer.ResetTransform();
|
||||
Renderer.DrawText(_font, $"Particle Sim: {_particleSimStopwatch.Elapsed.TotalMilliseconds} ms", Color.White);
|
||||
|
||||
Renderer.SetTransform(new Vector2(0.0f, 16.0f), Vector2.Zero);
|
||||
Renderer.DrawText(_font, $"Render: {RenderFrameTime.TotalMilliseconds:F1} ms", Color.White);
|
||||
|
||||
Renderer.SetTransform(new Vector2(0.0f, 32.0f), Vector2.Zero);
|
||||
Renderer.SetTransform(new Vector2(0.0f, 16.0f), Vector2.Zero);
|
||||
Renderer.DrawText(_font, $"Update: {UpdateTimeStep * 1000:F1} ms", Color.White);
|
||||
}
|
||||
|
||||
private void DrawEmitter(ParticleEmitter emitter)
|
||||
{
|
||||
Renderer.BeginBlended(Voile.Rendering.BlendMode.BlendAlpha);
|
||||
Renderer.BeginBlended(BlendMode.BlendAlpha);
|
||||
|
||||
var maxParticles = emitter.Settings.MaxParticles;
|
||||
var particleSize = new Vector2(16.0f, 16.0f);
|
||||
@@ -99,11 +105,8 @@ public class TestGame : BaseGame
|
||||
}
|
||||
|
||||
[NotNull] private ParticleSystem _particleSystem;
|
||||
|
||||
private Stopwatch _particleSimStopwatch;
|
||||
private int _emitterId;
|
||||
private ResourceRef<ParticleEmitterSettingsResource> _fireEffect;
|
||||
private ResourceRef<Font> _font;
|
||||
private ResourceRef<Texture2d> _icon;
|
||||
private Logger _logger = new(nameof(TestGame));
|
||||
}
|
||||
Reference in New Issue
Block a user