feat: shapes

This commit is contained in:
cha0s 2024-08-01 14:32:20 -05:00
parent 770a63897d
commit 72d114ac74

View File

@ -1,6 +1,7 @@
import K from 'kefir';
import * as easings from '@/util/easing.js';
import {TAU} from '@/util/math.js';
export default class Emitter {
constructor(ecs) {
@ -11,6 +12,18 @@ export default class Emitter {
const allocated = this.ecs.get(await this.ecs.create(entity));
if (shape) {
switch (shape.type) {
case 'circle': {
const r = Math.random() * TAU;
allocated.Position.x += Math.cos(r) * shape.payload.radius;
allocated.Position.y += Math.sin(r) * shape.payload.radius;
break;
}
case 'filledCircle': {
const r = Math.random() * TAU;
allocated.Position.x += Math.cos(r) * Math.random() * shape.payload.radius;
allocated.Position.y += Math.sin(r) * Math.random() * shape.payload.radius;
break;
}
case 'filledRect': {
allocated.Position.x += Math.random() * shape.payload.width - (shape.payload.width / 2);
allocated.Position.y += Math.random() * shape.payload.height - (shape.payload.height / 2);