Compare commits

...

5 Commits

Author SHA1 Message Date
cb4ce4188e Amogus cleanup
All checks were successful
CI / build (pull_request) Successful in 12s
CI / lint (pull_request) Successful in 10s
CI / create-and-publish-docker-image (pull_request) Successful in 14s
CI / build (push) Successful in 12s
CI / lint (push) Successful in 9s
CI / create-and-publish-docker-image (push) Successful in 12s
2025-09-01 20:24:19 +02:00
53db7e795c Bad collision 2025-09-01 20:24:19 +02:00
3606f9b043 restart firefox after pull 2025-09-01 20:24:19 +02:00
5da900c1c3 Enhance Amogus 2025-09-01 20:24:19 +02:00
8653365af1 rename github folder
All checks were successful
CI / build (push) Successful in 13s
CI / lint (push) Successful in 9s
CI / create-and-publish-docker-image (push) Successful in 14s
2025-08-31 23:55:45 +02:00
5 changed files with 113 additions and 102 deletions

View File

@@ -69,12 +69,13 @@ jobs:
password: ${{ secrets.GARRISON_DOCKER_PASSWORD }} password: ${{ secrets.GARRISON_DOCKER_PASSWORD }}
script: | script: |
cd monitor-im-flur cd monitor-im-flur
export HYPRLAND_INSTANCE_SIGNATURE=$(hyprctl instances -j | jq '.[0].instance' | tr -d "'\"")
hyprctl dispatch exec 'pkill firefox'
hyprctl dispatch exec 'firefox -kiosk localhost:9123'
git clean -dfx git clean -dfx
git reset --hard HEAD git reset --hard HEAD
git pull git pull
docker-compose pull docker-compose pull
docker-compose down docker-compose down
docker-compose up -d docker-compose up -d
export HYPRLAND_INSTANCE_SIGNATURE=$(hyprctl instances -j | jq '.[0].instance' | tr -d "'\"")
hyprctl dispatch exec 'pkill firefox'
hyprctl dispatch exec 'firefox -kiosk localhost:9123'

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;
@@ -12,81 +11,122 @@ type Amogus = {
speedY: number; speedY: number;
}; };
const amogusWidth = 70;
const amogusHeight = 70;
const { innerWidth: width, innerHeight: height } = window;
const getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus); const getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus);
const initialCrewmates: Amogus[] = [ const makeInitialCrewmates = (): Amogus[] => {
{ key: "a", isImposter: true, posX: 10, posY: 20, speedX: 10, speedY: 30 }, return [
{ makeCrewmate(true),
key: "b", makeCrewmate(false),
isImposter: false, makeCrewmate(false),
posX: 400, makeCrewmate(false),
posY: 200, makeCrewmate(false),
speedX: 10, makeCrewmate(false),
speedY: -20, makeCrewmate(false),
}, makeCrewmate(false),
{ makeCrewmate(false),
key: "c", ];
isImposter: false,
posX: 900,
posY: 200,
speedX: -20,
speedY: 10,
},
];
const makeCrewmate = (crewmate: Amogus) => {
const image = getImage(crewmate);
return (
<div
key={crewmate.key}
className={style.container}
style={{ top: crewmate.posY, left: crewmate.posX }}
>
<img src={image} alt="Amogus" />
</div>
);
}; };
const stepCrewmates = (list: Amogus[]) => { const randNum = (min: number, max: number): number =>
const { innerWidth: width, innerHeight: height } = window; Math.random() * (max - min) + min;
const newCrewmates = list.slice();
for (const c of newCrewmates) { const makeCrewmate = (imposter: boolean): Amogus => ({
let newX = c.posX + c.speedX; isImposter: imposter,
let newY = c.posY + c.speedY; posX: randNum(0, width - amogusWidth),
if (newX > width - 90) { posY: randNum(0, height - amogusHeight),
newX = width - 90; speedX: Math.random() > 0.5 ? randNum(3, 10) : randNum(-3, -10),
c.speedX *= -1; speedY: Math.random() > 0.5 ? randNum(3, 10) : randNum(-3, -10),
});
const intersect = (c1: Amogus, c2: Amogus): boolean =>
Math.abs(c1.posX - c2.posX) < amogusWidth - 20 &&
Math.abs(c1.posY - c2.posY) < amogusHeight - 20;
const doMove = (crewmates: Amogus[]) =>
crewmates.map((c) => ({
...c,
posX: c.posX + c.speedX,
posY: c.posY + c.speedY,
}));
const doCollisionWalls = (crewmates: Amogus[]) =>
crewmates.map((c) => {
if (c.posX > width - amogusWidth) {
return {
...c,
posX: width - amogusWidth,
speedX: c.speedX * -1,
};
} else if (c.posX < -20) {
return { ...c, posX: -20, speedX: c.speedX * -1 };
} else if (c.posY > height - amogusHeight) {
return {
...c,
posY: height - amogusHeight,
speedY: c.speedY * -1,
};
} else if (c.posY < -20) {
return { ...c, posY: -20, speedY: c.speedY * -1 };
} else return c;
});
// TODO: This is ugly
const doCollisionOthers = (crewmates: Amogus[]) =>
crewmates.map((c) => {
const intersections = crewmates
.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 };
} }
if (newX < 0) { if (intersections.some((o) => Math.abs(o.posY - c.posY) < 50)) {
newX = 0; return { ...c, speedY: c.speedY * -1 };
c.speedX *= -1;
} }
if (newY > height - 120) { return c;
newY = height - 120; });
c.speedY *= -1;
} const doKills = (crewmates: Amogus[]) => {
if (newY < 0) { const imposters = crewmates.filter((c) => c.isImposter);
newY = 0; const alive = crewmates
c.speedY *= -1; .filter((c) => !c.isImposter)
} .filter((c) => imposters.every((i) => !intersect(i, c)));
c.posX = newX; return imposters.concat(alive);
c.posY = newY;
}
return newCrewmates;
}; };
const checkReset = (crewmates: Amogus[]) =>
crewmates.every((c) => c.isImposter) ? makeInitialCrewmates() : crewmates;
const renderCrewmate = (crewmate: Amogus, key: number) => (
<div
key={key}
className={style.container}
style={{ top: crewmate.posY, left: crewmate.posX }}
>
<img src={getImage(crewmate)} alt="Amogus" />
</div>
);
export default function Amogus() { export default function Amogus() {
const [crewmates, setCrewmates] = useState(initialCrewmates); const [crewmates, setCrewmates] = useState(() => makeInitialCrewmates());
useEffect(() => { useEffect(() => {
const timer = setInterval(() => { const timer = setInterval(() => {
const c = crewmates; setCrewmates((c) => doMove(c));
setCrewmates(stepCrewmates(c)); setCrewmates((c) => doCollisionWalls(c));
}, 100); setCrewmates((c) => doCollisionOthers(c));
setCrewmates((c) => doKills(c));
setCrewmates((c) => checkReset(c));
}, 50);
return () => { return () => {
clearInterval(timer); clearInterval(timer);
}; };
}, [crewmates]); }, []);
return <>{crewmates.map((c) => makeCrewmate(c))}</>; return <>{crewmates.map((c, index) => renderCrewmate(c, index))}</>;
} }

View File

@@ -1,4 +1,8 @@
.container { .container {
z-index: 100; z-index: 100;
position: absolute; position: absolute;
scale: 50%;
display: flex;
justify-content: center;
align-items: center;
} }

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);
}
}