Compare commits
2 Commits
32e012ca55
...
5534451c1e
| Author | SHA1 | Date | |
|---|---|---|---|
| 5534451c1e | |||
| ee26161108 |
@@ -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[]) => {
|
||||
|
||||
@@ -60,16 +60,9 @@ export default function Dashboard() {
|
||||
<Weather />
|
||||
</Card>
|
||||
|
||||
<div
|
||||
className={classNames(
|
||||
style.bouncingWindow,
|
||||
style.hidden,
|
||||
)}
|
||||
>
|
||||
<Card icon="🍁" name="420">
|
||||
<FourTwenty />
|
||||
</Card>
|
||||
</div>
|
||||
<Card icon="🍁" name="420">
|
||||
<FourTwenty />
|
||||
</Card>
|
||||
</CardRow>
|
||||
|
||||
<Card icon="🔔" name="Terminal" active={true}>
|
||||
|
||||
@@ -25,30 +25,3 @@
|
||||
.night {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user