jamesbright commited on
Commit
0446533
·
verified ·
1 Parent(s): fea0c59

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +767 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Spacex Simulator
3
- emoji: 🌖
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: spacex-simulator
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: red
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,767 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>SpaceX Simulator: Build Like Elon</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&family=Roboto:wght@300;400;500;700&display=swap');
11
+
12
+ body {
13
+ font-family: 'Roboto', sans-serif;
14
+ background-color: #0a0a1a;
15
+ color: #e0e0e0;
16
+ overflow-x: hidden;
17
+ }
18
+
19
+ .orbitron {
20
+ font-family: 'Orbitron', sans-serif;
21
+ }
22
+
23
+ .space-gradient {
24
+ background: linear-gradient(135deg, #000428 0%, #004e92 100%);
25
+ }
26
+
27
+ .rocket-part {
28
+ transition: all 0.3s ease;
29
+ border: 1px solid rgba(255, 255, 255, 0.1);
30
+ }
31
+
32
+ .rocket-part:hover {
33
+ transform: translateY(-5px);
34
+ box-shadow: 0 10px 20px rgba(0, 150, 255, 0.3);
35
+ border-color: rgba(0, 150, 255, 0.5);
36
+ }
37
+
38
+ .selected-part {
39
+ box-shadow: 0 0 0 3px rgba(0, 150, 255, 0.7);
40
+ border-color: rgba(0, 150, 255, 0.9);
41
+ }
42
+
43
+ .planet-card {
44
+ transition: all 0.3s ease;
45
+ background-size: cover;
46
+ background-position: center;
47
+ }
48
+
49
+ .planet-card:hover {
50
+ transform: scale(1.05);
51
+ box-shadow: 0 10px 25px rgba(0, 150, 255, 0.4);
52
+ }
53
+
54
+ .rocket-display {
55
+ perspective: 1000px;
56
+ }
57
+
58
+ .rocket-3d {
59
+ transform-style: preserve-3d;
60
+ transition: transform 0.5s ease;
61
+ }
62
+
63
+ .flame {
64
+ position: absolute;
65
+ bottom: -20px;
66
+ left: 50%;
67
+ transform: translateX(-50%);
68
+ width: 40px;
69
+ height: 60px;
70
+ background: linear-gradient(to top, #ff4500, #ff8c00, #ffd700);
71
+ border-radius: 50% 50% 20% 20%;
72
+ filter: blur(5px);
73
+ opacity: 0;
74
+ transition: opacity 0.3s ease;
75
+ }
76
+
77
+ .launching .flame {
78
+ opacity: 1;
79
+ animation: flame-flicker 0.3s infinite alternate;
80
+ }
81
+
82
+ @keyframes flame-flicker {
83
+ 0% { height: 60px; width: 40px; }
84
+ 100% { height: 80px; width: 50px; }
85
+ }
86
+
87
+ .stars {
88
+ position: fixed;
89
+ top: 0;
90
+ left: 0;
91
+ width: 100%;
92
+ height: 100%;
93
+ z-index: -1;
94
+ }
95
+
96
+ .star {
97
+ position: absolute;
98
+ background-color: white;
99
+ border-radius: 50%;
100
+ animation: twinkle 5s infinite ease-in-out;
101
+ }
102
+
103
+ @keyframes twinkle {
104
+ 0% { opacity: 0.2; }
105
+ 50% { opacity: 1; }
106
+ 100% { opacity: 0.2; }
107
+ }
108
+
109
+ .elon-avatar {
110
+ transition: all 0.3s ease;
111
+ }
112
+
113
+ .elon-avatar:hover {
114
+ transform: scale(1.05);
115
+ filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.7));
116
+ }
117
+
118
+ .mission-control {
119
+ background: rgba(10, 20, 30, 0.9);
120
+ border: 1px solid rgba(0, 150, 255, 0.3);
121
+ box-shadow: 0 0 30px rgba(0, 150, 255, 0.2);
122
+ }
123
+
124
+ .console-text {
125
+ font-family: 'Courier New', monospace;
126
+ color: #00ff00;
127
+ text-shadow: 0 0 5px rgba(0, 255, 0, 0.7);
128
+ }
129
+
130
+ .progress-bar {
131
+ height: 10px;
132
+ background: linear-gradient(90deg, #004e92, #00b4ff);
133
+ transition: width 0.5s ease;
134
+ }
135
+
136
+ .blink {
137
+ animation: blink 1s infinite;
138
+ }
139
+
140
+ @keyframes blink {
141
+ 0% { opacity: 1; }
142
+ 50% { opacity: 0.5; }
143
+ 100% { opacity: 1; }
144
+ }
145
+ </style>
146
+ </head>
147
+ <body>
148
+ <div class="stars" id="stars"></div>
149
+
150
+ <div class="min-h-screen flex flex-col">
151
+ <!-- Header -->
152
+ <header class="space-gradient py-4 px-6 shadow-lg">
153
+ <div class="container mx-auto flex justify-between items-center">
154
+ <div class="flex items-center space-x-4">
155
+ <i class="fas fa-rocket text-3xl text-yellow-400"></i>
156
+ <h1 class="orbitron text-2xl md:text-3xl font-bold text-white">
157
+ <span class="text-yellow-400">SPACEX</span> SIMULATOR
158
+ </h1>
159
+ </div>
160
+ <div class="flex items-center space-x-4">
161
+ <div class="hidden md:flex items-center space-x-2">
162
+ <i class="fas fa-coins text-yellow-400"></i>
163
+ <span class="font-bold" id="funds">$10,000,000</span>
164
+ </div>
165
+ <div class="hidden md:flex items-center space-x-2">
166
+ <i class="fas fa-star text-blue-400"></i>
167
+ <span class="font-bold" id="reputation">100</span>
168
+ </div>
169
+ <button class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg orbitron">
170
+ MISSION CONTROL
171
+ </button>
172
+ </div>
173
+ </div>
174
+ </header>
175
+
176
+ <!-- Main Content -->
177
+ <main class="flex-grow container mx-auto px-4 py-8">
178
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
179
+ <!-- Rocket Builder Panel -->
180
+ <div class="lg:col-span-2 space-y-8">
181
+ <!-- Rocket Display -->
182
+ <div class="bg-gray-900 rounded-xl p-6 shadow-xl border border-gray-800">
183
+ <h2 class="orbitron text-xl text-blue-400 mb-4">ROCKET DESIGN</h2>
184
+ <div class="rocket-display flex justify-center items-end h-96">
185
+ <div class="rocket-3d relative" id="rocket-model">
186
+ <!-- Rocket parts will be added here by JavaScript -->
187
+ <div class="flame" id="rocket-flame"></div>
188
+ </div>
189
+ </div>
190
+ <div class="mt-6 grid grid-cols-3 gap-4">
191
+ <div class="bg-gray-800 rounded-lg p-3 text-center">
192
+ <p class="text-gray-400 text-sm">DELTA-V</p>
193
+ <p class="orbitron text-xl" id="delta-v">0 m/s</p>
194
+ </div>
195
+ <div class="bg-gray-800 rounded-lg p-3 text-center">
196
+ <p class="text-gray-400 text-sm">PAYLOAD</p>
197
+ <p class="orbitron text-xl" id="payload">0 kg</p>
198
+ </div>
199
+ <div class="bg-gray-800 rounded-lg p-3 text-center">
200
+ <p class="text-gray-400 text-sm">COST</p>
201
+ <p class="orbitron text-xl" id="rocket-cost">$0</p>
202
+ </div>
203
+ </div>
204
+ </div>
205
+
206
+ <!-- Parts Selection -->
207
+ <div class="bg-gray-900 rounded-xl p-6 shadow-xl border border-gray-800">
208
+ <h2 class="orbitron text-xl text-blue-400 mb-4">ROCKET COMPONENTS</h2>
209
+ <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
210
+ <!-- Parts will be added here by JavaScript -->
211
+ </div>
212
+ </div>
213
+ </div>
214
+
215
+ <!-- Mission Control Panel -->
216
+ <div class="space-y-8">
217
+ <!-- Elon Musk Avatar -->
218
+ <div class="bg-gray-900 rounded-xl p-6 shadow-xl border border-gray-800 flex flex-col items-center">
219
+ <div class="elon-avatar mb-4 relative">
220
+ <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Elon_Musk_Royal_Society_%28crop2%29.jpg/1200px-Elon_Musk_Royal_Society_%28crop2%29.jpg"
221
+ alt="Elon Musk" class="w-32 h-32 rounded-full object-cover border-4 border-blue-500">
222
+ <div class="absolute -bottom-2 -right-2 bg-yellow-500 text-black rounded-full w-10 h-10 flex items-center justify-center">
223
+ <i class="fas fa-crown"></i>
224
+ </div>
225
+ </div>
226
+ <h3 class="orbitron text-xl text-center">ELON MUSK</h3>
227
+ <p class="text-gray-400 text-center mb-4">CEO & Chief Engineer</p>
228
+ <div class="w-full bg-gray-800 rounded-full h-2.5 mb-4">
229
+ <div class="progress-bar rounded-full h-2.5" style="width: 100%"></div>
230
+ </div>
231
+ <div class="mission-control w-full bg-gray-800 rounded-lg p-4 h-48 overflow-y-auto">
232
+ <p class="console-text">> Welcome to SpaceX Simulator</p>
233
+ <p class="console-text">> Initializing systems...</p>
234
+ <p class="console-text">> Ready to build some rockets!</p>
235
+ <p class="console-text blink">> _</p>
236
+ </div>
237
+ </div>
238
+
239
+ <!-- Destination Selector -->
240
+ <div class="bg-gray-900 rounded-xl p-6 shadow-xl border border-gray-800">
241
+ <h2 class="orbitron text-xl text-blue-400 mb-4">MISSION DESTINATION</h2>
242
+ <div class="grid grid-cols-2 gap-4" id="destinations">
243
+ <!-- Planets will be added here by JavaScript -->
244
+ </div>
245
+ </div>
246
+
247
+ <!-- Launch Controls -->
248
+ <div class="bg-gray-900 rounded-xl p-6 shadow-xl border border-gray-800">
249
+ <h2 class="orbitron text-xl text-blue-400 mb-4">MISSION CONTROL</h2>
250
+ <div class="space-y-4">
251
+ <div>
252
+ <label class="block text-gray-400 mb-2">Mission Name</label>
253
+ <input type="text" class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
254
+ placeholder="e.g. Mars Colony 1" id="mission-name">
255
+ </div>
256
+ <div>
257
+ <label class="block text-gray-400 mb-2">Payload Type</label>
258
+ <select class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" id="payload-type">
259
+ <option value="satellite">Communication Satellite</option>
260
+ <option value="rover">Planetary Rover</option>
261
+ <option value="probe">Scientific Probe</option>
262
+ <option value="habitat">Colony Habitat</option>
263
+ <option value="crew">Astronaut Crew</option>
264
+ </select>
265
+ </div>
266
+ <div>
267
+ <label class="block text-gray-400 mb-2">Payload Mass (kg)</label>
268
+ <input type="number" class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
269
+ value="1000" min="100" max="100000" id="payload-mass">
270
+ </div>
271
+ <button class="w-full bg-green-600 hover:bg-green-700 text-white py-3 rounded-lg orbitron text-lg flex items-center justify-center space-x-2" id="launch-button">
272
+ <i class="fas fa-rocket"></i>
273
+ <span>INITIATE LAUNCH SEQUENCE</span>
274
+ </button>
275
+ </div>
276
+ </div>
277
+ </div>
278
+ </div>
279
+ </main>
280
+
281
+ <!-- Footer -->
282
+ <footer class="space-gradient py-6 px-6">
283
+ <div class="container mx-auto">
284
+ <div class="flex flex-col md:flex-row justify-between items-center">
285
+ <div class="flex items-center space-x-4 mb-4 md:mb-0">
286
+ <i class="fab fa-twitter text-blue-400 text-xl"></i>
287
+ <i class="fab fa-linkedin text-blue-400 text-xl"></i>
288
+ <i class="fab fa-instagram text-purple-400 text-xl"></i>
289
+ </div>
290
+ <p class="text-gray-300 text-sm">© 2023 SpaceX Simulator. Not affiliated with SpaceX or Elon Musk. For educational purposes only.</p>
291
+ </div>
292
+ </div>
293
+ </footer>
294
+ </div>
295
+
296
+ <script>
297
+ // Create stars background
298
+ function createStars() {
299
+ const stars = document.getElementById('stars');
300
+ const count = 200;
301
+
302
+ for (let i = 0; i < count; i++) {
303
+ const star = document.createElement('div');
304
+ star.className = 'star';
305
+
306
+ // Random position
307
+ const x = Math.random() * 100;
308
+ const y = Math.random() * 100;
309
+
310
+ // Random size
311
+ const size = Math.random() * 2;
312
+
313
+ // Random opacity
314
+ const opacity = Math.random();
315
+
316
+ // Random animation delay
317
+ const delay = Math.random() * 5;
318
+
319
+ star.style.left = `${x}%`;
320
+ star.style.top = `${y}%`;
321
+ star.style.width = `${size}px`;
322
+ star.style.height = `${size}px`;
323
+ star.style.opacity = opacity;
324
+ star.style.animationDelay = `${delay}s`;
325
+
326
+ stars.appendChild(star);
327
+ }
328
+ }
329
+
330
+ // Rocket parts data
331
+ const rocketParts = {
332
+ firstStages: [
333
+ { id: 'falcon9', name: 'Falcon 9', cost: 5000000, mass: 25000, thrust: 7607, height: 10, color: 'bg-white', image: 'https://www.spacex.com/static/images/falcon9/falcon9-1.png' },
334
+ { id: 'falcon-heavy', name: 'Falcon Heavy', cost: 9000000, mass: 40000, thrust: 22819, height: 12, color: 'bg-gray-300', image: 'https://www.spacex.com/static/images/falcon-heavy/falcon-heavy-1.png' },
335
+ { id: 'starship', name: 'Starship', cost: 15000000, mass: 120000, thrust: 75000, height: 18, color: 'bg-gray-400', image: 'https://www.spacex.com/static/images/starship/starship-1.png' },
336
+ { id: 'nova', name: 'Nova', cost: 20000000, mass: 150000, thrust: 100000, height: 20, color: 'bg-blue-200', image: '' }
337
+ ],
338
+ secondStages: [
339
+ { id: 'falcon9-upper', name: 'Falcon 9 Upper', cost: 2000000, mass: 5000, thrust: 934, height: 6, color: 'bg-white', image: '' },
340
+ { id: 'falcon-heavy-upper', name: 'Falcon Heavy Upper', cost: 3000000, mass: 8000, thrust: 934, height: 8, color: 'bg-gray-300', image: '' },
341
+ { id: 'starship-upper', name: 'Starship Upper', cost: 5000000, mass: 15000, thrust: 3000, height: 12, color: 'bg-gray-400', image: '' },
342
+ { id: 'nova-upper', name: 'Nova Upper', cost: 7000000, mass: 20000, thrust: 5000, height: 14, color: 'bg-blue-200', image: '' }
343
+ ],
344
+ fairings: [
345
+ { id: 'standard', name: 'Standard Fairing', cost: 1000000, mass: 2000, height: 5, color: 'bg-white', image: '' },
346
+ { id: 'extended', name: 'Extended Fairing', cost: 1500000, mass: 3000, height: 7, color: 'bg-gray-300', image: '' },
347
+ { id: 'heavy', name: 'Heavy Fairing', cost: 2000000, mass: 4000, height: 8, color: 'bg-gray-400', image: '' },
348
+ { id: 'none', name: 'No Fairing', cost: 0, mass: 0, height: 0, color: 'transparent', image: '' }
349
+ ],
350
+ engines: [
351
+ { id: 'merlin', name: 'Merlin', cost: 1000000, thrust: 845, isp: 282, color: 'bg-gray-500', image: '' },
352
+ { id: 'raptor', name: 'Raptor', cost: 2000000, thrust: 2000, isp: 330, color: 'bg-gray-600', image: '' },
353
+ { id: 'be-4', name: 'BE-4', cost: 2500000, thrust: 2400, isp: 340, color: 'bg-blue-600', image: '' },
354
+ { id: 'rs-25', name: 'RS-25', cost: 3000000, thrust: 1860, isp: 366, color: 'bg-red-600', image: '' }
355
+ ]
356
+ };
357
+
358
+ // Planets data
359
+ const destinations = [
360
+ { id: 'leo', name: 'Low Earth Orbit', distance: 200, difficulty: 1, image: 'https://science.nasa.gov/wp-content/uploads/2023/09/iss067e092866_large.jpg?w=1536' },
361
+ { id: 'moon', name: 'The Moon', distance: 384400, difficulty: 2, image: 'https://science.nasa.gov/wp-content/uploads/2023/09/webb-southern-ring-nebula-1.jpg?w=1536' },
362
+ { id: 'mars', name: 'Mars', distance: 225000000, difficulty: 3, image: 'https://science.nasa.gov/wp-content/uploads/2023/09/pia25980-16.jpg?w=1536' },
363
+ { id: 'jupiter', name: 'Jupiter', distance: 778000000, difficulty: 4, image: 'https://science.nasa.gov/wp-content/uploads/2023/09/jupiter-1.jpg?w=1536' },
364
+ { id: 'saturn', name: 'Saturn', distance: 1400000000, difficulty: 5, image: 'https://science.nasa.gov/wp-content/uploads/2023/09/saturn-1.jpg?w=1536' },
365
+ { id: 'pluto', name: 'Pluto', distance: 5900000000, difficulty: 6, image: 'https://science.nasa.gov/wp-content/uploads/2023/09/pluto-1.jpg?w=1536' }
366
+ ];
367
+
368
+ // Game state
369
+ let gameState = {
370
+ funds: 10000000,
371
+ reputation: 100,
372
+ currentRocket: {
373
+ firstStage: null,
374
+ secondStage: null,
375
+ fairing: null,
376
+ engines: null
377
+ },
378
+ currentDestination: null,
379
+ currentPayload: {
380
+ type: 'satellite',
381
+ mass: 1000
382
+ }
383
+ };
384
+
385
+ // Initialize the game
386
+ function initGame() {
387
+ createStars();
388
+ renderParts();
389
+ renderDestinations();
390
+ updateUI();
391
+
392
+ // Set up event listeners
393
+ document.getElementById('launch-button').addEventListener('click', launchRocket);
394
+ document.getElementById('payload-type').addEventListener('change', updatePayload);
395
+ document.getElementById('payload-mass').addEventListener('input', updatePayload);
396
+ }
397
+
398
+ // Render rocket parts selection
399
+ function renderParts() {
400
+ const partsContainer = document.querySelector('.grid.grid-cols-2.md\\:grid-cols-4.gap-4');
401
+
402
+ // First stages
403
+ rocketParts.firstStages.forEach(part => {
404
+ const partElement = createPartElement(part, 'firstStage');
405
+ partsContainer.appendChild(partElement);
406
+ });
407
+
408
+ // Second stages
409
+ rocketParts.secondStages.forEach(part => {
410
+ const partElement = createPartElement(part, 'secondStage');
411
+ partsContainer.appendChild(partElement);
412
+ });
413
+
414
+ // Fairings
415
+ rocketParts.fairings.forEach(part => {
416
+ const partElement = createPartElement(part, 'fairing');
417
+ partsContainer.appendChild(partElement);
418
+ });
419
+
420
+ // Engines
421
+ rocketParts.engines.forEach(part => {
422
+ const partElement = createPartElement(part, 'engines');
423
+ partsContainer.appendChild(partElement);
424
+ });
425
+ }
426
+
427
+ // Create a part selection element
428
+ function createPartElement(part, partType) {
429
+ const partElement = document.createElement('div');
430
+ partElement.className = 'rocket-part bg-gray-800 rounded-lg p-4 cursor-pointer flex flex-col items-center';
431
+ partElement.dataset.partId = part.id;
432
+ partElement.dataset.partType = partType;
433
+
434
+ partElement.innerHTML = `
435
+ <div class="w-16 h-16 ${part.color} rounded-full mb-2 flex items-center justify-center">
436
+ ${part.image ? `<img src="${part.image}" alt="${part.name}" class="w-full h-full object-contain">` : '<i class="fas fa-rocket text-xl"></i>'}
437
+ </div>
438
+ <h3 class="font-bold text-center">${part.name}</h3>
439
+ <p class="text-sm text-gray-400 text-center">$${part.cost.toLocaleString()}</p>
440
+ `;
441
+
442
+ partElement.addEventListener('click', () => selectPart(part, partType));
443
+
444
+ return partElement;
445
+ }
446
+
447
+ // Render destination selection
448
+ function renderDestinations() {
449
+ const destinationsContainer = document.getElementById('destinations');
450
+
451
+ destinations.forEach(destination => {
452
+ const destinationElement = document.createElement('div');
453
+ destinationElement.className = 'planet-card rounded-lg overflow-hidden cursor-pointer relative h-32';
454
+ destinationElement.style.backgroundImage = `url(${destination.image})`;
455
+ destinationElement.dataset.destinationId = destination.id;
456
+
457
+ destinationElement.innerHTML = `
458
+ <div class="absolute inset-0 bg-black bg-opacity-50 hover:bg-opacity-30 transition-all duration-300 flex items-end p-3">
459
+ <div>
460
+ <h3 class="font-bold">${destination.name}</h3>
461
+ <p class="text-xs">${destination.distance.toLocaleString()} km</p>
462
+ </div>
463
+ </div>
464
+ `;
465
+
466
+ destinationElement.addEventListener('click', () => selectDestination(destination));
467
+
468
+ destinationsContainer.appendChild(destinationElement);
469
+ });
470
+ }
471
+
472
+ // Select a rocket part
473
+ function selectPart(part, partType) {
474
+ // Deselect all parts of this type
475
+ document.querySelectorAll(`[data-part-type="${partType}"]`).forEach(el => {
476
+ el.classList.remove('selected-part');
477
+ });
478
+
479
+ // Select the clicked part
480
+ event.currentTarget.classList.add('selected-part');
481
+
482
+ // Update current rocket
483
+ gameState.currentRocket[partType] = part;
484
+
485
+ // Update rocket display
486
+ updateRocketDisplay();
487
+ updateUI();
488
+ }
489
+
490
+ // Select a destination
491
+ function selectDestination(destination) {
492
+ // Deselect all destinations
493
+ document.querySelectorAll('.planet-card').forEach(el => {
494
+ el.classList.remove('border-2', 'border-yellow-400');
495
+ });
496
+
497
+ // Select the clicked destination
498
+ event.currentTarget.classList.add('border-2', 'border-yellow-400');
499
+
500
+ // Update current destination
501
+ gameState.currentDestination = destination;
502
+
503
+ updateUI();
504
+ }
505
+
506
+ // Update payload information
507
+ function updatePayload() {
508
+ gameState.currentPayload.type = document.getElementById('payload-type').value;
509
+ gameState.currentPayload.mass = parseInt(document.getElementById('payload-mass').value);
510
+
511
+ updateUI();
512
+ }
513
+
514
+ // Update rocket display
515
+ function updateRocketDisplay() {
516
+ const rocketModel = document.getElementById('rocket-model');
517
+ rocketModel.innerHTML = '<div class="flame" id="rocket-flame"></div>';
518
+
519
+ // Add parts to the rocket model
520
+ if (gameState.currentRocket.firstStage) {
521
+ const firstStage = document.createElement('div');
522
+ firstStage.className = `first-stage ${gameState.currentRocket.firstStage.color} w-16 mx-auto`;
523
+ firstStage.style.height = `${gameState.currentRocket.firstStage.height * 10}px`;
524
+ rocketModel.appendChild(firstStage);
525
+ }
526
+
527
+ if (gameState.currentRocket.secondStage) {
528
+ const secondStage = document.createElement('div');
529
+ secondStage.className = `second-stage ${gameState.currentRocket.secondStage.color} w-12 mx-auto`;
530
+ secondStage.style.height = `${gameState.currentRocket.secondStage.height * 10}px`;
531
+ rocketModel.appendChild(secondStage);
532
+ }
533
+
534
+ if (gameState.currentRocket.fairing && gameState.currentRocket.fairing.id !== 'none') {
535
+ const fairing = document.createElement('div');
536
+ fairing.className = `fairing ${gameState.currentRocket.fairing.color} w-16 mx-auto rounded-t-lg`;
537
+ fairing.style.height = `${gameState.currentRocket.fairing.height * 10}px`;
538
+ rocketModel.appendChild(fairing);
539
+ }
540
+ }
541
+
542
+ // Update UI elements
543
+ function updateUI() {
544
+ // Update funds and reputation
545
+ document.getElementById('funds').textContent = `$${gameState.funds.toLocaleString()}`;
546
+ document.getElementById('reputation').textContent = gameState.reputation;
547
+
548
+ // Calculate rocket stats
549
+ let cost = 0;
550
+ let payloadCapacity = 0;
551
+ let deltaV = 0;
552
+
553
+ if (gameState.currentRocket.firstStage) {
554
+ cost += gameState.currentRocket.firstStage.cost;
555
+ payloadCapacity += gameState.currentRocket.firstStage.thrust * 10;
556
+ deltaV += gameState.currentRocket.firstStage.thrust * 5;
557
+ }
558
+
559
+ if (gameState.currentRocket.secondStage) {
560
+ cost += gameState.currentRocket.secondStage.cost;
561
+ payloadCapacity += gameState.currentRocket.secondStage.thrust * 5;
562
+ deltaV += gameState.currentRocket.secondStage.thrust * 3;
563
+ }
564
+
565
+ if (gameState.currentRocket.fairing) {
566
+ cost += gameState.currentRocket.fairing.cost;
567
+ }
568
+
569
+ if (gameState.currentRocket.engines) {
570
+ cost += gameState.currentRocket.engines.cost;
571
+ deltaV += gameState.currentRocket.engines.isp * 100;
572
+ }
573
+
574
+ // Update stats display
575
+ document.getElementById('delta-v').textContent = `${deltaV.toLocaleString()} m/s`;
576
+ document.getElementById('payload').textContent = `${payloadCapacity.toLocaleString()} kg`;
577
+ document.getElementById('rocket-cost').textContent = `$${cost.toLocaleString()}`;
578
+
579
+ // Update launch button state
580
+ const launchButton = document.getElementById('launch-button');
581
+ if (isReadyForLaunch()) {
582
+ launchButton.disabled = false;
583
+ launchButton.classList.remove('bg-gray-600', 'cursor-not-allowed');
584
+ launchButton.classList.add('bg-green-600', 'hover:bg-green-700');
585
+ } else {
586
+ launchButton.disabled = true;
587
+ launchButton.classList.remove('bg-green-600', 'hover:bg-green-700');
588
+ launchButton.classList.add('bg-gray-600', 'cursor-not-allowed');
589
+ }
590
+ }
591
+
592
+ // Check if rocket is ready for launch
593
+ function isReadyForLaunch() {
594
+ return gameState.currentRocket.firstStage &&
595
+ gameState.currentRocket.secondStage &&
596
+ gameState.currentRocket.engines &&
597
+ gameState.currentDestination &&
598
+ gameState.currentPayload.mass > 0;
599
+ }
600
+
601
+ // Launch the rocket
602
+ function launchRocket() {
603
+ if (!isReadyForLaunch()) return;
604
+
605
+ const rocketModel = document.getElementById('rocket-model');
606
+ const rocketFlame = document.getElementById('rocket-flame');
607
+ const missionControl = document.querySelector('.mission-control');
608
+ const launchButton = document.getElementById('launch-button');
609
+
610
+ // Disable launch button during launch
611
+ launchButton.disabled = true;
612
+ launchButton.classList.remove('bg-green-600', 'hover:bg-green-700');
613
+ launchButton.classList.add('bg-gray-600', 'cursor-not-allowed');
614
+
615
+ // Add launching class for animation
616
+ rocketModel.classList.add('launching');
617
+
618
+ // Calculate mission success chance (simplified)
619
+ const rocketPower = (gameState.currentRocket.firstStage.thrust +
620
+ gameState.currentRocket.secondStage.thrust) / 1000;
621
+ const difficulty = gameState.currentDestination.difficulty;
622
+ const successChance = Math.min(0.9, 0.5 + (rocketPower - difficulty) * 0.1);
623
+
624
+ // Calculate mission cost
625
+ const missionCost = calculateMissionCost();
626
+
627
+ // Update mission control console
628
+ updateConsole("> Starting launch sequence...");
629
+ setTimeout(() => updateConsole("> Engine ignition..."), 1000);
630
+ setTimeout(() => updateConsole("> Liftoff! We have liftoff!"), 2000);
631
+ setTimeout(() => updateConsole(`> Rocket is on course for ${gameState.currentDestination.name}`), 3000);
632
+
633
+ // Simulate launch sequence
634
+ setTimeout(() => {
635
+ // Random mission outcome
636
+ const isSuccess = Math.random() < successChance;
637
+
638
+ if (isSuccess) {
639
+ // Successful mission
640
+ setTimeout(() => updateConsole("> First stage separation successful"), 4000);
641
+ setTimeout(() => updateConsole("> Second stage ignition"), 5000);
642
+ setTimeout(() => updateConsole("> Payload deployment confirmed"), 6000);
643
+ setTimeout(() => updateConsole(`> Mission to ${gameState.currentDestination.name} successful!`), 7000);
644
+
645
+ // Calculate rewards
646
+ const reputationGain = gameState.currentDestination.difficulty * 10;
647
+ const financialReward = gameState.currentDestination.difficulty * 500000;
648
+
649
+ setTimeout(() => {
650
+ updateConsole(`> Reputation increased by ${reputationGain}`);
651
+ updateConsole(`> Financial reward: $${financialReward.toLocaleString()}`);
652
+ updateConsole("> Ready for next mission");
653
+
654
+ // Update game state
655
+ gameState.reputation += reputationGain;
656
+ gameState.funds += financialReward - missionCost;
657
+
658
+ // Reset for next launch
659
+ resetAfterLaunch();
660
+ }, 8000);
661
+ } else {
662
+ // Failed mission
663
+ const failureReason = getRandomFailureReason();
664
+
665
+ setTimeout(() => updateConsole(`> WARNING: ${failureReason}`), 4000);
666
+ setTimeout(() => updateConsole("> Attempting to mitigate..."), 5000);
667
+ setTimeout(() => updateConsole("> Mission failure confirmed"), 6000);
668
+ setTimeout(() => updateConsole("> Investigating root cause"), 7000);
669
+
670
+ // Calculate penalties
671
+ const reputationLoss = gameState.currentDestination.difficulty * 5;
672
+ const financialLoss = missionCost * 0.5;
673
+
674
+ setTimeout(() => {
675
+ updateConsole(`> Reputation decreased by ${reputationLoss}`);
676
+ updateConsole(`> Financial loss: $${financialLoss.toLocaleString()}`);
677
+ updateConsole("> Preparing for next attempt");
678
+
679
+ // Update game state
680
+ gameState.reputation = Math.max(0, gameState.reputation - reputationLoss);
681
+ gameState.funds -= financialLoss;
682
+
683
+ // Reset for next launch
684
+ resetAfterLaunch();
685
+ }, 8000);
686
+ }
687
+ }, 3000);
688
+ }
689
+
690
+ // Calculate mission cost
691
+ function calculateMissionCost() {
692
+ let cost = 0;
693
+
694
+ if (gameState.currentRocket.firstStage) cost += gameState.currentRocket.firstStage.cost;
695
+ if (gameState.currentRocket.secondStage) cost += gameState.currentRocket.secondStage.cost;
696
+ if (gameState.currentRocket.fairing) cost += gameState.currentRocket.fairing.cost;
697
+ if (gameState.currentRocket.engines) cost += gameState.currentRocket.engines.cost;
698
+
699
+ // Add payload cost
700
+ cost += gameState.currentPayload.mass * 1000;
701
+
702
+ return cost;
703
+ }
704
+
705
+ // Get random failure reason
706
+ function getRandomFailureReason() {
707
+ const reasons = [
708
+ "First stage engine failure",
709
+ "Guidance system malfunction",
710
+ "Structural integrity compromised",
711
+ "Fuel leak detected",
712
+ "Second stage separation failure",
713
+ "Communication loss",
714
+ "Payload fairing jettison failure",
715
+ "Trajectory deviation"
716
+ ];
717
+
718
+ return reasons[Math.floor(Math.random() * reasons.length)];
719
+ }
720
+
721
+ // Update mission control console
722
+ function updateConsole(message) {
723
+ const consoleElement = document.querySelector('.mission-control');
724
+ const blinkElement = document.querySelector('.blink');
725
+
726
+ if (blinkElement) {
727
+ blinkElement.remove();
728
+ }
729
+
730
+ const newMessage = document.createElement('p');
731
+ newMessage.className = 'console-text';
732
+ newMessage.textContent = message;
733
+
734
+ consoleElement.appendChild(newMessage);
735
+ consoleElement.scrollTop = consoleElement.scrollHeight;
736
+
737
+ // Add new blinking cursor
738
+ const newBlink = document.createElement('p');
739
+ newBlink.className = 'console-text blink';
740
+ newBlink.textContent = '> _';
741
+
742
+ consoleElement.appendChild(newBlink);
743
+ consoleElement.scrollTop = consoleElement.scrollHeight;
744
+ }
745
+
746
+ // Reset after launch
747
+ function resetAfterLaunch() {
748
+ const rocketModel = document.getElementById('rocket-model');
749
+ const launchButton = document.getElementById('launch-button');
750
+
751
+ // Remove launching class
752
+ rocketModel.classList.remove('launching');
753
+
754
+ // Re-enable launch button
755
+ launchButton.disabled = false;
756
+ launchButton.classList.remove('bg-gray-600', 'cursor-not-allowed');
757
+ launchButton.classList.add('bg-green-600', 'hover:bg-green-700');
758
+
759
+ // Update UI
760
+ updateUI();
761
+ }
762
+
763
+ // Initialize the game when DOM is loaded
764
+ document.addEventListener('DOMContentLoaded', initGame);
765
+ </script>
766
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=jamesbright/spacex-simulator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
767
+ </html>