Added some vars and funcs for testing. Added more fair fps counter and frame counter
This commit is contained in:
26
2DGAMELIB/_2DGAMELIB/FrameTimeCounter.cs
Normal file
26
2DGAMELIB/_2DGAMELIB/FrameTimeCounter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace _2DGAMELIB
|
||||
{
|
||||
internal class FrameTimeCounter
|
||||
{
|
||||
private readonly Stopwatch sw = Stopwatch.StartNew();
|
||||
private long lastTicks;
|
||||
public double FrameMs { get; private set; }
|
||||
|
||||
public void Frame()
|
||||
{
|
||||
long now = sw.ElapsedTicks;
|
||||
|
||||
if (lastTicks != 0)
|
||||
{
|
||||
FrameMs = (now - lastTicks) * 1000.0 / Stopwatch.Frequency;
|
||||
}
|
||||
|
||||
lastTicks = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user