3 Commits

Author SHA1 Message Date
32e012ca55 Bad collision 2025-08-31 22:34:02 +02:00
ea93063465 restart firefox after pull 2025-08-31 21:08:08 +02:00
f6e8983879 Enhance Amogus 2025-08-31 21:05:53 +02:00
5 changed files with 48 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ 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;
@@ -18,7 +19,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),
@@ -32,10 +33,10 @@ const makeInitialCrewmates = (): Amogus[] => {
]; ];
}; };
const randNum = (min: number, max: number): number => const randNum: number = (min: number, max: number) =>
Math.random() * (max - min) + min; Math.random() * (max - min) + min;
const makeCrewmate = (imposter: boolean): Amogus => ({ const makeCrewmate: Amogus = (imposter: boolean) => ({
isImposter: imposter, isImposter: imposter,
posX: randNum(0, width - amogusWidth), posX: randNum(0, width - amogusWidth),
posY: randNum(0, height - amogusHeight), posY: randNum(0, height - amogusHeight),
@@ -43,7 +44,7 @@ const makeCrewmate = (imposter: boolean): Amogus => ({
speedY: Math.random() > 0.5 ? randNum(3, 10) : randNum(-3, -10), speedY: Math.random() > 0.5 ? randNum(3, 10) : randNum(-3, -10),
}); });
const intersect = (c1: Amogus, c2: Amogus): boolean => const intersect: Bool = (c1: Crewmate, c2: Crewmate) =>
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;
@@ -75,20 +76,17 @@ 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) => o !== c) // don't collide with yourself pls .filter((o) => intersect(c, o))
.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);
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,9 +60,16 @@ export default function Dashboard() {
<Weather /> <Weather />
</Card> </Card>
<Card icon="🍁" name="420"> <div
<FourTwenty /> className={classNames(
</Card> style.bouncingWindow,
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,3 +25,30 @@
.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);
}
}

View File

@@ -1,10 +1,9 @@
import path from "node:path"; import path from "node:path";
import react from "@vitejs/plugin-react-swc"; import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import mkcert from "vite-plugin-mkcert";
export default defineConfig({ export default defineConfig({
plugins: [react(), mkcert()], plugins: [react()],
resolve: { resolve: {
alias: { alias: {
"@": path.resolve(__dirname, "src"), "@": path.resolve(__dirname, "src"),