mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
commit
b7641541cb
2 changed files with 4 additions and 6 deletions
|
|
@ -1,6 +1,5 @@
|
|||
#include "Clock.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace util;
|
||||
|
|
@ -20,10 +19,8 @@ int Clock::update(float delta) {
|
|||
tickTimer -= parts * delay / tickParts;
|
||||
tickTimer = std::min<float>(tickTimer, delay);
|
||||
}
|
||||
currentTickPart += parts;
|
||||
if (currentTickPart >= tickParts) {
|
||||
currentTickPart %= tickParts;
|
||||
}
|
||||
lastPartsStart = currentTickPart;
|
||||
currentTickPart = (currentTickPart + parts) % tickParts;
|
||||
return parts;
|
||||
}
|
||||
|
||||
|
|
@ -40,5 +37,5 @@ int Clock::getTickId() const {
|
|||
}
|
||||
|
||||
int Clock::convertPart(int index) const {
|
||||
return (tickParts - currentTickPart) % tickParts + index;
|
||||
return (lastPartsStart + index) % tickParts;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace util {
|
|||
float tickTimer = 0.0f;
|
||||
int tickId = 0;
|
||||
int currentTickPart = 0;
|
||||
int lastPartsStart = 0;
|
||||
public:
|
||||
Clock(int tickRate, int tickParts);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue