fix: atomic tomatoes

This commit is contained in:
cha0s 2024-09-28 10:26:20 -05:00
parent 0588dbf6c2
commit b5019153f3

View File

@ -1,11 +1,11 @@
const {Interactive, Position, Plant, Sprite} = subject;
Interactive.interacting = false;
Plant.stage = 4;
Sprite.animation = ['stage', Plant.stage].join('/')
const promises = [];
for (let i = 0; i < 10; ++i) {
const tomato = ecs.get(await ecs.create({
promises.push(ecs.create({
Collider: {
bodies: [
{
@ -42,6 +42,12 @@ for (let i = 0; i < 10; ++i) {
VisibleAabb: {},
}));
}
const ids = await Promise.all(promises);
for (const id of ids) {
const tomato = ecs.get(id);
const {x, y} = Math.normalizeVector({
x: (Math.random() * 2) - 1,
y: (Math.random() * 2) - 1,
@ -113,6 +119,7 @@ for (let i = 0; i < 10; ++i) {
).promise,
]),
);
}
Plant.stage = 4;
Sprite.animation = ['stage', Plant.stage].join('/')