Added some vars and funcs for testing. Added more fair fps counter and frame counter

This commit is contained in:
Absolutely disgusting
2026-03-07 11:27:29 +04:00
parent c88038e38a
commit d982bc836a
6 changed files with 201 additions and 70 deletions

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace _2DGAMELIB
{
internal class RealFpsCounter
{
private readonly Stopwatch sw = Stopwatch.StartNew();
private int frames;
private long lastTicks;
public double Value { get; private set; }
public void Frame()
{
frames++;
long now = sw.ElapsedTicks;
long delta = now - lastTicks;
if (delta >= Stopwatch.Frequency)
{
Value = frames / (delta / (double)Stopwatch.Frequency);
frames = 0;
lastTicks = now;
}
}
}
}