Skip to content
256 changes: 162 additions & 94 deletions app/js/canvas.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion app/js/componentUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ let ticksPerSecond = 0;

let pauseSimulation = false;
let updates;
let maxUpdatesInitial = 10000;
let maxUpdates = maxUpdatesInitial;


function tick() {
const start = new Date;
updates = 0;

while(updateQueue.length > 0 && updates < 10000 && !pauseSimulation) {
while(updateQueue.length > 0 && updates < maxUpdates && !pauseSimulation) {
updateQueue.splice(0,1)[0]();
++updates;
}

// randomize max updates, so that flickering wires will flicker on screen as their value will be different each tick
// due to different max updates
maxUpdates = maxUpdatesInitial + Math.floor(Math.random() * Math.floor(100)) - 50;

ticksPerSecond = 1000 / (new Date - lastTick);
lastTick = new Date;
}
Expand Down
Loading