Skip to content

Commit bdbfc6a

Browse files
committed
Added new missingno background and ability to unlock/lock secrets
1 parent 96b8abd commit bdbfc6a

13 files changed

Lines changed: 389 additions & 28 deletions

File tree

‎src/app/boot/page.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { useEffect } from "react";
44
import { useRouter } from "next/navigation";
55
//import Background from '@components/background/background';
66
import WebGlBackground from '@components/background/webGlBackground';
7+
import BackgroundView from "@components/background/BackgroundView";
78
import { useBoot } from '@context/BootContext';
89

910
export default function BootPage() {
@@ -24,7 +25,7 @@ export default function BootPage() {
2425

2526
return (
2627
<div className="root-container relative min-h-screen overflow-hidden pointer-events-auto opacity-100">
27-
<WebGlBackground />
28+
<BackgroundView />
2829
</div>
2930
);
3031
}

‎src/app/error.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { Suspense, useEffect, useState } from "react";
44
import { unstable_catchError as catchError, type ErrorInfo } from 'next/error';
55
//import Background from "@components/background/background";
66
import WebGlBackground from "@components/background/webGlBackground";
7+
import BackgroundView from "@components/background/BackgroundView";
78
import Clock from "@components/clock/Clock";
89
//import dynamic from "next/dynamic";
910
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@@ -71,7 +72,7 @@ export default function ErrorPage({
7172
return (
7273
<div className="root-container">
7374
<Suspense>
74-
<WebGlBackground />
75+
<BackgroundView />
7576
<Clock />
7677
</Suspense>
7778
<div className="grid content-center z-100 w-full h-full text-white">

‎src/app/not-found.tsx‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
"use client";
22

3-
import React, { Suspense } from "react";
3+
import React, { Suspense, useEffect } from "react";
44
import Image from "next/image";
55
import Link from "next/link";
66
//import Background from "@components/background/background";
77
import Clock from "@components/clock/Clock";
88
import WebGlBackground from "@components/background/webGlBackground";
9-
//import dynamic from "next/dynamic";
9+
import BackgroundView from "@components/background/BackgroundView";
1010
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
1111
import { faBug } from "@fortawesome/free-solid-svg-icons";
12+
import { AchievementId, useSecret } from "@context/SecretContext";
1213
import sh404 from "public/image/404.png";
1314
import "./not-found.css";
1415
import "@styles/global.scss";
1516

16-
//const Clock = dynamic(() => import('@components/clock/Clock'));
17-
1817
export default function NotFound() {
18+
19+
const { unlockSecret } = useSecret();
20+
21+
useEffect(() => {
22+
23+
unlockSecret(AchievementId._404);
24+
25+
}, []);
26+
1927
return (
2028
<div className="root-container">
2129
<Suspense>
22-
<WebGlBackground />
30+
<BackgroundView />
2331
<Clock />
2432
</Suspense>
2533
<div className="grid content-center z-100 overflow-hidden absolute left-0 top-0 w-full h-screen text-white">

‎src/app/page.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import Clock from "@components/clock/Clock";
77
import Menu from "@components/xmb-menu/xmb-menu";
88
import Modal from "@components/modal/Modal";
99
import WebGlBackground from "@components/background/webGlBackground";
10+
import BackgroundView from "@components/background/BackgroundView";
1011

1112
export default function Home() {
1213
const { isBootVisible, isBootTransitioningOut } = useBoot();
1314

1415
return (
1516
<div className="root-container">
16-
<WebGlBackground />
17+
<BackgroundView />
1718
{!isBootVisible && !isBootTransitioningOut && (
1819
<>
1920
<Clock />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use client';
2+
3+
import React, { useEffect, useRef, useState } from 'react';
4+
import { useSecret } from '@context/SecretContext';
5+
import PixelatedBackground from '@components/background/PixelatedBackground';
6+
import WebGlBackground from '@components/background/webGlBackground';
7+
8+
export default function BackgroundView() {
9+
10+
const { isMissingNoSecretActive } = useSecret();
11+
12+
return (
13+
<>
14+
{isMissingNoSecretActive
15+
? <PixelatedBackground />
16+
: <WebGlBackground />}
17+
</>
18+
);
19+
20+
}
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
'use client';
2+
3+
import React, { useEffect, useRef } from 'react';
4+
import "./pixelatedBackground.css";
5+
6+
// 2. Define Vertex Shader (Draws a full-screen quad)
7+
const vsSource = `
8+
attribute vec2 position;
9+
void main() {
10+
gl_Position = vec4(position, 0.0, 1.0);
11+
}
12+
`;
13+
14+
// 3. Define Fragment Shader (Generates pixelated procedural waves)
15+
const fsSource = `
16+
precision mediump float;
17+
uniform vec2 u_resolution;
18+
uniform float u_time;
19+
20+
void main() {
21+
// Pixel grid sizing: Adjust this number to change pixel size
22+
float pixelSize = 12.0; // 8.0
23+
24+
// Quantize coordinates to create the pixelated effect
25+
vec2 uv = floor(gl_FragCoord.xy / pixelSize) * pixelSize / u_resolution.xy;
26+
27+
// Create an example retro procedural animation pattern
28+
float colorA = sin(uv.x * 4.0 + u_time) * 0.5 + 0.5;
29+
float colorB = cos(uv.y * 4.0 - u_time) * 0.5 + 0.5;
30+
31+
gl_FragColor = vec4(colorA, colorB, 0.8, 1.0);
32+
}
33+
`;
34+
35+
export default function PixelatedBackground() {
36+
const canvasRef = useRef<HTMLCanvasElement | null>(null);
37+
const contextRef = useRef<WebGLRenderingContext | null>(null);
38+
const shaderProgramRef = useRef<WebGLProgram | null>(null);
39+
const positionLocationRef = useRef<number | null>(null);
40+
const timeUniformLocationRef = useRef<WebGLUniformLocation | null>(null);
41+
const resolutionUniformLocationRef = useRef<WebGLUniformLocation | null>(null);
42+
const positionBufferRef = useRef<WebGLBuffer | null>(null);
43+
const frameRef = useRef<number | null>(null);
44+
45+
// Render loop
46+
function render(time: number) {
47+
const canvas = canvasRef.current;
48+
if (!canvas) return;
49+
const gl = contextRef.current;
50+
if (!gl) return;
51+
const program = shaderProgramRef.current;
52+
if (!program) return;
53+
54+
const positionLocation = positionLocationRef.current;
55+
const positionBuffer = positionBufferRef.current;
56+
if (positionLocation === null || positionLocation === undefined || !positionBuffer) return;
57+
58+
const seconds = time * 0.001;
59+
60+
gl.clearColor(0, 0, 0, 1);
61+
gl.clear(gl.COLOR_BUFFER_BIT);
62+
63+
gl.useProgram(program);
64+
gl.uniform2f(resolutionUniformLocationRef.current, canvas.width, canvas.height);
65+
gl.uniform1f(timeUniformLocationRef.current, seconds);
66+
67+
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
68+
gl.enableVertexAttribArray(positionLocation);
69+
gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0);
70+
71+
gl.drawArrays(gl.TRIANGLES, 0, 6);
72+
73+
frameRef.current = requestAnimationFrame(render);
74+
}
75+
76+
function setup() {
77+
const canvas = canvasRef.current;
78+
if (!canvas) return;
79+
const gl = contextRef.current;
80+
if (!gl) return;
81+
82+
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vsSource);
83+
const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fsSource);
84+
85+
if (!vertexShader || !fragmentShader) return;
86+
87+
const program = gl.createProgram();
88+
if (!program) return;
89+
90+
gl.attachShader(program, vertexShader);
91+
gl.attachShader(program, fragmentShader);
92+
gl.linkProgram(program);
93+
94+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
95+
console.error(gl.getProgramInfoLog(program));
96+
return;
97+
}
98+
99+
shaderProgramRef.current = program;
100+
positionLocationRef.current = gl.getAttribLocation(program, 'position');
101+
resolutionUniformLocationRef.current = gl.getUniformLocation(program, 'u_resolution');
102+
timeUniformLocationRef.current = gl.getUniformLocation(program, 'u_time');
103+
104+
const positionBuffer = gl.createBuffer();
105+
if (!positionBuffer) return;
106+
107+
positionBufferRef.current = positionBuffer;
108+
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
109+
gl.bufferData(
110+
gl.ARRAY_BUFFER,
111+
new Float32Array([
112+
-1, -1, 1, -1, -1, 1,
113+
-1, 1, 1, -1, 1, 1,
114+
]),
115+
gl.STATIC_DRAW,
116+
);
117+
}
118+
119+
// Resize handler to match screen dimensions
120+
function resize() {
121+
const canvas = canvasRef.current;
122+
if (!canvas) return;
123+
const gl = contextRef.current;
124+
if (!gl) return;
125+
126+
const scale = 4;
127+
const width = Math.floor(window.innerWidth / scale);
128+
const height = Math.floor(window.innerHeight / scale);
129+
130+
if (canvas.width !== width || canvas.height !== height) {
131+
canvas.width = width;
132+
canvas.height = height;
133+
gl.viewport(0, 0, width, height);
134+
}
135+
}
136+
137+
// Helper function to compile shaders
138+
function createShader(gl: WebGLRenderingContext, type: number, source: string) {
139+
const shader = gl.createShader(type);
140+
if (!shader) return null;
141+
gl.shaderSource(shader, source);
142+
gl.compileShader(shader);
143+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
144+
console.error(gl.getShaderInfoLog(shader));
145+
gl.deleteShader(shader);
146+
return null;
147+
}
148+
return shader;
149+
}
150+
151+
useEffect(() => {
152+
const canvas = canvasRef.current;
153+
if (!canvas) return;
154+
155+
const gl = canvas.getContext('webgl', { antialias: false });
156+
if (!gl) {
157+
console.error('WebGL not supported');
158+
return;
159+
}
160+
161+
contextRef.current = gl;
162+
163+
window.addEventListener('resize', resize);
164+
resize();
165+
setup();
166+
167+
frameRef.current = requestAnimationFrame(render);
168+
169+
return () => {
170+
window.removeEventListener('resize', resize);
171+
if (frameRef.current !== null) {
172+
cancelAnimationFrame(frameRef.current);
173+
}
174+
if (shaderProgramRef.current) {
175+
gl.deleteProgram(shaderProgramRef.current);
176+
}
177+
if (positionBufferRef.current) {
178+
gl.deleteBuffer(positionBufferRef.current);
179+
}
180+
contextRef.current = null;
181+
};
182+
}, []);
183+
184+
return (
185+
<canvas
186+
id="webgl-canvas"
187+
ref={canvasRef}
188+
className="pixelated fixed top-0 left-0 w-screen h-screen -z-100 pointer-events-none"
189+
style={{ imageRendering: 'pixelated' }}
190+
/>
191+
);
192+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
canvas.pixelated {
2+
image-rendering: -moz-crisp-edges;
3+
image-rendering: -webkit-crisp-edges;
4+
image-rendering: pixelated;
5+
image-rendering: crisp-edges;
6+
}
7+
8+
.xmb-main, .xmb-category-title,
9+
.xmb-item-name, .xmb-item-description,
10+
.clock-container {
11+
/* text-shadow: -1px -1px 0 #0000009f, 1px -1px 0 #0000009f, -1px 1px 0 #0000009f, 1px 1px 0 #0000009f; */
12+
filter: drop-shadow(0 0 1px black);
13+
}
14+
15+
.clock, .psp-clock {
16+
border-color: black !important;
17+
text-shadow: -1px -1px 0 #0000009f, 1px -1px 0 #0000009f, -1px 1px 0 #0000009f, 1px 1px 0 #0000009f;
18+
}
19+
20+
.clock svg, .clock img, .psp-clock svg, .psp-clock img {
21+
filter: drop-shadow(0 0 1px black);
22+
}

‎src/components/background/webGlBackground.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,9 @@ export default function WebGlBackground() {
210210
// draw each animation frame.
211211
const renderFrame = (timeMs: number) => {
212212
if (!contextRef.current) return;
213-
214213
const context = contextRef.current;
215214

216215
if (!canvasRef.current) return;
217-
218216
const canvas = canvasRef.current;
219217

220218
context.clear(context.COLOR_BUFFER_BIT);

‎src/components/clock/Clock.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default function Clock() {
7474

7575
return (
7676
<>
77-
<div className={`${ !isPspSecretActive ? 'clock' : 'psp-clock' } boot-fade-in rounded-sm absolute p-2 select-none pointer-events-none tabular-nums`}>
77+
<div className={`${ !isPspSecretActive ? 'clock' : 'psp-clock' } boot-fade-in rounded-sm absolute p-2 select-none pointer-events-none tabular-nums`}>
7878
<div className={`clock-container ${loaded ? 'flex' : 'hidden'} ${isPspSecretActive ? pspFontClass : clockFont.className} tracking-normal align-middle flex flex-nowrap items-center ${isPspSecretActive && '-mt-1'}`}>
7979
<div className="flex flex-nowrap gap-0 items-center mx-2">
8080
<span>{month}</span>

0 commit comments

Comments
 (0)