Amogus cleanup

This commit is contained in:
2025-09-01 00:02:03 +02:00
parent ee26161108
commit 5534451c1e
3 changed files with 15 additions and 47 deletions

View File

@@ -4,7 +4,6 @@ import imposter from "/img/imposter.png";
import style from "./style.module.css"; import style from "./style.module.css";
type Amogus = { type Amogus = {
key: string;
isImposter: boolean; isImposter: boolean;
posX: number; posX: number;
posY: number; posY: number;
@@ -19,7 +18,7 @@ const { innerWidth: width, innerHeight: height } = window;
const getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus); const getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus);
const makeInitialCrewmates: Amogus[] = () => { const makeInitialCrewmates = (): Amogus[] => {
return [ return [
makeCrewmate(true), makeCrewmate(true),
makeCrewmate(false), 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; Math.random() * (max - min) + min;
const makeCrewmate: Amogus = (imposter: boolean) => ({ const makeCrewmate = (imposter: boolean): Amogus => ({
isImposter: imposter, isImposter: imposter,
posX: randNum(0, width - amogusWidth), posX: randNum(0, width - amogusWidth),
posY: randNum(0, height - amogusHeight), 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), 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.posX - c2.posX) < amogusWidth - 20 &&
Math.abs(c1.posY - c2.posY) < amogusHeight - 20; Math.abs(c1.posY - c2.posY) < amogusHeight - 20;
@@ -76,17 +75,20 @@ const doCollisionWalls = (crewmates: Amogus[]) =>
} else return c; } else return c;
}); });
// TODO: This is ugly
const doCollisionOthers = (crewmates: Amogus[]) => const doCollisionOthers = (crewmates: Amogus[]) =>
crewmates.map((c) => { crewmates.map((c) => {
const intersections = crewmates const intersections = crewmates
.filter((o) => intersect(c, o)) .filter((o) => o !== c) // don't collide with yourself pls
.filter((o) => Math.abs(o.posX - c.posX) > 1e-3) // don't collide with yourself pls .filter((o) => intersect(c, o));
.filter((o) => Math.abs(o.posY - c.posY) > 1e-3);
if (intersections.some((o) => Math.abs(o.posX - c.posX) < 50)) { if (intersections.some((o) => Math.abs(o.posX - c.posX) < 50)) {
return { ...c, speedX: c.speedX * -1 }; 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 }; return { ...c, speedY: c.speedY * -1 };
} else return c; }
return c;
}); });
const doKills = (crewmates: Amogus[]) => { const doKills = (crewmates: Amogus[]) => {

View File

@@ -60,16 +60,9 @@ export default function Dashboard() {
<Weather /> <Weather />
</Card> </Card>
<div <Card icon="🍁" name="420">
className={classNames( <FourTwenty />
style.bouncingWindow, </Card>
style.hidden,
)}
>
<Card icon="🍁" name="420">
<FourTwenty />
</Card>
</div>
</CardRow> </CardRow>
<Card icon="🔔" name="Terminal" active={true}> <Card icon="🔔" name="Terminal" active={true}>

View File

@@ -25,30 +25,3 @@
.night { .night {
background-color: #2a3f55; background-color: #2a3f55;
} }
.amogus {
z-index: 100;
position: absolute;
scale: 60%;
animation:
x 10s linear infinite alternate,
y 7s linear infinite alternate;
}
@keyframes x {
from {
left: 0;
}
to {
left: calc(100vw - 70px);
}
}
@keyframes y {
from {
top: 0;
}
to {
top: calc(100vh - 90px);
}
}