Spaces:
Running
Running
File size: 343 Bytes
df80484 54f4763 df80484 c73d07c 54f4763 df80484 c73d07c df80484 54f4763 df80484 54f4763 c73d07c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | export class Agents {
constructor(world) {
this.world = world;
this.agents = [];
}
spawn() {
this.agents.push({
v: Math.random() * 0.5 - 0.25
});
}
update(dt) {
for (const a of this.agents) {
this.world.power += a.v * dt;
}
}
apply(cmd) {
if (cmd.action === "spawn") this.spawn();
}
} |