import React, { useState, useEffect } from "react"; import Button from "../components/Input/Button"; // @ts-ignore import ChromeDinoGame from "react-chrome-dino"; const NotFoundPage: React.FC = () => { const [stars, setStars] = useState< { x: number; y: number; xChange: number; yChange: number }[] >([]); const starSize = 30; const [score, setScore] = useState(0); const [isGameOver, setIsGameOver] = useState(false); useEffect(() => { console.log("Game over state:", isGameOver); const loop = setInterval(() => { if (Math.random() < 0.1) { const newStar = { x: score > 20000 ? window.innerWidth + starSize : Math.random() * (window.innerWidth - starSize), y: score > 20000 ? Math.random() * (window.innerHeight - starSize) : -starSize, xChange: score * 0.001, yChange: 5, }; setStars((prev) => [...prev, newStar]); } setStars((prev) => { const newStars = prev.filter((star) => { if ( star.y > window.innerHeight - starSize && star.y < window.innerHeight ) { return false; } if (star.y > window.innerHeight) return false; return true; }); return newStars.map((star) => ({ x: star.x - star.xChange, y: star.y + star.yChange, xChange: score * 0.001, yChange: star.yChange, })); }); if (isGameOver) { setScore(score * 0.99); } }, 10); return () => { clearInterval(loop); }; }, [isGameOver, score]); useEffect(() => { const gameMonitor = setInterval(() => { // Access the Runner instance (which the code stores in Runner.instance_) const runner = (window as any).Runner?.instance_; setIsGameOver(runner?.crashed); if (!runner?.crashed) setScore(runner?.distanceRan); }, 500); return () => { clearInterval(gameMonitor); }; }, []); return (
Page Not Found