CodexCapsule / agents.js
LordXido's picture
Update agents.js
54f4763 verified
raw
history blame contribute delete
343 Bytes
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();
}
}