fixed fullscreen crash
This commit is contained in:
parent
de4400c52f
commit
4798b2a0c6
|
|
@ -27,11 +27,4 @@ bun dev
|
||||||
## 📋 Ideas
|
## 📋 Ideas
|
||||||
|
|
||||||
- Add global big board
|
- Add global big board
|
||||||
- Questinmark after flag
|
|
||||||
- Earn points for wins
|
|
||||||
- Powerups
|
- Powerups
|
||||||
|
|
||||||
## TODOs
|
|
||||||
|
|
||||||
- Fix scoreboard modal
|
|
||||||
- Fix fullscrean
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,11 @@ interface ViewportInfo {
|
||||||
y: number;
|
y: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const toViewportInfo = (viewport: PixiViewport) => {
|
const toViewportInfo = (viewport: PixiViewport | null) => {
|
||||||
|
// Viewport or its properties may be null during mount/unmount transitions
|
||||||
|
if (!viewport || viewport.x == null || viewport.y == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
x: -viewport.x / viewport.scaled,
|
x: -viewport.x / viewport.scaled,
|
||||||
y: -viewport.y / viewport.scaled,
|
y: -viewport.y / viewport.scaled,
|
||||||
|
|
@ -102,9 +106,11 @@ const Board: React.FC<BoardProps> = (props) => {
|
||||||
y: 0,
|
y: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const onViewportChange = useCallback((viewport: PixiViewport) => {
|
const onViewportChange = useCallback((viewport: PixiViewport | null) => {
|
||||||
setViewport((v) => {
|
setViewport((v) => {
|
||||||
const { width, height, x, y } = toViewportInfo(viewport);
|
const info = toViewportInfo(viewport);
|
||||||
|
if (!info) return v;
|
||||||
|
const { width, height, x, y } = info;
|
||||||
if (v.width !== width || v.height !== height) {
|
if (v.width !== width || v.height !== height) {
|
||||||
return { width, height, x, y };
|
return { width, height, x, y };
|
||||||
}
|
}
|
||||||
|
|
@ -115,9 +121,10 @@ const Board: React.FC<BoardProps> = (props) => {
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInterval(() => {
|
const intervalId = setInterval(() => {
|
||||||
if (viewportRef.current) onViewportChange(viewportRef.current);
|
if (viewportRef.current) onViewportChange(viewportRef.current);
|
||||||
}, 200);
|
}, 200);
|
||||||
|
return () => clearInterval(intervalId);
|
||||||
}, [game.width, game.height, onViewportChange]);
|
}, [game.width, game.height, onViewportChange]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!ref.current) return;
|
if (!ref.current) return;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,35 @@ import Section from "./Section";
|
||||||
import Hr from "../../components/Hr";
|
import Hr from "../../components/Hr";
|
||||||
import { Link } from "wouter";
|
import { Link } from "wouter";
|
||||||
|
|
||||||
|
const taglines = [
|
||||||
|
"is the greatest experience",
|
||||||
|
"will blow your mind (literally)",
|
||||||
|
"99% luck, 1% skill, 100% rage",
|
||||||
|
"where clicking randomly is a strategy",
|
||||||
|
"sponsored by your cardiologist",
|
||||||
|
"teaching probability since 1990",
|
||||||
|
"the original trust issues simulator",
|
||||||
|
"50/50 has never felt so wrong",
|
||||||
|
"making grown adults say 'one more game'",
|
||||||
|
"it's not gambling, it's math",
|
||||||
|
"click responsibly",
|
||||||
|
"where every square is a life decision",
|
||||||
|
"the reason you have trust issues",
|
||||||
|
"now with 100% more explosions",
|
||||||
|
"technically a puzzle game",
|
||||||
|
"stress testing your mouse since 1990",
|
||||||
|
"flag it and pray",
|
||||||
|
"corner clicks are self-care",
|
||||||
|
"because therapy is expensive",
|
||||||
|
"sweeping mines, not floors",
|
||||||
|
"your daily dose of anxiety",
|
||||||
|
"where 1 means run",
|
||||||
|
"perfecting the art of guessing",
|
||||||
|
"the game that never forgives",
|
||||||
|
];
|
||||||
|
|
||||||
|
const randomTagline = taglines[Math.floor(Math.random() * taglines.length)];
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const { data: userCount } = useWSQuery("user.getUserCount", null);
|
const { data: userCount } = useWSQuery("user.getUserCount", null);
|
||||||
const { data: gameCount } = useWSQuery("game.getTotalGamesPlayed", {});
|
const { data: gameCount } = useWSQuery("game.getTotalGamesPlayed", {});
|
||||||
|
|
@ -45,7 +74,7 @@ const Home = () => {
|
||||||
Business Minesweeper
|
Business Minesweeper
|
||||||
<br />
|
<br />
|
||||||
<span className="[background:var(--bg-brand)] [-webkit-text-fill-color:transparent] font-black [-webkit-background-clip:text!important] font-mono text-xl md:text-4xl text-center">
|
<span className="[background:var(--bg-brand)] [-webkit-text-fill-color:transparent] font-black [-webkit-background-clip:text!important] font-mono text-xl md:text-4xl text-center">
|
||||||
is the greatest experience
|
{randomTagline}
|
||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
<span className="flex gap-8 items-center">
|
<span className="flex gap-8 items-center">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue