mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-12 02:51:22 +00:00
improve ticking, fix #101
This commit is contained in:
parent
3f7853c95b
commit
79e7d040b5
1 changed files with 3 additions and 2 deletions
|
|
@ -8,10 +8,11 @@ module.exports.server=function(serv) {
|
|||
|
||||
serv.tickInterval = setInterval(() => {
|
||||
serv.tickCount++;
|
||||
var time = (Date.now() - serv.lastTickTime) / 1000;
|
||||
var t=Date.now();
|
||||
var time = (t - serv.lastTickTime) / 1000;
|
||||
if (time > 100) time = 0;
|
||||
serv.emit('tick', time, serv.tickCount);
|
||||
serv.lastTickTime = Date.now();
|
||||
serv.lastTickTime = t;
|
||||
}, 1000/ticksPerSecond);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue