chore: physics and predictions back
This commit is contained in:
parent
ff07ef86c8
commit
e2d9151c02
|
@ -3,12 +3,14 @@ import {EntityList} from '@avocado/entity';
|
||||||
import {ActionRegistry} from '@avocado/input';
|
import {ActionRegistry} from '@avocado/input';
|
||||||
import {Container, Renderer, ShapeView} from '@avocado/graphics';
|
import {Container, Renderer, ShapeView} from '@avocado/graphics';
|
||||||
import {shapeFromJSON} from '@avocado/physics';
|
import {shapeFromJSON} from '@avocado/physics';
|
||||||
|
import {World} from '@avocado/physics/dummy';
|
||||||
import {StateSynchronizer} from '@avocado/state';
|
import {StateSynchronizer} from '@avocado/state';
|
||||||
import {Animation} from '@avocado/timing';
|
import {Animation} from '@avocado/timing';
|
||||||
|
|
||||||
const stage = new Container();
|
const stage = new Container();
|
||||||
|
|
||||||
const entityList = new EntityList();
|
const entityList = new EntityList();
|
||||||
|
entityList.world = new World();
|
||||||
const stateSynchronizer = new StateSynchronizer({
|
const stateSynchronizer = new StateSynchronizer({
|
||||||
entityList,
|
entityList,
|
||||||
});
|
});
|
||||||
|
@ -67,16 +69,16 @@ const messageHandle = setInterval(() => {
|
||||||
}
|
}
|
||||||
}, 1000 / 60);
|
}, 1000 / 60);
|
||||||
// Prediction.
|
// Prediction.
|
||||||
// let lastTime = performance.now();
|
let lastTime = performance.now();
|
||||||
// const predictionHandle = setInterval(() => {
|
const predictionHandle = setInterval(() => {
|
||||||
// const now = performance.now();
|
const now = performance.now();
|
||||||
// const elapsed = (now - lastTime) / 1000;
|
const elapsed = (now - lastTime) / 1000;
|
||||||
// lastTime = now;
|
lastTime = now;
|
||||||
// if (hasSelfEntity()) {
|
if (hasSelfEntity()) {
|
||||||
// selfEntity.inputState = actionState.toJS();
|
selfEntity.inputState = actionState.toJS();
|
||||||
// }
|
}
|
||||||
// entityList.tick(elapsed);
|
entityList.tick(elapsed);
|
||||||
// }, 1000 / 80);
|
}, 1000 / 80);
|
||||||
// State updates.
|
// State updates.
|
||||||
let dirty = false;
|
let dirty = false;
|
||||||
function onMessage({type, payload}) {
|
function onMessage({type, payload}) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user