diff --git a/src/components/Amogus/Amogus.tsx b/src/components/Amogus/Amogus.tsx
index 535fd00..ada808b 100644
--- a/src/components/Amogus/Amogus.tsx
+++ b/src/components/Amogus/Amogus.tsx
@@ -4,7 +4,6 @@ import imposter from "/img/imposter.png";
import style from "./style.module.css";
type Amogus = {
- key: string;
isImposter: boolean;
posX: number;
posY: number;
@@ -19,7 +18,7 @@ const { innerWidth: width, innerHeight: height } = window;
const getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus);
-const makeInitialCrewmates: Amogus[] = () => {
+const makeInitialCrewmates = (): Amogus[] => {
return [
makeCrewmate(true),
makeCrewmate(false),
@@ -33,10 +32,10 @@ const makeInitialCrewmates: Amogus[] = () => {
];
};
-const randNum: number = (min: number, max: number) =>
+const randNum = (min: number, max: number): number =>
Math.random() * (max - min) + min;
-const makeCrewmate: Amogus = (imposter: boolean) => ({
+const makeCrewmate = (imposter: boolean): Amogus => ({
isImposter: imposter,
posX: randNum(0, width - amogusWidth),
posY: randNum(0, height - amogusHeight),
@@ -44,7 +43,7 @@ const makeCrewmate: Amogus = (imposter: boolean) => ({
speedY: Math.random() > 0.5 ? randNum(3, 10) : randNum(-3, -10),
});
-const intersect: Bool = (c1: Crewmate, c2: Crewmate) =>
+const intersect = (c1: Amogus, c2: Amogus): boolean =>
Math.abs(c1.posX - c2.posX) < amogusWidth - 20 &&
Math.abs(c1.posY - c2.posY) < amogusHeight - 20;
@@ -76,17 +75,20 @@ const doCollisionWalls = (crewmates: Amogus[]) =>
} else return c;
});
+// TODO: This is ugly
const doCollisionOthers = (crewmates: Amogus[]) =>
crewmates.map((c) => {
const intersections = crewmates
- .filter((o) => intersect(c, o))
- .filter((o) => Math.abs(o.posX - c.posX) > 1e-3) // don't collide with yourself pls
- .filter((o) => Math.abs(o.posY - c.posY) > 1e-3);
+ .filter((o) => o !== c) // don't collide with yourself pls
+ .filter((o) => intersect(c, o));
+
if (intersections.some((o) => Math.abs(o.posX - c.posX) < 50)) {
return { ...c, speedX: c.speedX * -1 };
- } else if (intersections.some((o) => Math.abs(o.posY - c.posY) < 50)) {
+ }
+ if (intersections.some((o) => Math.abs(o.posY - c.posY) < 50)) {
return { ...c, speedY: c.speedY * -1 };
- } else return c;
+ }
+ return c;
});
const doKills = (crewmates: Amogus[]) => {
diff --git a/src/components/Dashboard/Dashboard.tsx b/src/components/Dashboard/Dashboard.tsx
index c951ed8..08602f9 100644
--- a/src/components/Dashboard/Dashboard.tsx
+++ b/src/components/Dashboard/Dashboard.tsx
@@ -60,16 +60,9 @@ export default function Dashboard() {