-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path404.html
More file actions
510 lines (463 loc) · 16.4 KB
/
Copy path404.html
File metadata and controls
510 lines (463 loc) · 16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<!-- Esta página aparece en cualquier ruta rota, así que fija la raíz del sitio
antes de resolver fuentes, iconos y enlaces. -->
<base href="/portafolio/">
<script>
(function () {
var seg = location.pathname.split('/')[1];
document.querySelector('base').href =
/\.github\.io$/.test(location.hostname) && seg ? '/' + seg + '/' : '/';
})();
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Página no encontrada, pero Benny necesita quien lo acompañe.">
<meta name="robots" content="noindex">
<title>404 · Emily Castellanos</title>
<meta name="theme-color" content="#0a0f1c">
<link rel="icon" href="img/favicon.ico" sizes="48x48">
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">
<style>
@font-face {
font-family: 'Fraunces';
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url('fonts/fraunces-latin.woff2') format('woff2');
}
@font-face {
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url('fonts/jetbrainsmono-latin.woff2') format('woff2');
}
:root {
--bg: #0a0f1c;
--bg-deep: #131b2e;
--ink: #e8edf5;
--ink-soft: #94a3b8;
--ink-mute: #64748b;
--accent: #e8963e;
--line: #1f2940;
--serif: "Fraunces", Georgia, "Times New Roman", serif;
--mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
--sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
"Helvetica Neue", Arial, sans-serif;
--r: 6px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
font-family: var(--sans);
font-size: 16px;
line-height: 1.6;
color: var(--ink);
background: var(--bg);
background-image:
radial-gradient(ellipse 80% 50% at 15% 0%, rgba(232, 150, 62, 0.09), transparent 60%),
radial-gradient(ellipse 70% 50% at 85% 100%, rgba(56, 189, 248, 0.07), transparent 60%);
background-attachment: fixed;
-webkit-font-smoothing: antialiased;
min-height: 100vh;
min-height: 100svh;
display: grid;
place-items: center;
padding: 4.5rem 1.25rem 2rem;
}
a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.nav {
position: fixed;
top: 0; left: 0; right: 0;
padding: 1.1rem 1.5rem;
background: rgba(10, 15, 28, 0.78);
backdrop-filter: blur(14px) saturate(140%);
border-bottom: 1px solid var(--line);
}
.nav__brand {
font-family: var(--mono);
font-weight: 700;
font-size: 1.05rem;
color: var(--ink);
}
.nav__cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.wrap { width: min(94vw, 820px); text-align: center; }
.eyebrow {
font-family: var(--mono);
font-weight: 700;
font-size: clamp(1.7rem, 4.5vw, 2.5rem);
line-height: 1.2;
color: var(--accent);
margin-bottom: 0.5rem;
}
.sub {
font-family: var(--serif);
font-size: clamp(1.05rem, 2.4vw, 1.4rem);
color: var(--ink);
text-wrap: balance;
}
.sub em { font-style: italic; color: var(--accent); }
.lead em { font-style: italic; color: var(--ink); }
.lead {
color: var(--ink-soft);
max-width: 34rem;
margin: 0.9rem auto 1.75rem;
text-wrap: balance;
}
.card {
background: var(--bg-deep);
border: 1px solid var(--line);
border-radius: 12px;
padding: 16px 16px 8px;
box-shadow: 0 10px 30px rgba(3, 7, 18, 0.5);
}
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; border-radius: var(--r); touch-action: manipulation; }
.hint {
font-family: var(--mono);
font-size: 0.72rem;
color: var(--ink-mute);
margin: 10px 0 4px;
user-select: none;
}
kbd {
border: 1px solid var(--line);
border-bottom-width: 2px;
border-radius: 4px;
padding: 0 5px;
font-family: inherit;
}
.hint-tel { display: none; }
@media (pointer: coarse) {
.hint-pc { display: none; }
.hint-tel { display: inline; }
}
@media (max-width: 480px) {
body { padding: 4rem 0.6rem 1.5rem; }
.card { padding: 10px 10px 6px; border-radius: 10px; }
}
.back {
display: inline-block;
margin-top: 1.6rem;
font-family: var(--mono);
font-size: 0.9rem;
color: var(--accent);
border-bottom: 1px solid transparent;
transition: border-color 0.15s ease;
}
.back:hover { border-color: var(--accent); }
.foot {
margin-top: 2.2rem;
font-family: var(--mono);
font-size: 0.72rem;
color: var(--ink-mute);
}
</style>
</head>
<body>
<header class="nav">
<a href="./" class="nav__brand">EC<span class="nav__cursor">_</span></a>
</header>
<main class="wrap">
<h1 class="eyebrow">// ERROR 404</h1>
<p class="sub">Esta página se fue a perseguir <em>palomas</em>.</p>
<p class="lead">
Parece que no tienes internet o el enlace que buscas <em>no</em> existe.
Mientras encuentras el camino de vuelta, Benny necesita quien lo acompañe :D
</p>
<div class="card">
<canvas id="game" width="760" height="300"></canvas>
<p class="hint"><span class="hint-pc"><kbd>Espacio</kbd> / <kbd>↑</kbd> / clic para saltar · <kbd>R</kbd> reinicia · </span><span class="hint-tel">Toca la pantalla para saltar · </span>¡a las palomas altas NO les saltes!</p>
</div>
<a class="back" href="./">← Volver al portafolio</a>
<p class="foot">© 2026 Emily R. Castellanos</p>
</main>
<script>
(() => {
"use strict";
const cvs = document.getElementById("game");
const ctx = cvs.getContext("2d");
const H = 300, GROUND = 252;
const DPR = Math.min(window.devicePixelRatio || 1, 3);
const TOUCH = matchMedia("(pointer: coarse)").matches;
let W = 760;
function sizeCanvas(){
// en pantallas chicas el mundo lógico se hace angosto para que todo se vea grande
const cssW = cvs.clientWidth || 760;
W = cssW < 600 ? Math.max(400, Math.round(cssW * 1.25)) : 760;
cvs.width = W * DPR; cvs.height = H * DPR;
ctx.setTransform(DPR, 0, 0, DPR, 0, 0);
ctx.imageSmoothingEnabled = false;
}
sizeCanvas();
let resizeT = null;
addEventListener("resize", () => { clearTimeout(resizeT); resizeT = setTimeout(sizeCanvas, 150); });
/* ---------- paleta (a juego con el portafolio) ---------- */
const C = {
hyd:"#dc2626", hydDark:"#991b1b", hydLight:"#f87171",
cloud:"#3b4a6b", ground:"#2dd4bf", speck:"#0f766e",
nSky:"#060b16", nStar:"#e2e8f0", nCloud:"#26314d", nGround:"#0d9488", nSpeck:"#115e59",
};
const FG = "#e8edf5", MUTED = "#94a3b8";
const FONT = "'JetBrains Mono',Consolas,monospace";
/* ---------- sprite del perrito (28x20, 3px por celda) ----------
K contorno · O pelo castaño · D oreja/cola oscuras · W pecho crema */
const PAL = { K:"#1a1208", O:"#b5651d", D:"#7a4310", W:"#f2e3c4" };
const BODY = [
".KKK.............KKKKKK.....",
"KDDDK...........KOOOOOOK....",
"KDDDK..........KDDOOOOOK....",
"KDDDDK.......KDDDOOOOOOK....",
".KDDDK......KDDDDOOOKKOOOKK.",
"..KDDK......KDDDDOOOKKOOOKK.",
"...KDK......KDDDOOOOOOOOOOOK",
"....KDK......KDDOOOOOOOKKKK.",
"....KKKKKKKKKKKOOWWWWK......",
"....KOOOOOOOOOOOOWWWWWK.....",
"....KOOOOOOOOOOOOWWWWWK.....",
"....KOOOOOOOOOOOOWWWWK......",
"....KOOOOOOOOOOOWWWWK.......",
".....KOOOOOOOOOOWWWK........",
".....KOOOOOOOOOOWWK.........",
"......KKOOOOOOOKKK..........",
];
const LEGS_A = [
".....KOK......KOK...........",
".....KOK......KOK...........",
"....KOOK.....KOOK...........",
"....KKK......KKK............",
];
const LEGS_B = [
".......KOK..KOK.............",
".......KOK..KOK.............",
".......KOOK.KOOK............",
"........KK...KK.............",
];
const FRAME_A = BODY.concat(LEGS_A);
const FRAME_B = BODY.concat(LEGS_B);
const FRAME_DEAD = FRAME_A.map((r,i) => (i===4||i===5) ? r.replace("OKKO","ODDO") : r);
const SPR = 3, DOG_X = 56, DOG_W = 28*SPR, DOG_H = 20*SPR;
/* ---------- sprite de la paloma (14x8, 3px por celda) ---------- */
const PALB = { G:"#9aa5b1", D:"#6b7684", O:"#f59e0b", B:"#1e293b" };
const BIRD_A = [
".......GG.....",
"......GGG.....",
"......GGG.....",
"OGBGGGGGGGGGG.",
".GGGGGGGGGGDD.",
"...GGGGGGG....",
"..............",
"..............",
];
const BIRD_B = [
"..............",
"..............",
"..............",
"OGBGGGGGGGGGG.",
".GGGGGGGGGGDD.",
"...GGGGGGG....",
"......GGG.....",
".......GG.....",
];
function drawSprite(rows, pal, x, y){
for (let r = 0; r < rows.length; r++){
const row = rows[r];
for (let c = 0; c < row.length; c++){
const k = row[c];
if (k === ".") continue;
ctx.fillStyle = pal[k];
ctx.fillRect(Math.round(x + c*SPR), Math.round(y + r*SPR), SPR, SPR);
}
}
}
/* ---------- sonido ---------- */
let ac = null;
function beep(freq, dur = 0.07, type = "square", gain = 0.035){
try {
ac = ac || new (window.AudioContext || window.webkitAudioContext)();
const o = ac.createOscillator(), g = ac.createGain();
o.type = type; o.frequency.value = freq; g.gain.value = gain;
o.connect(g); g.connect(ac.destination);
o.start();
g.gain.exponentialRampToValueAtTime(0.0001, ac.currentTime + dur);
o.stop(ac.currentTime + dur);
} catch(e){}
}
function yip(){ beep(740, .045); setTimeout(() => beep(520, .06), 55); }
/* ---------- estado ---------- */
let state = "idle"; // idle | run | over
let speed, dist, score, nextMilestone, gapLeft;
let dogY, vy, legT; // dogY: 0 en el suelo, negativo en el aire
let obstacles, clouds, specks, stars;
let deadFlash = 0, deadAt = 0, newBest = false;
let best = 0;
try { best = +localStorage.getItem("perrito_runner_best") || 0; } catch(e){}
function reset(){
speed = 400; dist = 0; score = 0; nextMilestone = 100;
dogY = 0; vy = 0; legT = 0; newBest = false;
obstacles = []; gapLeft = 480;
clouds = [{x:180,y:55},{x:470,y:95},{x:660,y:40}];
specks = []; stars = [];
for (let i = 0; i < 26; i++)
specks.push({ x: Math.random()*W, y: GROUND + 8 + Math.random()*16, w: 4 + Math.random()*8 });
for (let i = 0; i < 28; i++)
stars.push({ x: Math.random()*W, y: Math.random()*140 });
}
function spawn(){
if (score > 50 && Math.random() < 0.28){
const baja = Math.random() < 0.6; // baja: saltala · alta: pasa por debajo
obstacles.push({ type:"bird", x: W + 40, w: 42, h: 24, tw: 42,
y: baja ? GROUND - 44 : GROUND - 98,
extra: 60 + Math.random()*60 });
} else {
let n = 1, w = 24, h = 40;
const t = Math.random();
if (score > 200 && t < 0.15) n = 3;
else if (score > 40 && t < 0.35) n = 2;
else if (t < 0.6) { w = 26; h = 54; }
obstacles.push({ type:"hyd", x: W + 40, w, h, n, tw: n*w + (n-1)*10 });
}
gapLeft = 220 + Math.random()*240 + speed*0.30;
}
/* ---------- lógica ---------- */
function step(dt){
speed = Math.min(speed + 22*dt, W < 600 ? 950 : 1100);
dist += speed*dt;
score = Math.floor(dist/24);
if (score >= nextMilestone){
nextMilestone += 100;
beep(660, .05); setTimeout(() => beep(880, .07), 90);
}
vy += 2600*dt; dogY += vy*dt;
if (dogY > 0){ dogY = 0; vy = 0; }
legT += dt*11;
gapLeft -= speed*dt;
if (gapLeft <= 0) spawn();
for (const o of obstacles) o.x -= (speed + (o.extra || 0))*dt;
obstacles = obstacles.filter(o => o.x + o.tw > -20);
for (const c of clouds){
c.x -= speed*0.25*dt;
if (c.x < -90){ c.x = W + 40 + Math.random()*140; c.y = 30 + Math.random()*75; }
}
for (const s of specks){
s.x -= speed*dt;
if (s.x < -12){ s.x = W + Math.random()*30; s.y = GROUND + 8 + Math.random()*16; s.w = 4 + Math.random()*8; }
}
// colisión (caja con margen de perdón)
const dx = DOG_X + 12, dw = DOG_W - 32;
const dy = GROUND - DOG_H + dogY + 6, dh = DOG_H - 10;
for (const o of obstacles){
const ox = o.x + 2, ow = o.tw - 4;
const oy = (o.type === "bird" ? o.y : GROUND - o.h) + 2, oh = o.h - 4;
if (dx < ox + ow && dx + dw > ox && dy < oy + oh && dy + dh > oy){ die(); break; }
}
}
function die(){
state = "over"; deadFlash = 0.9; deadAt = performance.now();
if (score > best){ best = score; newBest = true; try { localStorage.setItem("perrito_runner_best", best); } catch(e){} }
beep(150, .3, "sawtooth", 0.05);
}
function press(){
if (state === "over"){
if (performance.now() - deadAt > 400){ reset(); state = "run"; }
return;
}
if (state === "idle") state = "run";
if (dogY === 0){ vy = -860; yip(); }
}
addEventListener("keydown", e => {
if (e.code === "Space" || e.code === "ArrowUp"){ e.preventDefault(); press(); }
else if (e.code === "KeyR" && state === "over"){ reset(); state = "run"; }
});
cvs.addEventListener("pointerdown", e => { e.preventDefault(); press(); });
/* ---------- dibujo ---------- */
function drawCloud(c, color){
ctx.fillStyle = color;
const x = Math.round(c.x), y = Math.round(c.y);
ctx.fillRect(x, y+10, 64, 10);
ctx.fillRect(x+12, y+4, 26, 6);
ctx.fillRect(x+20, y, 14, 4);
ctx.fillRect(x+42, y+6, 16, 4);
}
function drawHydrant(o){
for (let i = 0; i < o.n; i++){
const x = Math.round(o.x + i*(o.w + 10)), y = GROUND - o.h, w = o.w;
ctx.fillStyle = C.hyd;
ctx.fillRect(x, GROUND - 5, w, 5); // base
ctx.fillRect(x+4, y+8, w-8, o.h-8); // cuerpo
ctx.fillRect(x+6, y+3, w-12, 6); // domo
ctx.fillRect(x + ((w/2)|0) - 2, y, 5, 4); // tapa
ctx.fillStyle = C.hydDark;
ctx.fillRect(x, y+14, 4, 6); // brazo izq
ctx.fillRect(x+w-4, y+14, 4, 6); // brazo der
ctx.fillStyle = C.hydLight;
ctx.fillRect(x+4, y+21, w-8, 3); // banda
}
}
function drawBird(o){
const rows = (Math.floor(legT*1.6) % 2 === 0) ? BIRD_A : BIRD_B;
drawSprite(rows, PALB, o.x, o.y);
}
function draw(){
ctx.clearRect(0, 0, W, H);
const night = Math.floor(score/200) % 2 === 1;
if (night){
ctx.fillStyle = C.nSky; ctx.fillRect(0, 0, W, H);
ctx.fillStyle = C.nStar;
for (const st of stars) ctx.fillRect(Math.round(st.x), Math.round(st.y), 2, 2);
}
for (const c of clouds) drawCloud(c, night ? C.nCloud : C.cloud);
ctx.fillStyle = night ? C.nGround : C.ground; ctx.fillRect(0, GROUND, W, 3);
ctx.fillStyle = night ? C.nSpeck : C.speck;
for (const s of specks) ctx.fillRect(Math.round(s.x), Math.round(s.y), Math.round(s.w), 2);
for (const o of obstacles){
if (o.type === "bird") drawBird(o); else drawHydrant(o);
}
let frame = FRAME_A;
if (state === "over") frame = FRAME_DEAD;
else if (dogY < 0) frame = FRAME_B; // patas recogidas en el aire
else if (state === "run") frame = (Math.floor(legT) % 2 === 0) ? FRAME_A : FRAME_B;
drawSprite(frame, PAL, DOG_X, GROUND - DOG_H + dogY);
ctx.fillStyle = night ? C.nStar : FG;
ctx.font = "15px " + FONT;
ctx.textAlign = "right";
ctx.fillText("Score: " + score + " Best: " + best, W - 16, 30);
ctx.textAlign = "center";
if (state === "idle"){
ctx.font = "bold 20px " + FONT;
ctx.fillText(TOUCH ? "Toca la pantalla para jugar" : "Pulsa ESPACIO o haz clic para jugar", W/2, 120);
} else if (state === "over"){
ctx.font = "bold 28px " + FONT;
ctx.fillText("GAME OVER", W/2, 112);
ctx.font = "14px " + FONT;
ctx.fillStyle = night ? "#94a3b8" : MUTED;
const rr = TOUCH ? "Toca para reiniciar" : "Espacio o clic para reiniciar";
ctx.fillText(newBest ? "¡Nuevo récord! · " + rr : rr, W/2, 140);
}
if (deadFlash > 0){
ctx.fillStyle = "rgba(255,255,255," + (deadFlash*0.35).toFixed(3) + ")";
ctx.fillRect(0, 0, W, H);
deadFlash = Math.max(0, deadFlash - 0.06);
}
}
/* ---------- bucle ---------- */
let last = null;
function frame(ts){
const dt = Math.min((ts - (last === null ? ts : last)) / 1000, 0.05);
last = ts;
if (state === "run") step(dt);
draw();
requestAnimationFrame(frame);
}
document.addEventListener("visibilitychange", () => { last = null; });
reset();
requestAnimationFrame(frame);
})();
if ("serviceWorker" in navigator) navigator.serviceWorker.register("sw.js");
</script>
</body>
</html>