updating motor state in game loop

This commit is contained in:
Peli de Halleux
2017-12-19 16:03:26 -08:00
parent a7d002d949
commit aa031036ee
3 changed files with 25 additions and 59 deletions

View File

@ -375,16 +375,17 @@ namespace pxsim.visuals {
delta = now - then;
if (delta > interval) {
then = now - (delta % interval);
that.updateStateStep();
that.updateStateStep(delta);
}
}
loop();
}
private updateStateStep() {
private updateStateStep(elapsed: number) {
const selected = this.layoutView.getSelected();
const inputNodes = ev3board().getInputNodes();
inputNodes.forEach((node, index) => {
node.updateState(elapsed);
if (!node.didChange()) return;
const view = this.getDisplayViewForNode(node.id, index);
if (view) {
@ -400,6 +401,7 @@ namespace pxsim.visuals {
const outputNodes = ev3board().getMotors();
outputNodes.forEach((node, index) => {
node.updateState(elapsed);
if (!node.didChange()) return;
const view = this.getDisplayViewForNode(node.id, index);
if (view) {