game-over.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use client";
  2. import { useEditorStore } from "@/lib/store";
  3. export function GameOverScreen() {
  4. const setIsPlaying = useEditorStore((s) => s.setIsPlaying);
  5. const setHealth = useEditorStore((s) => s.setHealth);
  6. const setShield = useEditorStore((s) => s.setShield);
  7. const maxHealth = useEditorStore((s) => s.maxHealth);
  8. const maxShield = useEditorStore((s) => s.maxShield);
  9. const handleRestart = () => {
  10. setHealth(maxHealth);
  11. setShield(maxShield);
  12. setIsPlaying(false);
  13. setTimeout(() => setIsPlaying(true), 100);
  14. };
  15. const handleExit = () => {
  16. setHealth(maxHealth);
  17. setShield(maxShield);
  18. setIsPlaying(false);
  19. };
  20. return (
  21. <div className="absolute inset-0 z-30 flex items-center justify-center bg-black/80 animate-fade-in">
  22. <div className="text-center px-4">
  23. <h1 className="text-3xl sm:text-5xl font-bold text-red-500 mb-2">
  24. GAME OVER
  25. </h1>
  26. <p className="text-[#888] mb-8 text-sm sm:text-base">
  27. You have been defeated
  28. </p>
  29. <div className="flex gap-3 justify-center">
  30. <button
  31. onClick={handleRestart}
  32. className="px-6 py-2.5 sm:py-2 bg-white/10 hover:bg-white/20 active:bg-white/30 text-white rounded-lg text-sm transition-colors min-w-[100px]"
  33. >
  34. Restart
  35. </button>
  36. <button
  37. onClick={handleExit}
  38. className="px-6 py-2.5 sm:py-2 bg-white/5 hover:bg-white/10 active:bg-white/20 text-[#888] rounded-lg text-sm transition-colors min-w-[100px]"
  39. >
  40. Exit
  41. </button>
  42. </div>
  43. </div>
  44. </div>
  45. );
  46. }