darkc0de commited on
Commit
63cb361
·
verified ·
1 Parent(s): e4dfa63

Delete script.js

Browse files
Files changed (1) hide show
  1. script.js +0 -199
script.js DELETED
@@ -1,199 +0,0 @@
1
- /* =========================================
2
- 1. Boot Sequence Logic
3
- ========================================= */
4
- const bootLines =[
5
- "XORTRON CRIMINAL COMPUTING BIOS v2.4.1",
6
- "Copyright (C) 2084 XORTRON Syndicate",
7
- "Initializing hardware interface... OK",
8
- "Checking memory... 64000K OK",
9
- "Loading Neural Net Drivers... SUCCESS",
10
- "Connecting to Dark Web Node 77-Alpha...",
11
- "Bypassing security protocols...",
12
- "Decryption key accepted.",
13
- "Mounting virtual drives...",
14
- "System Ready. Welcome, Operative."
15
- ];
16
-
17
- let bootScreen = document.getElementById('boot-screen');
18
- let bootText = document.getElementById('boot-text');
19
- let lineIndex = 0;
20
-
21
- function runBootSequence() {
22
- if (lineIndex < bootLines.length) {
23
- bootText.innerHTML += bootLines[lineIndex] + "<br>";
24
- lineIndex++;
25
- // Speed of boot lines appearing
26
- setTimeout(runBootSequence, Math.random() * 300 + 100);
27
- } else {
28
- // Wait 1 second after boot text finishes, then fade out
29
- setTimeout(() => {
30
- bootScreen.style.opacity = '0';
31
- setTimeout(() => { bootScreen.style.display = 'none'; }, 1000);
32
- }, 1000);
33
- }
34
- }
35
- window.onload = runBootSequence;
36
-
37
- /* =========================================
38
- 2. System Clock & Window Management
39
- ========================================= */
40
- function updateClock() {
41
- const now = new Date();
42
- document.getElementById('clock').innerText = now.toLocaleTimeString();
43
- }
44
- setInterval(updateClock, 1000);
45
- updateClock();
46
-
47
- let highestZIndex = 10;
48
-
49
- function openWindow(id) {
50
- let win = document.getElementById(id);
51
- win.style.display = 'flex';
52
- bringToFront(win);
53
- }
54
-
55
- function closeWindow(id) {
56
- document.getElementById(id).style.display = 'none';
57
- }
58
-
59
- function bringToFront(elmnt) {
60
- highestZIndex++;
61
- elmnt.style.zIndex = highestZIndex;
62
- }
63
-
64
- // Apply drag functionality to all windows
65
- document.querySelectorAll('.window').forEach(win => {
66
- dragElement(win);
67
- // Bring window to front when clicked anywhere on it
68
- win.addEventListener('mousedown', () => bringToFront(win));
69
- });
70
-
71
- function dragElement(elmnt) {
72
- var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
73
- var header = document.getElementById(elmnt.id + "-header");
74
-
75
- if (header) { header.onmousedown = dragMouseDown; }
76
- else { elmnt.onmousedown = dragMouseDown; }
77
-
78
- function dragMouseDown(e) {
79
- e = e || window.event;
80
- e.preventDefault();
81
- pos3 = e.clientX;
82
- pos4 = e.clientY;
83
- document.onmouseup = closeDragElement;
84
- document.onmousemove = elementDrag;
85
- bringToFront(elmnt);
86
- }
87
-
88
- function elementDrag(e) {
89
- e = e || window.event;
90
- e.preventDefault();
91
- pos1 = pos3 - e.clientX;
92
- pos2 = pos4 - e.clientY;
93
- pos3 = e.clientX;
94
- pos4 = e.clientY;
95
- elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
96
- elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
97
- }
98
-
99
- function closeDragElement() {
100
- document.onmouseup = null;
101
- document.onmousemove = null;
102
- }
103
- }
104
-
105
- /* =========================================
106
- 3. XOR-Snake Game Logic
107
- ========================================= */
108
- const canvas = document.getElementById('snake-canvas');
109
- const ctx = canvas.getContext('2d');
110
- const gridSize = 20;
111
- let snake =[{x: 200, y: 200}];
112
- let apple = {x: 100, y: 100};
113
- let dx = 0;
114
- let dy = 0;
115
- let gameInterval;
116
- let gameRunning = false;
117
-
118
- function initSnake() {
119
- if(gameRunning) return;
120
- snake =[{x: 200, y: 200}];
121
- dx = gridSize; dy = 0; // Start moving right
122
- placeApple();
123
- gameRunning = true;
124
- gameInterval = setInterval(gameLoop, 100);
125
-
126
- // Auto-focus window to accept keystrokes immediately
127
- bringToFront(document.getElementById('snake-window'));
128
- }
129
-
130
- function placeApple() {
131
- apple.x = Math.floor(Math.random() * (canvas.width / gridSize)) * gridSize;
132
- apple.y = Math.floor(Math.random() * (canvas.height / gridSize)) * gridSize;
133
- }
134
-
135
- function gameLoop() {
136
- // Move Snake
137
- const head = {x: snake[0].x + dx, y: snake[0].y + dy};
138
- snake.unshift(head);
139
-
140
- // Check collision with apple
141
- if (head.x === apple.x && head.y === apple.y) {
142
- placeApple();
143
- } else {
144
- snake.pop(); // Remove tail if no apple eaten
145
- }
146
-
147
- // Check collision with walls or self
148
- if (head.x < 0 || head.x >= canvas.width || head.y < 0 || head.y >= canvas.height || collision(head)) {
149
- clearInterval(gameInterval);
150
- gameRunning = false;
151
- ctx.fillStyle = '#ff003c';
152
- ctx.font = '30px "Share Tech Mono"';
153
- ctx.fillText('SYSTEM FAILURE', 80, 200);
154
- return;
155
- }
156
-
157
- // Draw Background
158
- ctx.fillStyle = 'black';
159
- ctx.fillRect(0, 0, canvas.width, canvas.height);
160
-
161
- // Draw Grid Lines (Hacker aesthetic)
162
- ctx.strokeStyle = '#003333';
163
- for(let i=0; i<canvas.width; i+=gridSize) {
164
- ctx.beginPath(); ctx.moveTo(i, 0); ctx.lineTo(i, canvas.height); ctx.stroke();
165
- ctx.beginPath(); ctx.moveTo(0, i); ctx.lineTo(canvas.width, i); ctx.stroke();
166
- }
167
-
168
- // Draw Apple
169
- ctx.fillStyle = '#ff003c';
170
- ctx.fillRect(apple.x, apple.y, gridSize - 2, gridSize - 2);
171
-
172
- // Draw Snake
173
- ctx.fillStyle = '#00e5ff';
174
- snake.forEach(part => {
175
- ctx.fillRect(part.x, part.y, gridSize - 2, gridSize - 2);
176
- });
177
- }
178
-
179
- function collision(head) {
180
- for (let i = 1; i < snake.length; i++) {
181
- if (head.x === snake[i].x && head.y === snake[i].y) return true;
182
- }
183
- return false;
184
- }
185
-
186
- // Arrow Key Controls for Snake (Only active if window is displayed)
187
- document.addEventListener('keydown', (e) => {
188
- if(document.getElementById('snake-window').style.display !== 'flex') return;
189
-
190
- // Prevent default scrolling when using arrows
191
- if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code) > -1) {
192
- e.preventDefault();
193
- }
194
-
195
- if (e.code === 'ArrowUp' && dy === 0) { dx = 0; dy = -gridSize; }
196
- else if (e.code === 'ArrowDown' && dy === 0) { dx = 0; dy = gridSize; }
197
- else if (e.code === 'ArrowLeft' && dx === 0) { dx = -gridSize; dy = 0; }
198
- else if (e.code === 'ArrowRight' && dx === 0) { dx = gridSize; dy = 0; }
199
- });