Spaces:
Running

SorrelC commited on
Commit
d3587f9
·
verified ·
1 Parent(s): ed45339

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +546 -286
index.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Archive Snake - Digital Preservation Game</title>
7
  <link href="https://fonts.googleapis.com/css2?family=VT323&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
8
  <style>
9
  * {
@@ -18,8 +18,7 @@
18
  --crt-amber: #ffb000;
19
  --floppy-blue: #1a5fb4;
20
  --cd-purple: #9141ac;
21
- --tape-brown: #865e3c;
22
- --hdd-silver: #c0c0c0;
23
  --bit-rot: #ff4444;
24
  --bg-dark: #0a0a0f;
25
  --bg-terminal: #0d1117;
@@ -59,7 +58,7 @@
59
  }
60
 
61
  .container {
62
- max-width: 900px;
63
  width: 100%;
64
  }
65
 
@@ -70,7 +69,7 @@
70
 
71
  h1 {
72
  font-family: 'VT323', monospace;
73
- font-size: 3.5rem;
74
  color: var(--crt-green);
75
  text-shadow:
76
  0 0 10px var(--crt-green),
@@ -95,7 +94,7 @@
95
 
96
  .game-wrapper {
97
  display: grid;
98
- grid-template-columns: 1fr 220px;
99
  gap: 20px;
100
  margin-bottom: 20px;
101
  }
@@ -174,30 +173,151 @@
174
  50% { opacity: 0.5; }
175
  }
176
 
177
- .legend-item {
 
 
 
 
 
178
  display: flex;
179
  align-items: center;
180
  gap: 10px;
181
  margin-bottom: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  font-size: 0.75rem;
183
  }
184
 
185
  .legend-icon {
186
- width: 24px;
187
- height: 24px;
188
- border-radius: 4px;
 
 
 
 
 
 
 
 
189
  display: flex;
 
190
  align-items: center;
191
- justify-content: center;
192
- font-size: 14px;
193
  }
194
 
195
- .legend-icon.floppy { background: var(--floppy-blue); }
196
- .legend-icon.cd { background: var(--cd-purple); }
197
- .legend-icon.tape { background: var(--tape-brown); }
198
- .legend-icon.hdd { background: var(--hdd-silver); color: #000; }
199
- .legend-icon.quiz { background: var(--crt-amber); color: #000; }
200
- .legend-icon.bitrot { background: var(--bit-rot); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  .controls {
203
  display: flex;
@@ -298,17 +418,24 @@
298
 
299
  .modal {
300
  background: var(--panel-bg);
301
- border: 3px solid var(--crt-amber);
302
  border-radius: 12px;
303
  padding: 30px;
304
  max-width: 500px;
305
  width: 90%;
306
  box-shadow:
307
- 0 0 40px rgba(255, 176, 0, 0.3),
308
- 0 0 80px rgba(255, 176, 0, 0.1);
309
  animation: modalIn 0.3s ease-out;
310
  }
311
 
 
 
 
 
 
 
 
312
  @keyframes modalIn {
313
  from {
314
  opacity: 0;
@@ -322,22 +449,26 @@
322
 
323
  .modal h2 {
324
  font-family: 'VT323', monospace;
325
- color: var(--crt-amber);
326
- font-size: 2rem;
327
- margin-bottom: 20px;
328
  text-align: center;
329
  }
330
 
331
- .modal .question {
332
  color: var(--crt-green);
333
- font-size: 1.1rem;
334
- margin-bottom: 20px;
335
- line-height: 1.5;
 
 
 
 
336
  }
337
 
338
  .modal .term-display {
339
  background: var(--bg-terminal);
340
- border: 2px solid var(--crt-green);
341
  padding: 15px;
342
  border-radius: 8px;
343
  margin-bottom: 20px;
@@ -347,8 +478,8 @@
347
  .modal .term-display span {
348
  font-family: 'VT323', monospace;
349
  font-size: 1.8rem;
350
- color: var(--crt-green);
351
- text-shadow: 0 0 10px var(--crt-green);
352
  }
353
 
354
  .answer-options {
@@ -360,8 +491,8 @@
360
  .answer-btn {
361
  text-align: left;
362
  font-family: 'Space Mono', monospace;
363
- font-size: 0.85rem;
364
- padding: 15px;
365
  border: 2px solid var(--border-glow);
366
  background: var(--bg-terminal);
367
  color: #c9d1d9;
@@ -388,12 +519,19 @@
388
  color: var(--bit-rot);
389
  }
390
 
391
- .quiz-timer {
392
  text-align: center;
393
  margin-top: 15px;
394
  font-family: 'VT323', monospace;
395
- font-size: 1.5rem;
396
- color: var(--crt-amber);
 
 
 
 
 
 
 
397
  }
398
 
399
  /* Game Over Modal */
@@ -445,7 +583,7 @@
445
  }
446
 
447
  h1 {
448
- font-size: 2.5rem;
449
  }
450
 
451
  .side-panel {
@@ -455,7 +593,7 @@
455
 
456
  .panel {
457
  flex: 1;
458
- min-width: 150px;
459
  }
460
  }
461
  </style>
@@ -463,7 +601,7 @@
463
  <body>
464
  <div class="container">
465
  <header>
466
- <h1>🐍 ARCHIVE SNAKE</h1>
467
  <p class="subtitle">Preserve Digital Heritage Before It's Lost</p>
468
  </header>
469
 
@@ -483,10 +621,6 @@
483
  <span class="stat-label">Time Left</span>
484
  <span class="stat-value time" id="timer">2:00</span>
485
  </div>
486
- <div class="stat-row">
487
- <span class="stat-label">Archived</span>
488
- <span class="stat-value" id="archived">0</span>
489
- </div>
490
  <div class="stat-row">
491
  <span class="stat-label">Quizzes</span>
492
  <span class="stat-value" id="quizzes">0/0</span>
@@ -494,43 +628,76 @@
494
  </div>
495
 
496
  <div class="panel">
497
- <div class="panel-title">📁 Artifacts</div>
498
- <div class="legend-item">
499
- <div class="legend-icon floppy">💾</div>
500
- <span>Floppy +10</span>
501
- </div>
502
- <div class="legend-item">
503
- <div class="legend-icon cd">💿</div>
504
- <span>CD-ROM +20</span>
505
- </div>
506
- <div class="legend-item">
507
- <div class="legend-icon tape">📼</div>
508
- <span>Tape +30</span>
509
- </div>
510
- <div class="legend-item">
511
- <div class="legend-icon hdd">🗄️</div>
512
- <span>HDD +50</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
513
  </div>
514
- <div class="legend-item">
515
- <div class="legend-icon quiz">❓</div>
516
- <span>Quiz +15s</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
  </div>
518
  <div class="legend-item">
519
- <div class="legend-icon bitrot">☠️</div>
520
- <span>Bit Rot -5s</span>
521
  </div>
522
  </div>
523
  </div>
524
  </div>
525
 
526
  <div class="controls">
527
- <button id="startBtn" onclick="startGame()">▶ Start Mission</button>
528
  <button class="secondary" onclick="pauseGame()" id="pauseBtn" disabled>⏸ Pause</button>
529
  </div>
530
 
531
  <div class="instructions">
532
  <h2>📋 Mission Briefing</h2>
533
- <p>You are the <strong>Digital Preservation Pipeline</strong>. Your mission: collect endangered digital artifacts before time runs out!</p>
534
  <p>
535
  <span class="key-hint">↑</span>
536
  <span class="key-hint">↓</span>
@@ -543,11 +710,14 @@
543
  <span class="key-hint">D</span>
544
  to navigate
545
  </p>
546
- <p>Collect <strong>Quiz Orbs ❓</strong> to answer preservation questions for bonus time. Avoid <strong>Bit Rot ☠️</strong> zones!</p>
 
 
 
547
  </div>
548
 
549
  <div class="attribution">
550
- <strong>Glossary Source:</strong> Digital Preservation Handbook, 2nd Edition,
551
  <a href="https://www.dpconline.org/handbook" target="_blank">dpconline.org/handbook</a><br>
552
  Digital Preservation Coalition © 2015 —
553
  <a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" target="_blank">OGL v3.0</a>
@@ -556,16 +726,18 @@
556
 
557
  <!-- Quiz Modal -->
558
  <div class="modal-overlay" id="quizModal">
559
- <div class="modal">
560
- <h2>🎓 Preservation Quiz!</h2>
561
- <p class="question">Match this term with its definition:</p>
562
  <div class="term-display">
563
  <span id="quizTerm">OAIS</span>
564
  </div>
565
  <div class="answer-options" id="answerOptions">
566
  <!-- Answers populated by JS -->
567
  </div>
568
- <div class="quiz-timer">⏱ <span id="quizTimer">10</span>s</div>
 
 
569
  </div>
570
  </div>
571
 
@@ -579,16 +751,24 @@
579
  <span class="value" id="finalScore">0</span>
580
  </div>
581
  <div class="final-stat">
582
- <span class="label">Artifacts Archived</span>
583
- <span class="value" id="finalArchived">0</span>
 
 
 
 
 
 
 
 
584
  </div>
585
  <div class="final-stat">
586
  <span class="label">Quiz Accuracy</span>
587
  <span class="value" id="finalQuizzes">0%</span>
588
  </div>
589
  <div class="final-stat">
590
- <span class="label">Pipeline Length</span>
591
- <span class="value" id="finalLength">0</span>
592
  </div>
593
  </div>
594
  <button onclick="restartGame()" style="width: 100%;">🔄 New Mission</button>
@@ -596,58 +776,71 @@
596
  </div>
597
 
598
  <script>
599
- // Glossary data from DPC Handbook
600
  const glossaryData = [
601
- { term: "OAIS", definition: "Open Archival Information System. An Archive consisting of an organization of people and systems that has accepted the responsibility to preserve information and make it available for a Designated Community." },
602
- { term: "AIP", definition: "Archival Information Package. An Information Package, consisting of the Content Information and the associated Preservation Description Information (PDI), which is preserved within an OAIS." },
603
- { term: "SIP", definition: "Submission Information Package. An Information Package that is delivered by the Producer to the OAIS for use in the construction or update of one or more Archival Information Packages." },
604
- { term: "DIP", definition: "Dissemination Information Package. An Information Package, derived from one or more Archival Information Packages, and sent by Archives to the Consumer in response to a request." },
605
- { term: "Checksum", definition: "A unique numerical signature derived from a file. Used to compare copies and verify file integrity." },
606
- { term: "Bit Preservation", definition: "A basic level of preservation of digital resources as submitted, including maintaining backups, virus checking, fixity-checking, and periodic refreshment to new storage media." },
607
- { term: "Emulation", definition: "A means of overcoming technological obsolescence by developing techniques for imitating obsolete systems on future generations of computers." },
608
- { term: "Migration", definition: "A means of overcoming technological obsolescence by transferring digital resources from one hardware/software generation to the next." },
609
- { term: "Born-Digital", definition: "Digital materials which are not intended to have an analogue equivalent, either as the originating source or as a result of conversion to analogue form." },
610
- { term: "Fixity Check", definition: "A method for ensuring the integrity of a file and verifying it has not been altered or corrupted, often using checksums like MD5 or SHA256." },
611
- { term: "Ingest", definition: "The process of turning a Submission Information Package (SIP) into an Archival Information Package (AIP), putting data into a digital archive." },
612
- { term: "PREMIS", definition: "Preservation Metadata: Implementation Strategies. A de facto standard for digital preservation metadata." },
613
- { term: "PRONOM", definition: "A database of file formats, software products and other technical components required to support long-term access to electronic records." },
614
  { term: "DROID", definition: "A file profiling tool developed by The National Archives to identify file formats based on PRONOM." },
615
- { term: "Dark Archive", definition: "An archive that cannot be accessed by current users but may be accessible at future dates subject to specific pre-defined trigger events." },
616
- { term: "TDR", definition: "Trusted Digital Repository. A repository with a mission to provide reliable, long-term access to managed digital resources." },
617
- { term: "WARC", definition: "Web ARChive format. A container format for archived websites, a revision of the Internet Archive's ARC format." },
618
  { term: "Metadata", definition: "Information which describes significant aspects of a resource, essential for managing and preserving digital materials over time." },
619
  { term: "PDF/A", definition: "Versions of the PDF standard intended for archival use, ensuring long-term preservation of electronic documents." },
620
- { term: "Authenticity", definition: "The digital material is what it purports to be, referring to the trustworthiness of the electronic record." },
621
  { term: "Designated Community", definition: "An identified group of potential consumers who should be able to understand a particular set of information from an archive." },
622
  { term: "Significant Properties", definition: "Characteristics of digital objects that must be preserved over time to ensure continued accessibility, usability and meaning." },
623
  { term: "Refreshing", definition: "Copying information content from one storage media to the same storage media to prevent degradation." },
624
- { term: "Reformatting", definition: "Copying information content from one storage medium to a different storage medium or converting from one file format to another." },
625
- { term: "Chain of Custody", definition: "A forensics concept whereby the custody and provenance of digital hardware, media and files are safeguarded through evidence custodians." },
626
- { term: "TIFF", definition: "Tagged Image File Format, a common format for images that is typically lossless." },
627
  { term: "Lossless Compression", definition: "A mechanism for reducing file sizes that retains all original data without any loss of quality." },
628
  { term: "Lossy Compression", definition: "A mechanism for reducing file sizes that typically discards some data, potentially reducing quality." },
629
- { term: "ASCII", definition: "American Standard Code for Information Interchange, a standard for encoding electronic text." },
630
- { term: "XML", definition: "Extensible Markup Language, a widely used standard for representing structured information." }
631
  ];
632
 
633
- // Game constants
634
  const GRID_SIZE = 20;
635
  const CANVAS_WIDTH = 600;
636
  const CANVAS_HEIGHT = 400;
637
  const COLS = CANVAS_WIDTH / GRID_SIZE;
638
  const ROWS = CANVAS_HEIGHT / GRID_SIZE;
639
- const GAME_TIME = 120; // seconds
640
- const QUIZ_TIME = 15; // seconds per quiz
 
 
 
 
 
 
 
 
 
 
 
 
 
 
641
 
642
  // Game state
643
  let canvas, ctx;
644
  let snake = [];
645
  let direction = { x: 1, y: 0 };
646
  let nextDirection = { x: 1, y: 0 };
647
- let items = [];
648
  let bitRots = [];
649
  let score = 0;
650
- let archived = 0;
651
  let timeLeft = GAME_TIME;
652
  let quizzesCorrect = 0;
653
  let quizzesTotal = 0;
@@ -655,22 +848,30 @@
655
  let timerLoop = null;
656
  let isRunning = false;
657
  let isPaused = false;
 
658
  let gameSpeed = 120;
 
 
 
 
 
 
 
 
 
659
 
660
  // Quiz state
661
  let quizActive = false;
662
- let quizTimer = null;
663
- let quizTimeLeft = QUIZ_TIME;
664
  let currentQuiz = null;
665
 
666
- // Item types
667
- const ITEM_TYPES = {
668
- FLOPPY: { emoji: '💾', points: 10, color: '#1a5fb4', chance: 0.4 },
669
- CD: { emoji: '💿', points: 20, color: '#9141ac', chance: 0.3 },
670
- TAPE: { emoji: '📼', points: 30, color: '#865e3c', chance: 0.15 },
671
- HDD: { emoji: '🗄️', points: 50, color: '#c0c0c0', chance: 0.1 },
672
- QUIZ: { emoji: '❓', points: 0, color: '#ffb000', chance: 0.05, isQuiz: true }
673
- };
674
 
675
  function init() {
676
  canvas = document.getElementById('gameCanvas');
@@ -678,6 +879,13 @@
678
 
679
  document.addEventListener('keydown', handleKeyPress);
680
 
 
 
 
 
 
 
 
681
  drawStartScreen();
682
  }
683
 
@@ -686,20 +894,47 @@
686
  ctx.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
687
 
688
  ctx.fillStyle = '#00ff41';
689
- ctx.font = '24px VT323';
690
  ctx.textAlign = 'center';
691
- ctx.fillText('🐍 ARCHIVE SNAKE 🐍', CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 - 40);
692
 
693
  ctx.font = '16px VT323';
694
  ctx.fillStyle = '#ffb000';
695
- ctx.fillText('Press START to begin your preservation mission', CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 + 10);
696
 
697
  ctx.font = '14px Space Mono';
698
  ctx.fillStyle = '#8b949e';
699
- ctx.fillText('Collect artifacts • Answer quizzes • Avoid bit rot', CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 + 50);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
700
  }
701
 
702
- function startGame() {
 
 
 
 
 
703
  // Reset state
704
  snake = [
705
  { x: 5, y: Math.floor(ROWS / 2) },
@@ -708,27 +943,41 @@
708
  ];
709
  direction = { x: 1, y: 0 };
710
  nextDirection = { x: 1, y: 0 };
711
- items = [];
712
  bitRots = [];
713
  score = 0;
714
- archived = 0;
715
  timeLeft = GAME_TIME;
716
  quizzesCorrect = 0;
717
  quizzesTotal = 0;
718
  isRunning = true;
719
  isPaused = false;
720
- gameSpeed = 120;
 
 
 
 
 
 
 
 
721
 
722
- // Spawn initial items
723
- for (let i = 0; i < 5; i++) spawnItem();
724
- for (let i = 0; i < 3; i++) spawnBitRot();
 
 
 
725
 
726
  // Update UI
727
  updateStats();
 
728
  document.getElementById('startBtn').disabled = true;
729
  document.getElementById('pauseBtn').disabled = false;
 
730
 
731
  // Start loops
 
 
732
  gameLoop = setInterval(update, gameSpeed);
733
  timerLoop = setInterval(updateTimer, 1000);
734
  }
@@ -760,7 +1009,7 @@
760
  }
761
 
762
  function update() {
763
- if (isPaused || quizActive) return;
764
 
765
  direction = { ...nextDirection };
766
 
@@ -778,22 +1027,19 @@
778
 
779
  // Self collision
780
  if (snake.some(seg => seg.x === head.x && seg.y === head.y)) {
781
- gameOver();
782
  return;
783
  }
784
 
785
  snake.unshift(head);
786
 
787
- // Check item collision
788
  let ate = false;
789
- items = items.filter(item => {
790
- if (item.x === head.x && item.y === head.y) {
791
- if (item.type.isQuiz) {
792
- triggerQuiz();
793
- } else {
794
- score += item.type.points;
795
- archived++;
796
- }
797
  ate = true;
798
  return false;
799
  }
@@ -803,148 +1049,75 @@
803
  if (!ate) {
804
  snake.pop();
805
  } else {
806
- spawnItem();
807
  }
808
 
809
  // Check bit rot collision
810
- bitRots.forEach(rot => {
 
811
  if (rot.x === head.x && rot.y === head.y) {
812
- timeLeft = Math.max(0, timeLeft - 5);
813
- // Move bit rot
814
- rot.x = Math.floor(Math.random() * COLS);
815
- rot.y = Math.floor(Math.random() * ROWS);
 
 
816
  }
817
- });
818
 
819
  updateStats();
 
820
  draw();
821
  }
822
 
823
- function draw() {
824
- // Clear
825
- ctx.fillStyle = '#000';
826
- ctx.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
827
-
828
- // Draw grid (subtle)
829
- ctx.strokeStyle = 'rgba(0, 255, 65, 0.05)';
830
- for (let x = 0; x <= COLS; x++) {
831
- ctx.beginPath();
832
- ctx.moveTo(x * GRID_SIZE, 0);
833
- ctx.lineTo(x * GRID_SIZE, CANVAS_HEIGHT);
834
- ctx.stroke();
835
- }
836
- for (let y = 0; y <= ROWS; y++) {
837
- ctx.beginPath();
838
- ctx.moveTo(0, y * GRID_SIZE);
839
- ctx.lineTo(CANVAS_WIDTH, y * GRID_SIZE);
840
- ctx.stroke();
841
  }
 
842
 
843
- // Draw bit rot zones
844
- bitRots.forEach(rot => {
845
- ctx.fillStyle = 'rgba(255, 68, 68, 0.3)';
846
- ctx.fillRect(rot.x * GRID_SIZE, rot.y * GRID_SIZE, GRID_SIZE, GRID_SIZE);
847
- ctx.font = '16px Arial';
848
- ctx.textAlign = 'center';
849
- ctx.textBaseline = 'middle';
850
- ctx.fillText('☠️', rot.x * GRID_SIZE + GRID_SIZE/2, rot.y * GRID_SIZE + GRID_SIZE/2);
851
- });
852
-
853
- // Draw items
854
- items.forEach(item => {
855
- ctx.fillStyle = item.type.color + '40';
856
- ctx.fillRect(item.x * GRID_SIZE, item.y * GRID_SIZE, GRID_SIZE, GRID_SIZE);
857
- ctx.font = '16px Arial';
858
- ctx.textAlign = 'center';
859
- ctx.textBaseline = 'middle';
860
- ctx.fillText(item.type.emoji, item.x * GRID_SIZE + GRID_SIZE/2, item.y * GRID_SIZE + GRID_SIZE/2);
861
- });
862
 
863
- // Draw snake
864
- snake.forEach((seg, i) => {
865
- const isHead = i === 0;
866
- const alpha = 1 - (i / snake.length) * 0.5;
867
-
868
- if (isHead) {
869
- ctx.fillStyle = '#00ff41';
870
- ctx.shadowColor = '#00ff41';
871
- ctx.shadowBlur = 10;
872
- } else {
873
- ctx.fillStyle = `rgba(0, 255, 65, ${alpha})`;
874
- ctx.shadowBlur = 0;
875
- }
876
 
877
- ctx.fillRect(
878
- seg.x * GRID_SIZE + 1,
879
- seg.y * GRID_SIZE + 1,
880
- GRID_SIZE - 2,
881
- GRID_SIZE - 2
882
- );
883
 
884
- if (isHead) {
885
- ctx.shadowBlur = 0;
886
- // Draw eyes
887
- ctx.fillStyle = '#000';
888
- const eyeOffset = 4;
889
- if (direction.x === 1) {
890
- ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 5, 3, 3);
891
- ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 12, 3, 3);
892
- } else if (direction.x === -1) {
893
- ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 5, 3, 3);
894
- ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 12, 3, 3);
895
- } else if (direction.y === -1) {
896
- ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 5, 3, 3);
897
- ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 5, 3, 3);
898
- } else {
899
- ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 12, 3, 3);
900
- ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 12, 3, 3);
901
- }
902
  }
903
  });
904
  }
905
 
906
- function spawnItem() {
907
- let x, y;
908
- do {
909
- x = Math.floor(Math.random() * COLS);
910
- y = Math.floor(Math.random() * ROWS);
911
- } while (
912
- snake.some(seg => seg.x === x && seg.y === y) ||
913
- items.some(item => item.x === x && item.y === y) ||
914
- bitRots.some(rot => rot.x === x && rot.y === y)
915
- );
916
-
917
- // Select item type based on chance
918
- const rand = Math.random();
919
- let cumulative = 0;
920
- let selectedType = ITEM_TYPES.FLOPPY;
921
-
922
- for (const [key, type] of Object.entries(ITEM_TYPES)) {
923
- cumulative += type.chance;
924
- if (rand <= cumulative) {
925
- selectedType = type;
926
- break;
927
- }
928
- }
929
-
930
- items.push({ x, y, type: selectedType });
931
- }
932
-
933
- function spawnBitRot() {
934
- let x, y;
935
- do {
936
- x = Math.floor(Math.random() * COLS);
937
- y = Math.floor(Math.random() * ROWS);
938
- } while (
939
- snake.some(seg => seg.x === x && seg.y === y) ||
940
- items.some(item => item.x === x && item.y === y)
941
- );
942
- bitRots.push({ x, y });
943
- }
944
-
945
  function triggerQuiz() {
946
  quizActive = true;
947
- quizTimeLeft = QUIZ_TIME;
948
 
949
  // Select random question
950
  const correctIndex = Math.floor(Math.random() * glossaryData.length);
@@ -964,36 +1137,32 @@
964
  currentQuiz = { correct, answers };
965
 
966
  // Update modal
 
967
  document.getElementById('quizTerm').textContent = correct.term;
 
 
 
 
968
  const optionsEl = document.getElementById('answerOptions');
969
  optionsEl.innerHTML = '';
970
 
971
  answers.forEach((answer, i) => {
972
  const btn = document.createElement('button');
973
  btn.className = 'answer-btn';
974
- btn.textContent = answer.definition.substring(0, 150) + (answer.definition.length > 150 ? '...' : '');
975
  btn.onclick = () => submitAnswer(answer === correct, btn);
976
  optionsEl.appendChild(btn);
977
  });
978
 
979
  // Show modal
980
  document.getElementById('quizModal').classList.add('show');
981
-
982
- // Start quiz timer
983
- quizTimer = setInterval(() => {
984
- quizTimeLeft--;
985
- document.getElementById('quizTimer').textContent = quizTimeLeft;
986
- if (quizTimeLeft <= 0) {
987
- submitAnswer(false, null);
988
- }
989
- }, 1000);
990
  }
991
 
992
  function submitAnswer(correct, btnEl) {
993
- clearInterval(quizTimer);
994
  quizzesTotal++;
995
 
996
- // Disable all buttons
997
  document.querySelectorAll('.answer-btn').forEach(btn => {
998
  btn.onclick = null;
999
  if (btn.textContent.includes(currentQuiz.correct.definition.substring(0, 50))) {
@@ -1001,45 +1170,54 @@
1001
  }
1002
  });
1003
 
 
 
1004
  if (correct) {
1005
  quizzesCorrect++;
1006
- timeLeft += 15;
 
1007
  if (btnEl) btnEl.classList.add('correct');
 
 
1008
  } else {
 
1009
  if (btnEl) btnEl.classList.add('wrong');
 
 
1010
  }
1011
 
 
 
1012
  // Close modal after delay
1013
  setTimeout(() => {
1014
  document.getElementById('quizModal').classList.remove('show');
 
 
1015
  quizActive = false;
1016
- updateStats();
 
 
 
1017
  }, 1500);
1018
  }
1019
 
1020
  function updateTimer() {
1021
- if (isPaused || quizActive) return;
1022
 
1023
  timeLeft--;
1024
  updateStats();
1025
 
1026
  if (timeLeft <= 0) {
1027
- gameOver();
1028
- }
1029
-
1030
- // Spawn new bit rot occasionally
1031
- if (timeLeft % 20 === 0 && bitRots.length < 8) {
1032
- spawnBitRot();
1033
  }
1034
  }
1035
 
1036
  function updateStats() {
1037
  document.getElementById('score').textContent = score;
1038
- document.getElementById('archived').textContent = archived;
1039
  document.getElementById('quizzes').textContent = `${quizzesCorrect}/${quizzesTotal}`;
1040
 
1041
- const mins = Math.floor(timeLeft / 60);
1042
- const secs = timeLeft % 60;
1043
  const timerEl = document.getElementById('timer');
1044
  timerEl.textContent = `${mins}:${secs.toString().padStart(2, '0')}`;
1045
 
@@ -1050,32 +1228,114 @@
1050
  }
1051
  }
1052
 
1053
- function gameOver() {
 
1054
  isRunning = false;
1055
  clearInterval(gameLoop);
1056
  clearInterval(timerLoop);
1057
 
1058
  document.getElementById('startBtn').disabled = false;
1059
  document.getElementById('pauseBtn').disabled = true;
 
1060
 
1061
  // Show game over modal
1062
  const accuracy = quizzesTotal > 0 ? Math.round((quizzesCorrect / quizzesTotal) * 100) : 0;
1063
  document.getElementById('gameOverTitle').textContent = timeLeft > 0 ? '💀 Archive Corrupted!' : '⏰ Time Expired!';
1064
  document.getElementById('finalScore').textContent = score;
1065
- document.getElementById('finalArchived').textContent = archived;
 
 
1066
  document.getElementById('finalQuizzes').textContent = `${accuracy}%`;
1067
- document.getElementById('finalLength').textContent = snake.length;
1068
 
1069
  document.getElementById('gameOverModal').classList.add('show');
1070
  }
1071
 
1072
  function restartGame() {
1073
  document.getElementById('gameOverModal').classList.remove('show');
1074
- startGame();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1075
  }
1076
 
1077
  function handleKeyPress(e) {
1078
- if (!isRunning || isPaused) return;
1079
 
1080
  const key = e.key.toLowerCase();
1081
 
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Digital Archive Snake</title>
7
  <link href="https://fonts.googleapis.com/css2?family=VT323&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
8
  <style>
9
  * {
 
18
  --crt-amber: #ffb000;
19
  --floppy-blue: #1a5fb4;
20
  --cd-purple: #9141ac;
21
+ --vhs-red: #c01c28;
 
22
  --bit-rot: #ff4444;
23
  --bg-dark: #0a0a0f;
24
  --bg-terminal: #0d1117;
 
58
  }
59
 
60
  .container {
61
+ max-width: 950px;
62
  width: 100%;
63
  }
64
 
 
69
 
70
  h1 {
71
  font-family: 'VT323', monospace;
72
+ font-size: 3.2rem;
73
  color: var(--crt-green);
74
  text-shadow:
75
  0 0 10px var(--crt-green),
 
94
 
95
  .game-wrapper {
96
  display: grid;
97
+ grid-template-columns: 1fr 240px;
98
  gap: 20px;
99
  margin-bottom: 20px;
100
  }
 
173
  50% { opacity: 0.5; }
174
  }
175
 
176
+ /* Artifact collection progress */
177
+ .artifact-progress {
178
+ margin-bottom: 12px;
179
+ }
180
+
181
+ .artifact-row {
182
  display: flex;
183
  align-items: center;
184
  gap: 10px;
185
  margin-bottom: 10px;
186
+ }
187
+
188
+ .artifact-icon {
189
+ font-size: 20px;
190
+ width: 28px;
191
+ text-align: center;
192
+ }
193
+
194
+ .artifact-info {
195
+ flex: 1;
196
+ }
197
+
198
+ .artifact-name {
199
+ font-size: 0.7rem;
200
+ color: #8b949e;
201
+ margin-bottom: 4px;
202
+ }
203
+
204
+ .progress-bar {
205
+ height: 8px;
206
+ background: #1a1a2e;
207
+ border-radius: 4px;
208
+ overflow: hidden;
209
+ position: relative;
210
+ }
211
+
212
+ .progress-fill {
213
+ height: 100%;
214
+ border-radius: 4px;
215
+ transition: width 0.3s ease;
216
+ }
217
+
218
+ .progress-fill.floppy { background: linear-gradient(90deg, var(--floppy-blue), #3584e4); }
219
+ .progress-fill.cdrom { background: linear-gradient(90deg, var(--cd-purple), #c061cb); }
220
+ .progress-fill.vhs { background: linear-gradient(90deg, var(--vhs-red), #e66100); }
221
+
222
+ .artifact-count {
223
+ font-family: 'VT323', monospace;
224
+ font-size: 1rem;
225
+ color: var(--crt-green);
226
+ min-width: 40px;
227
+ text-align: right;
228
+ }
229
+
230
+ .bonus-indicator {
231
+ font-size: 0.65rem;
232
+ color: var(--crt-amber);
233
+ text-align: right;
234
+ margin-top: 2px;
235
+ }
236
+
237
+ .bonus-indicator.achieved {
238
+ color: var(--crt-green);
239
+ text-shadow: 0 0 5px var(--crt-green);
240
+ }
241
+
242
+ /* Legend items without boxes */
243
+ .legend-item {
244
+ display: flex;
245
+ align-items: center;
246
+ gap: 10px;
247
+ margin-bottom: 8px;
248
  font-size: 0.75rem;
249
  }
250
 
251
  .legend-icon {
252
+ font-size: 20px;
253
+ width: 28px;
254
+ text-align: center;
255
+ }
256
+
257
+ /* Difficulty slider */
258
+ .difficulty-control {
259
+ margin-bottom: 15px;
260
+ }
261
+
262
+ .difficulty-label {
263
  display: flex;
264
+ justify-content: space-between;
265
  align-items: center;
266
+ margin-bottom: 8px;
 
267
  }
268
 
269
+ .difficulty-label span {
270
+ font-size: 0.8rem;
271
+ color: #8b949e;
272
+ }
273
+
274
+ .difficulty-value {
275
+ font-family: 'VT323', monospace;
276
+ font-size: 1rem;
277
+ color: var(--crt-amber);
278
+ text-transform: uppercase;
279
+ }
280
+
281
+ .slider-container {
282
+ position: relative;
283
+ }
284
+
285
+ input[type="range"] {
286
+ -webkit-appearance: none;
287
+ width: 100%;
288
+ height: 8px;
289
+ background: linear-gradient(90deg, var(--crt-green) 0%, var(--crt-amber) 50%, var(--bit-rot) 100%);
290
+ border-radius: 4px;
291
+ outline: none;
292
+ }
293
+
294
+ input[type="range"]::-webkit-slider-thumb {
295
+ -webkit-appearance: none;
296
+ width: 20px;
297
+ height: 20px;
298
+ background: var(--bg-dark);
299
+ border: 3px solid var(--crt-green);
300
+ border-radius: 50%;
301
+ cursor: pointer;
302
+ box-shadow: 0 0 10px var(--crt-green);
303
+ }
304
+
305
+ input[type="range"]::-moz-range-thumb {
306
+ width: 20px;
307
+ height: 20px;
308
+ background: var(--bg-dark);
309
+ border: 3px solid var(--crt-green);
310
+ border-radius: 50%;
311
+ cursor: pointer;
312
+ }
313
+
314
+ .slider-labels {
315
+ display: flex;
316
+ justify-content: space-between;
317
+ margin-top: 5px;
318
+ font-size: 0.65rem;
319
+ color: #666;
320
+ }
321
 
322
  .controls {
323
  display: flex;
 
418
 
419
  .modal {
420
  background: var(--panel-bg);
421
+ border: 3px solid var(--bit-rot);
422
  border-radius: 12px;
423
  padding: 30px;
424
  max-width: 500px;
425
  width: 90%;
426
  box-shadow:
427
+ 0 0 40px rgba(255, 68, 68, 0.3),
428
+ 0 0 80px rgba(255, 68, 68, 0.1);
429
  animation: modalIn 0.3s ease-out;
430
  }
431
 
432
+ .modal.success {
433
+ border-color: var(--crt-green);
434
+ box-shadow:
435
+ 0 0 40px rgba(0, 255, 65, 0.3),
436
+ 0 0 80px rgba(0, 255, 65, 0.1);
437
+ }
438
+
439
  @keyframes modalIn {
440
  from {
441
  opacity: 0;
 
449
 
450
  .modal h2 {
451
  font-family: 'VT323', monospace;
452
+ color: var(--bit-rot);
453
+ font-size: 1.8rem;
454
+ margin-bottom: 15px;
455
  text-align: center;
456
  }
457
 
458
+ .modal.success h2 {
459
  color: var(--crt-green);
460
+ }
461
+
462
+ .modal .question {
463
+ color: #aaa;
464
+ font-size: 0.9rem;
465
+ margin-bottom: 15px;
466
+ text-align: center;
467
  }
468
 
469
  .modal .term-display {
470
  background: var(--bg-terminal);
471
+ border: 2px solid var(--crt-amber);
472
  padding: 15px;
473
  border-radius: 8px;
474
  margin-bottom: 20px;
 
478
  .modal .term-display span {
479
  font-family: 'VT323', monospace;
480
  font-size: 1.8rem;
481
+ color: var(--crt-amber);
482
+ text-shadow: 0 0 10px var(--crt-amber);
483
  }
484
 
485
  .answer-options {
 
491
  .answer-btn {
492
  text-align: left;
493
  font-family: 'Space Mono', monospace;
494
+ font-size: 0.8rem;
495
+ padding: 12px 15px;
496
  border: 2px solid var(--border-glow);
497
  background: var(--bg-terminal);
498
  color: #c9d1d9;
 
519
  color: var(--bit-rot);
520
  }
521
 
522
+ .quiz-stakes {
523
  text-align: center;
524
  margin-top: 15px;
525
  font-family: 'VT323', monospace;
526
+ font-size: 1.1rem;
527
+ }
528
+
529
+ .quiz-stakes .gain {
530
+ color: var(--crt-green);
531
+ }
532
+
533
+ .quiz-stakes .lose {
534
+ color: var(--bit-rot);
535
  }
536
 
537
  /* Game Over Modal */
 
583
  }
584
 
585
  h1 {
586
+ font-size: 2.2rem;
587
  }
588
 
589
  .side-panel {
 
593
 
594
  .panel {
595
  flex: 1;
596
+ min-width: 200px;
597
  }
598
  }
599
  </style>
 
601
  <body>
602
  <div class="container">
603
  <header>
604
+ <h1>🐍 DIGITAL ARCHIVE SNAKE</h1>
605
  <p class="subtitle">Preserve Digital Heritage Before It's Lost</p>
606
  </header>
607
 
 
621
  <span class="stat-label">Time Left</span>
622
  <span class="stat-value time" id="timer">2:00</span>
623
  </div>
 
 
 
 
624
  <div class="stat-row">
625
  <span class="stat-label">Quizzes</span>
626
  <span class="stat-value" id="quizzes">0/0</span>
 
628
  </div>
629
 
630
  <div class="panel">
631
+ <div class="panel-title">📁 Collection Progress</div>
632
+ <div class="artifact-progress">
633
+ <div class="artifact-row">
634
+ <span class="artifact-icon">💾</span>
635
+ <div class="artifact-info">
636
+ <div class="artifact-name">Floppy Disc</div>
637
+ <div class="progress-bar">
638
+ <div class="progress-fill floppy" id="floppyProgress" style="width: 0%"></div>
639
+ </div>
640
+ <div class="bonus-indicator" id="floppyBonus">5 for +10s bonus</div>
641
+ </div>
642
+ <span class="artifact-count" id="floppyCount">0</span>
643
+ </div>
644
+ <div class="artifact-row">
645
+ <span class="artifact-icon">💿</span>
646
+ <div class="artifact-info">
647
+ <div class="artifact-name">CD-ROM</div>
648
+ <div class="progress-bar">
649
+ <div class="progress-fill cdrom" id="cdromProgress" style="width: 0%"></div>
650
+ </div>
651
+ <div class="bonus-indicator" id="cdromBonus">5 for +15s bonus</div>
652
+ </div>
653
+ <span class="artifact-count" id="cdromCount">0</span>
654
+ </div>
655
+ <div class="artifact-row">
656
+ <span class="artifact-icon">📼</span>
657
+ <div class="artifact-info">
658
+ <div class="artifact-name">VHS Tape</div>
659
+ <div class="progress-bar">
660
+ <div class="progress-fill vhs" id="vhsProgress" style="width: 0%"></div>
661
+ </div>
662
+ <div class="bonus-indicator" id="vhsBonus">5 for +20s bonus</div>
663
+ </div>
664
+ <span class="artifact-count" id="vhsCount">0</span>
665
+ </div>
666
  </div>
667
+ </div>
668
+
669
+ <div class="panel">
670
+ <div class="panel-title">⚙️ Difficulty</div>
671
+ <div class="difficulty-control">
672
+ <div class="difficulty-label">
673
+ <span>Challenge Level</span>
674
+ <span class="difficulty-value" id="difficultyValue">Normal</span>
675
+ </div>
676
+ <div class="slider-container">
677
+ <input type="range" id="difficultySlider" min="1" max="3" value="2" step="1">
678
+ <div class="slider-labels">
679
+ <span>Easy</span>
680
+ <span>Normal</span>
681
+ <span>Hard</span>
682
+ </div>
683
+ </div>
684
  </div>
685
  <div class="legend-item">
686
+ <span class="legend-icon">☠️</span>
687
+ <span>Bit Rot = Quiz Time!</span>
688
  </div>
689
  </div>
690
  </div>
691
  </div>
692
 
693
  <div class="controls">
694
+ <button id="startBtn" onclick="startNewGame()">▶ Start Mission</button>
695
  <button class="secondary" onclick="pauseGame()" id="pauseBtn" disabled>⏸ Pause</button>
696
  </div>
697
 
698
  <div class="instructions">
699
  <h2>📋 Mission Briefing</h2>
700
+ <p>Your mission: <strong>collect and preserve endangered digital artifacts before time runs out!</strong></p>
701
  <p>
702
  <span class="key-hint">↑</span>
703
  <span class="key-hint">↓</span>
 
710
  <span class="key-hint">D</span>
711
  to navigate
712
  </p>
713
+ <p>Collect <strong>💾 Floppy Discs</strong>, <strong>💿 CD-ROMs</strong>, and <strong>📼 VHS Tapes</strong> for points.
714
+ Collect 5 of any type to earn a time bonus!</p>
715
+ <p>Watch out for <strong>☠️ Bit Rot</strong> — hitting it triggers a quiz! Answer correctly to <span style="color: var(--crt-green);">gain time</span>,
716
+ answer wrong and you'll <span style="color: var(--bit-rot);">lose time</span>.</p>
717
  </div>
718
 
719
  <div class="attribution">
720
+ <strong>Source:</strong> Digital Preservation Handbook, 2nd Edition,
721
  <a href="https://www.dpconline.org/handbook" target="_blank">dpconline.org/handbook</a><br>
722
  Digital Preservation Coalition © 2015 —
723
  <a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" target="_blank">OGL v3.0</a>
 
726
 
727
  <!-- Quiz Modal -->
728
  <div class="modal-overlay" id="quizModal">
729
+ <div class="modal" id="quizModalInner">
730
+ <h2>☠️ Bit Rot Detected!</h2>
731
+ <p class="question">Quick! Match this preservation term to survive:</p>
732
  <div class="term-display">
733
  <span id="quizTerm">OAIS</span>
734
  </div>
735
  <div class="answer-options" id="answerOptions">
736
  <!-- Answers populated by JS -->
737
  </div>
738
+ <div class="quiz-stakes">
739
+ <span class="gain">✓ Correct: +10s</span> &nbsp;|&nbsp; <span class="lose">✗ Wrong: -10s</span>
740
+ </div>
741
  </div>
742
  </div>
743
 
 
751
  <span class="value" id="finalScore">0</span>
752
  </div>
753
  <div class="final-stat">
754
+ <span class="label">💾 Floppies Saved</span>
755
+ <span class="value" id="finalFloppies">0</span>
756
+ </div>
757
+ <div class="final-stat">
758
+ <span class="label">💿 CD-ROMs Saved</span>
759
+ <span class="value" id="finalCDs">0</span>
760
+ </div>
761
+ <div class="final-stat">
762
+ <span class="label">📼 VHS Tapes Saved</span>
763
+ <span class="value" id="finalVHS">0</span>
764
  </div>
765
  <div class="final-stat">
766
  <span class="label">Quiz Accuracy</span>
767
  <span class="value" id="finalQuizzes">0%</span>
768
  </div>
769
  <div class="final-stat">
770
+ <span class="label">Collection Bonuses</span>
771
+ <span class="value" id="finalBonuses">0</span>
772
  </div>
773
  </div>
774
  <button onclick="restartGame()" style="width: 100%;">🔄 New Mission</button>
 
776
  </div>
777
 
778
  <script>
779
+ // Complete glossary data from DPC Handbook
780
  const glossaryData = [
781
+ { term: "OAIS", definition: "Open Archival Information System - a reference model for digital archives that has accepted the responsibility to preserve information." },
782
+ { term: "AIP", definition: "Archival Information Package - the package preserved within an OAIS, consisting of Content Information and Preservation Description Information." },
783
+ { term: "SIP", definition: "Submission Information Package - delivered by the Producer to the OAIS for constructing Archival Information Packages." },
784
+ { term: "DIP", definition: "Dissemination Information Package - derived from AIPs and sent to users in response to a request." },
785
+ { term: "Checksum", definition: "A unique numerical signature derived from a file, used to compare copies and verify integrity." },
786
+ { term: "Bit Preservation", definition: "A basic level of preservation including backups, virus checking, fixity-checking, and periodic refreshment to new storage media." },
787
+ { term: "Born-Digital", definition: "Digital materials which are not intended to have an analogue equivalent, either as the originating source or as a result of conversion." },
788
+ { term: "Emulation", definition: "A means of overcoming technological obsolescence by developing techniques for imitating obsolete systems on future computers." },
789
+ { term: "Migration", definition: "Transferring digital resources from one hardware/software generation to the next to preserve intellectual content." },
790
+ { term: "Fixity Check", definition: "A method for ensuring the integrity of a file and verifying it has not been altered or corrupted." },
791
+ { term: "Ingest", definition: "The process of turning a Submission Information Package into an Archival Information Package in a digital archive." },
792
+ { term: "PREMIS", definition: "Preservation Metadata: Implementation Strategies - a de facto standard for digital preservation metadata." },
793
+ { term: "PRONOM", definition: "A database of file formats, software products and technical components required to support long-term access to electronic records." },
794
  { term: "DROID", definition: "A file profiling tool developed by The National Archives to identify file formats based on PRONOM." },
795
+ { term: "Dark Archive", definition: "An archive that cannot be accessed by current users but may be accessible at future dates subject to specific trigger events." },
796
+ { term: "TDR", definition: "Trusted Digital Repository - a repository with a mission to provide reliable, long-term access to managed digital resources." },
797
+ { term: "WARC", definition: "Web ARChive format - a container format for archived websites, a revision of the Internet Archive's ARC format." },
798
  { term: "Metadata", definition: "Information which describes significant aspects of a resource, essential for managing and preserving digital materials over time." },
799
  { term: "PDF/A", definition: "Versions of the PDF standard intended for archival use, ensuring long-term preservation of electronic documents." },
800
+ { term: "Authenticity", definition: "The digital material is what it purports to be - referring to the trustworthiness of the electronic record." },
801
  { term: "Designated Community", definition: "An identified group of potential consumers who should be able to understand a particular set of information from an archive." },
802
  { term: "Significant Properties", definition: "Characteristics of digital objects that must be preserved over time to ensure continued accessibility, usability and meaning." },
803
  { term: "Refreshing", definition: "Copying information content from one storage media to the same storage media to prevent degradation." },
804
+ { term: "Reformatting", definition: "Copying information content from one storage medium to a different medium or converting between file formats." },
805
+ { term: "Chain of Custody", definition: "A forensics concept whereby the custody and provenance of digital hardware, media and files are safeguarded." },
806
+ { term: "TIFF", definition: "Tagged Image File Format - a common format for images that is typically lossless." },
807
  { term: "Lossless Compression", definition: "A mechanism for reducing file sizes that retains all original data without any loss of quality." },
808
  { term: "Lossy Compression", definition: "A mechanism for reducing file sizes that typically discards some data, potentially reducing quality." },
809
+ { term: "ASCII", definition: "American Standard Code for Information Interchange - a standard for encoding electronic text." },
810
+ { term: "XML", definition: "Extensible Markup Language - a widely used standard for representing structured information." }
811
  ];
812
 
813
+ // Game configuration
814
  const GRID_SIZE = 20;
815
  const CANVAS_WIDTH = 600;
816
  const CANVAS_HEIGHT = 400;
817
  const COLS = CANVAS_WIDTH / GRID_SIZE;
818
  const ROWS = CANVAS_HEIGHT / GRID_SIZE;
819
+ const GAME_TIME = 120; // 2 minutes
820
+ const COLLECTION_GOAL = 5; // Artifacts needed for bonus
821
+
822
+ // Difficulty settings
823
+ const DIFFICULTY = {
824
+ 1: { name: 'Easy', bitRots: 2, quizGain: 15, quizLoss: 5 },
825
+ 2: { name: 'Normal', bitRots: 4, quizGain: 10, quizLoss: 10 },
826
+ 3: { name: 'Hard', bitRots: 7, quizGain: 8, quizLoss: 15 }
827
+ };
828
+
829
+ // Artifact types (only 3 now)
830
+ const ARTIFACT_TYPES = {
831
+ FLOPPY: { emoji: '💾', points: 10, key: 'floppy', bonusTime: 10 },
832
+ CDROM: { emoji: '💿', points: 20, key: 'cdrom', bonusTime: 15 },
833
+ VHS: { emoji: '📼', points: 30, key: 'vhs', bonusTime: 20 }
834
+ };
835
 
836
  // Game state
837
  let canvas, ctx;
838
  let snake = [];
839
  let direction = { x: 1, y: 0 };
840
  let nextDirection = { x: 1, y: 0 };
841
+ let artifacts = [];
842
  let bitRots = [];
843
  let score = 0;
 
844
  let timeLeft = GAME_TIME;
845
  let quizzesCorrect = 0;
846
  let quizzesTotal = 0;
 
848
  let timerLoop = null;
849
  let isRunning = false;
850
  let isPaused = false;
851
+ let gameOver = false;
852
  let gameSpeed = 120;
853
+ let currentDifficulty = 2;
854
+
855
+ // Collection tracking
856
+ let collections = {
857
+ floppy: { count: 0, bonusAwarded: 0 },
858
+ cdrom: { count: 0, bonusAwarded: 0 },
859
+ vhs: { count: 0, bonusAwarded: 0 }
860
+ };
861
+ let totalBonuses = 0;
862
 
863
  // Quiz state
864
  let quizActive = false;
 
 
865
  let currentQuiz = null;
866
 
867
+ function shuffle(array) {
868
+ const newArray = [...array];
869
+ for (let i = newArray.length - 1; i > 0; i--) {
870
+ const j = Math.floor(Math.random() * (i + 1));
871
+ [newArray[i], newArray[j]] = [newArray[j], newArray[i]];
872
+ }
873
+ return newArray;
874
+ }
875
 
876
  function init() {
877
  canvas = document.getElementById('gameCanvas');
 
879
 
880
  document.addEventListener('keydown', handleKeyPress);
881
 
882
+ // Difficulty slider
883
+ const slider = document.getElementById('difficultySlider');
884
+ slider.addEventListener('input', (e) => {
885
+ currentDifficulty = parseInt(e.target.value);
886
+ document.getElementById('difficultyValue').textContent = DIFFICULTY[currentDifficulty].name;
887
+ });
888
+
889
  drawStartScreen();
890
  }
891
 
 
894
  ctx.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
895
 
896
  ctx.fillStyle = '#00ff41';
897
+ ctx.font = '28px VT323';
898
  ctx.textAlign = 'center';
899
+ ctx.fillText('🐍 DIGITAL ARCHIVE SNAKE 🐍', CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 - 40);
900
 
901
  ctx.font = '16px VT323';
902
  ctx.fillStyle = '#ffb000';
903
+ ctx.fillText('Press START to begin your mission', CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 + 10);
904
 
905
  ctx.font = '14px Space Mono';
906
  ctx.fillStyle = '#8b949e';
907
+ ctx.fillText('Collect artifacts • Answer quizzes • Beat the clock', CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 + 50);
908
+ }
909
+
910
+ function getRandomPosition() {
911
+ let x, y, attempts = 0;
912
+ do {
913
+ x = Math.floor(Math.random() * COLS);
914
+ y = Math.floor(Math.random() * ROWS);
915
+ attempts++;
916
+ } while (
917
+ attempts < 100 &&
918
+ (snake.some(seg => seg.x === x && seg.y === y) ||
919
+ artifacts.some(a => a.x === x && a.y === y) ||
920
+ bitRots.some(b => b.x === x && b.y === y))
921
+ );
922
+ return { x, y };
923
+ }
924
+
925
+ function spawnArtifact() {
926
+ const pos = getRandomPosition();
927
+ const types = Object.values(ARTIFACT_TYPES);
928
+ const type = types[Math.floor(Math.random() * types.length)];
929
+ artifacts.push({ ...pos, type });
930
  }
931
 
932
+ function spawnBitRot() {
933
+ const pos = getRandomPosition();
934
+ bitRots.push(pos);
935
+ }
936
+
937
+ function startNewGame() {
938
  // Reset state
939
  snake = [
940
  { x: 5, y: Math.floor(ROWS / 2) },
 
943
  ];
944
  direction = { x: 1, y: 0 };
945
  nextDirection = { x: 1, y: 0 };
946
+ artifacts = [];
947
  bitRots = [];
948
  score = 0;
 
949
  timeLeft = GAME_TIME;
950
  quizzesCorrect = 0;
951
  quizzesTotal = 0;
952
  isRunning = true;
953
  isPaused = false;
954
+ gameOver = false;
955
+ totalBonuses = 0;
956
+
957
+ // Reset collections
958
+ collections = {
959
+ floppy: { count: 0, bonusAwarded: 0 },
960
+ cdrom: { count: 0, bonusAwarded: 0 },
961
+ vhs: { count: 0, bonusAwarded: 0 }
962
+ };
963
 
964
+ // Spawn initial artifacts
965
+ for (let i = 0; i < 5; i++) spawnArtifact();
966
+
967
+ // Spawn bit rots based on difficulty
968
+ const numBitRots = DIFFICULTY[currentDifficulty].bitRots;
969
+ for (let i = 0; i < numBitRots; i++) spawnBitRot();
970
 
971
  // Update UI
972
  updateStats();
973
+ updateCollectionUI();
974
  document.getElementById('startBtn').disabled = true;
975
  document.getElementById('pauseBtn').disabled = false;
976
+ document.getElementById('difficultySlider').disabled = true;
977
 
978
  // Start loops
979
+ if (gameLoop) clearInterval(gameLoop);
980
+ if (timerLoop) clearInterval(timerLoop);
981
  gameLoop = setInterval(update, gameSpeed);
982
  timerLoop = setInterval(updateTimer, 1000);
983
  }
 
1009
  }
1010
 
1011
  function update() {
1012
+ if (isPaused || quizActive || gameOver) return;
1013
 
1014
  direction = { ...nextDirection };
1015
 
 
1027
 
1028
  // Self collision
1029
  if (snake.some(seg => seg.x === head.x && seg.y === head.y)) {
1030
+ endGame();
1031
  return;
1032
  }
1033
 
1034
  snake.unshift(head);
1035
 
1036
+ // Check artifact collision
1037
  let ate = false;
1038
+ artifacts = artifacts.filter(artifact => {
1039
+ if (artifact.x === head.x && artifact.y === head.y) {
1040
+ score += artifact.type.points;
1041
+ collections[artifact.type.key].count++;
1042
+ checkCollectionBonus(artifact.type.key);
 
 
 
1043
  ate = true;
1044
  return false;
1045
  }
 
1049
  if (!ate) {
1050
  snake.pop();
1051
  } else {
1052
+ spawnArtifact();
1053
  }
1054
 
1055
  // Check bit rot collision
1056
+ for (let i = 0; i < bitRots.length; i++) {
1057
+ const rot = bitRots[i];
1058
  if (rot.x === head.x && rot.y === head.y) {
1059
+ // Move bit rot to new position
1060
+ const newPos = getRandomPosition();
1061
+ bitRots[i] = newPos;
1062
+ // Trigger quiz
1063
+ triggerQuiz();
1064
+ break;
1065
  }
1066
+ }
1067
 
1068
  updateStats();
1069
+ updateCollectionUI();
1070
  draw();
1071
  }
1072
 
1073
+ function checkCollectionBonus(key) {
1074
+ const collection = collections[key];
1075
+ const bonusLevel = Math.floor(collection.count / COLLECTION_GOAL);
1076
+
1077
+ if (bonusLevel > collection.bonusAwarded) {
1078
+ const type = Object.values(ARTIFACT_TYPES).find(t => t.key === key);
1079
+ timeLeft += type.bonusTime;
1080
+ score += 50;
1081
+ collection.bonusAwarded = bonusLevel;
1082
+ totalBonuses++;
1083
+
1084
+ // Visual feedback
1085
+ showBonusNotification(type);
 
 
 
 
 
1086
  }
1087
+ }
1088
 
1089
+ function showBonusNotification(type) {
1090
+ // Flash the progress bar
1091
+ const progressEl = document.getElementById(`${type.key}Progress`);
1092
+ progressEl.style.boxShadow = '0 0 20px var(--crt-green)';
1093
+ setTimeout(() => {
1094
+ progressEl.style.boxShadow = 'none';
1095
+ }, 500);
1096
+ }
 
 
 
 
 
 
 
 
 
 
 
1097
 
1098
+ function updateCollectionUI() {
1099
+ Object.keys(collections).forEach(key => {
1100
+ const collection = collections[key];
1101
+ const type = Object.values(ARTIFACT_TYPES).find(t => t.key === key);
1102
+ const progress = (collection.count % COLLECTION_GOAL) / COLLECTION_GOAL * 100;
 
 
 
 
 
 
 
 
1103
 
1104
+ document.getElementById(`${key}Count`).textContent = collection.count;
1105
+ document.getElementById(`${key}Progress`).style.width = `${progress}%`;
 
 
 
 
1106
 
1107
+ const bonusEl = document.getElementById(`${key}Bonus`);
1108
+ const remaining = COLLECTION_GOAL - (collection.count % COLLECTION_GOAL);
1109
+ if (remaining === COLLECTION_GOAL && collection.count > 0) {
1110
+ bonusEl.textContent = `✓ Bonus earned! Next at ${collection.count + COLLECTION_GOAL}`;
1111
+ bonusEl.classList.add('achieved');
1112
+ } else {
1113
+ bonusEl.textContent = `${remaining} more for +${type.bonusTime}s bonus`;
1114
+ bonusEl.classList.remove('achieved');
 
 
 
 
 
 
 
 
 
 
1115
  }
1116
  });
1117
  }
1118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1119
  function triggerQuiz() {
1120
  quizActive = true;
 
1121
 
1122
  // Select random question
1123
  const correctIndex = Math.floor(Math.random() * glossaryData.length);
 
1137
  currentQuiz = { correct, answers };
1138
 
1139
  // Update modal
1140
+ const diff = DIFFICULTY[currentDifficulty];
1141
  document.getElementById('quizTerm').textContent = correct.term;
1142
+
1143
+ const stakesEl = document.querySelector('.quiz-stakes');
1144
+ stakesEl.innerHTML = `<span class="gain">✓ Correct: +${diff.quizGain}s</span> &nbsp;|&nbsp; <span class="lose">✗ Wrong: -${diff.quizLoss}s</span>`;
1145
+
1146
  const optionsEl = document.getElementById('answerOptions');
1147
  optionsEl.innerHTML = '';
1148
 
1149
  answers.forEach((answer, i) => {
1150
  const btn = document.createElement('button');
1151
  btn.className = 'answer-btn';
1152
+ btn.textContent = answer.definition.substring(0, 120) + (answer.definition.length > 120 ? '...' : '');
1153
  btn.onclick = () => submitAnswer(answer === correct, btn);
1154
  optionsEl.appendChild(btn);
1155
  });
1156
 
1157
  // Show modal
1158
  document.getElementById('quizModal').classList.add('show');
 
 
 
 
 
 
 
 
 
1159
  }
1160
 
1161
  function submitAnswer(correct, btnEl) {
1162
+ const diff = DIFFICULTY[currentDifficulty];
1163
  quizzesTotal++;
1164
 
1165
+ // Disable all buttons and show correct answer
1166
  document.querySelectorAll('.answer-btn').forEach(btn => {
1167
  btn.onclick = null;
1168
  if (btn.textContent.includes(currentQuiz.correct.definition.substring(0, 50))) {
 
1170
  }
1171
  });
1172
 
1173
+ const modalInner = document.getElementById('quizModalInner');
1174
+
1175
  if (correct) {
1176
  quizzesCorrect++;
1177
+ timeLeft += diff.quizGain;
1178
+ score += 25;
1179
  if (btnEl) btnEl.classList.add('correct');
1180
+ modalInner.classList.add('success');
1181
+ modalInner.querySelector('h2').textContent = '✓ Correct!';
1182
  } else {
1183
+ timeLeft = Math.max(0, timeLeft - diff.quizLoss);
1184
  if (btnEl) btnEl.classList.add('wrong');
1185
+ modalInner.classList.remove('success');
1186
+ modalInner.querySelector('h2').textContent = '✗ Wrong!';
1187
  }
1188
 
1189
+ updateStats();
1190
+
1191
  // Close modal after delay
1192
  setTimeout(() => {
1193
  document.getElementById('quizModal').classList.remove('show');
1194
+ modalInner.classList.remove('success');
1195
+ modalInner.querySelector('h2').textContent = '☠️ Bit Rot Detected!';
1196
  quizActive = false;
1197
+
1198
+ if (timeLeft <= 0) {
1199
+ endGame();
1200
+ }
1201
  }, 1500);
1202
  }
1203
 
1204
  function updateTimer() {
1205
+ if (isPaused || quizActive || gameOver) return;
1206
 
1207
  timeLeft--;
1208
  updateStats();
1209
 
1210
  if (timeLeft <= 0) {
1211
+ endGame();
 
 
 
 
 
1212
  }
1213
  }
1214
 
1215
  function updateStats() {
1216
  document.getElementById('score').textContent = score;
 
1217
  document.getElementById('quizzes').textContent = `${quizzesCorrect}/${quizzesTotal}`;
1218
 
1219
+ const mins = Math.floor(Math.max(0, timeLeft) / 60);
1220
+ const secs = Math.max(0, timeLeft) % 60;
1221
  const timerEl = document.getElementById('timer');
1222
  timerEl.textContent = `${mins}:${secs.toString().padStart(2, '0')}`;
1223
 
 
1228
  }
1229
  }
1230
 
1231
+ function endGame() {
1232
+ gameOver = true;
1233
  isRunning = false;
1234
  clearInterval(gameLoop);
1235
  clearInterval(timerLoop);
1236
 
1237
  document.getElementById('startBtn').disabled = false;
1238
  document.getElementById('pauseBtn').disabled = true;
1239
+ document.getElementById('difficultySlider').disabled = false;
1240
 
1241
  // Show game over modal
1242
  const accuracy = quizzesTotal > 0 ? Math.round((quizzesCorrect / quizzesTotal) * 100) : 0;
1243
  document.getElementById('gameOverTitle').textContent = timeLeft > 0 ? '💀 Archive Corrupted!' : '⏰ Time Expired!';
1244
  document.getElementById('finalScore').textContent = score;
1245
+ document.getElementById('finalFloppies').textContent = collections.floppy.count;
1246
+ document.getElementById('finalCDs').textContent = collections.cdrom.count;
1247
+ document.getElementById('finalVHS').textContent = collections.vhs.count;
1248
  document.getElementById('finalQuizzes').textContent = `${accuracy}%`;
1249
+ document.getElementById('finalBonuses').textContent = totalBonuses;
1250
 
1251
  document.getElementById('gameOverModal').classList.add('show');
1252
  }
1253
 
1254
  function restartGame() {
1255
  document.getElementById('gameOverModal').classList.remove('show');
1256
+ startNewGame();
1257
+ }
1258
+
1259
+ function draw() {
1260
+ // Clear
1261
+ ctx.fillStyle = '#000';
1262
+ ctx.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
1263
+
1264
+ // Draw grid (subtle)
1265
+ ctx.strokeStyle = 'rgba(0, 255, 65, 0.05)';
1266
+ for (let x = 0; x <= COLS; x++) {
1267
+ ctx.beginPath();
1268
+ ctx.moveTo(x * GRID_SIZE, 0);
1269
+ ctx.lineTo(x * GRID_SIZE, CANVAS_HEIGHT);
1270
+ ctx.stroke();
1271
+ }
1272
+ for (let y = 0; y <= ROWS; y++) {
1273
+ ctx.beginPath();
1274
+ ctx.moveTo(0, y * GRID_SIZE);
1275
+ ctx.lineTo(CANVAS_WIDTH, y * GRID_SIZE);
1276
+ ctx.stroke();
1277
+ }
1278
+
1279
+ // Draw bit rot zones (just the skull, no box)
1280
+ bitRots.forEach(rot => {
1281
+ ctx.font = '18px Arial';
1282
+ ctx.textAlign = 'center';
1283
+ ctx.textBaseline = 'middle';
1284
+ ctx.fillText('☠️', rot.x * GRID_SIZE + GRID_SIZE/2, rot.y * GRID_SIZE + GRID_SIZE/2);
1285
+ });
1286
+
1287
+ // Draw artifacts (just the emoji, no box)
1288
+ artifacts.forEach(artifact => {
1289
+ ctx.font = '18px Arial';
1290
+ ctx.textAlign = 'center';
1291
+ ctx.textBaseline = 'middle';
1292
+ ctx.fillText(artifact.type.emoji, artifact.x * GRID_SIZE + GRID_SIZE/2, artifact.y * GRID_SIZE + GRID_SIZE/2);
1293
+ });
1294
+
1295
+ // Draw snake
1296
+ snake.forEach((seg, i) => {
1297
+ const isHead = i === 0;
1298
+ const alpha = 1 - (i / snake.length) * 0.5;
1299
+
1300
+ if (isHead) {
1301
+ ctx.fillStyle = '#00ff41';
1302
+ ctx.shadowColor = '#00ff41';
1303
+ ctx.shadowBlur = 10;
1304
+ } else {
1305
+ ctx.fillStyle = `rgba(0, 255, 65, ${alpha})`;
1306
+ ctx.shadowBlur = 0;
1307
+ }
1308
+
1309
+ ctx.fillRect(
1310
+ seg.x * GRID_SIZE + 1,
1311
+ seg.y * GRID_SIZE + 1,
1312
+ GRID_SIZE - 2,
1313
+ GRID_SIZE - 2
1314
+ );
1315
+
1316
+ if (isHead) {
1317
+ ctx.shadowBlur = 0;
1318
+ // Draw eyes
1319
+ ctx.fillStyle = '#000';
1320
+ if (direction.x === 1) {
1321
+ ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 5, 3, 3);
1322
+ ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 12, 3, 3);
1323
+ } else if (direction.x === -1) {
1324
+ ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 5, 3, 3);
1325
+ ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 12, 3, 3);
1326
+ } else if (direction.y === -1) {
1327
+ ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 5, 3, 3);
1328
+ ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 5, 3, 3);
1329
+ } else {
1330
+ ctx.fillRect(seg.x * GRID_SIZE + 5, seg.y * GRID_SIZE + 12, 3, 3);
1331
+ ctx.fillRect(seg.x * GRID_SIZE + 12, seg.y * GRID_SIZE + 12, 3, 3);
1332
+ }
1333
+ }
1334
+ });
1335
  }
1336
 
1337
  function handleKeyPress(e) {
1338
+ if (!isRunning || isPaused || quizActive) return;
1339
 
1340
  const key = e.key.toLowerCase();
1341