blob: c9b6cf73d3bd30291730ca663ca461f5d1c807b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
game.system.Physics = () => {
const update = (elapsedTime) => {
for (let id in game.entities) {
const entity = game.entities[id];
if (entity.hasComponent("momentum")) {
const {dx, dy} = entity.components.momentum;
entity.components.position.x += dx * elapsedTime;
entity.components.position.y += dy * elapsedTime;
}
}
}
return { update };
}
|