improve ticking, fix #101

This commit is contained in:
Romain Beaumont 2015-11-19 23:46:03 +01:00
parent 3f7853c95b
commit 79e7d040b5

View file

@ -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);
};