Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +1008 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 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: deejay-space
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: blue
|
| 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,1008 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Galaxy Explorer - Space Adventure Game</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 8 |
+
<style>
|
| 9 |
+
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Orbitron:wght@400;700&display=swap');
|
| 10 |
+
|
| 11 |
+
* {
|
| 12 |
+
margin: 0;
|
| 13 |
+
padding: 0;
|
| 14 |
+
box-sizing: border-box;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
body {
|
| 18 |
+
background-color: #0f0f1a;
|
| 19 |
+
overflow: hidden;
|
| 20 |
+
font-family: 'Orbitron', sans-serif;
|
| 21 |
+
color: white;
|
| 22 |
+
height: 100vh;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
#game-container {
|
| 26 |
+
position: relative;
|
| 27 |
+
width: 100%;
|
| 28 |
+
height: 100%;
|
| 29 |
+
background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
#start-screen {
|
| 33 |
+
position: absolute;
|
| 34 |
+
top: 0;
|
| 35 |
+
left: 0;
|
| 36 |
+
width: 100%;
|
| 37 |
+
height: 100%;
|
| 38 |
+
display: flex;
|
| 39 |
+
flex-direction: column;
|
| 40 |
+
justify-content: center;
|
| 41 |
+
align-items: center;
|
| 42 |
+
background: rgba(0, 0, 0, 0.6);
|
| 43 |
+
z-index: 10;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
#game-screen {
|
| 47 |
+
display: none;
|
| 48 |
+
width: 100%;
|
| 49 |
+
height: 100%;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
#game-over-screen {
|
| 53 |
+
position: absolute;
|
| 54 |
+
top: 0;
|
| 55 |
+
left: 0;
|
| 56 |
+
width: 100%;
|
| 57 |
+
height: 100%;
|
| 58 |
+
display: none;
|
| 59 |
+
flex-direction: column;
|
| 60 |
+
justify-content: center;
|
| 61 |
+
align-items: center;
|
| 62 |
+
background: rgba(0, 0, 0, 0.8);
|
| 63 |
+
z-index: 10;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.title {
|
| 67 |
+
font-family: 'Press Start 2P', cursive;
|
| 68 |
+
font-size: 3rem;
|
| 69 |
+
margin-bottom: 2rem;
|
| 70 |
+
text-align: center;
|
| 71 |
+
color: transparent;
|
| 72 |
+
background: linear-gradient(45deg, #ff00cc, #3333ff, #00ccff, #ffcc00);
|
| 73 |
+
-webkit-background-clip: text;
|
| 74 |
+
background-clip: text;
|
| 75 |
+
animation: rainbow 5s linear infinite;
|
| 76 |
+
text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
@keyframes rainbow {
|
| 80 |
+
0% { background-position: 0% 50%; }
|
| 81 |
+
100% { background-position: 100% 50%; }
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.subtitle {
|
| 85 |
+
font-size: 1.2rem;
|
| 86 |
+
margin-bottom: 2rem;
|
| 87 |
+
color: #a9a9ff;
|
| 88 |
+
text-align: center;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.score {
|
| 92 |
+
font-size: 1.5rem;
|
| 93 |
+
margin: 1rem 0;
|
| 94 |
+
color: #00ffcc;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.high-score {
|
| 98 |
+
font-size: 1.3rem;
|
| 99 |
+
margin-bottom: 2rem;
|
| 100 |
+
color: #ffcc00;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
button {
|
| 104 |
+
background: linear-gradient(45deg, #00ccff, #9933ff);
|
| 105 |
+
border: none;
|
| 106 |
+
color: white;
|
| 107 |
+
padding: 15px 30px;
|
| 108 |
+
font-size: 1.2rem;
|
| 109 |
+
font-family: 'Orbitron', sans-serif;
|
| 110 |
+
border-radius: 50px;
|
| 111 |
+
cursor: pointer;
|
| 112 |
+
margin: 10px;
|
| 113 |
+
box-shadow: 0 0 15px rgba(0, 204, 255, 0.5);
|
| 114 |
+
transition: all 0.3s ease;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
button:hover {
|
| 118 |
+
transform: scale(1.05);
|
| 119 |
+
box-shadow: 0 0 20px rgba(0, 204, 255, 0.8);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
#player {
|
| 123 |
+
position: absolute;
|
| 124 |
+
width: 50px;
|
| 125 |
+
height: 50px;
|
| 126 |
+
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="%2300ccff" d="M24,4 L36,20 L30,20 L30,44 L18,44 L18,20 L12,20 Z"/><path fill="%239933ff" d="M24,4 L12,20 L18,20 L18,44 L30,44 L30,20 L36,20 Z"/><circle cx="24" cy="15" r="5" fill="%23ffcc00"/></svg>') no-repeat center center;
|
| 127 |
+
background-size: contain;
|
| 128 |
+
z-index: 5;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.asteroid {
|
| 132 |
+
position: absolute;
|
| 133 |
+
width: 40px;
|
| 134 |
+
height: 40px;
|
| 135 |
+
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="%23ff5555" d="M24,2 C32,5 42,8 46,16 C50,24 48,34 42,40 C36,46 26,48 18,44 C10,40 2,32 2,24 C2,16 10,10 16,6 C18,4 22,2 24,2 Z"/></svg>') no-repeat center center;
|
| 136 |
+
background-size: contain;
|
| 137 |
+
z-index: 4;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.star {
|
| 141 |
+
position: absolute;
|
| 142 |
+
width: 30px;
|
| 143 |
+
height: 30px;
|
| 144 |
+
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="%23ffcc00" d="M24,2 L30,18 L46,18 L34,28 L40,44 L24,34 L8,44 L14,28 L2,18 L18,18 Z"/></svg>') no-repeat center center;
|
| 145 |
+
background-size: contain;
|
| 146 |
+
z-index: 3;
|
| 147 |
+
animation: pulse 1.5s infinite alternate;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
@keyframes pulse {
|
| 151 |
+
from { transform: scale(1); opacity: 0.8; }
|
| 152 |
+
to { transform: scale(1.2); opacity: 1; }
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.particle {
|
| 156 |
+
position: absolute;
|
| 157 |
+
width: 5px;
|
| 158 |
+
height: 5px;
|
| 159 |
+
background-color: rgba(255, 255, 255, 0.7);
|
| 160 |
+
border-radius: 50%;
|
| 161 |
+
z-index: 2;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
#hud {
|
| 165 |
+
position: absolute;
|
| 166 |
+
top: 20px;
|
| 167 |
+
left: 20px;
|
| 168 |
+
font-size: 1.2rem;
|
| 169 |
+
color: #00ffcc;
|
| 170 |
+
z-index: 6;
|
| 171 |
+
display: flex;
|
| 172 |
+
align-items: center;
|
| 173 |
+
text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
#hud span {
|
| 177 |
+
margin-right: 20px;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
#hud i {
|
| 181 |
+
margin-right: 5px;
|
| 182 |
+
color: #ffcc00;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
#controls {
|
| 186 |
+
position: absolute;
|
| 187 |
+
bottom: 20px;
|
| 188 |
+
left: 0;
|
| 189 |
+
right: 0;
|
| 190 |
+
display: flex;
|
| 191 |
+
justify-content: center;
|
| 192 |
+
z-index: 6;
|
| 193 |
+
color: #a9a9ff;
|
| 194 |
+
font-size: 0.9rem;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
#controls div {
|
| 198 |
+
margin: 0 15px;
|
| 199 |
+
display: flex;
|
| 200 |
+
align-items: center;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
#controls i {
|
| 204 |
+
margin-right: 5px;
|
| 205 |
+
font-size: 1.2rem;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.explosion {
|
| 209 |
+
position: absolute;
|
| 210 |
+
width: 60px;
|
| 211 |
+
height: 60px;
|
| 212 |
+
background: radial-gradient(circle, rgba(255, 100, 100, 0.8) 0%, rgba(255, 200, 100, 0.5) 70%, transparent 100%);
|
| 213 |
+
border-radius: 50%;
|
| 214 |
+
z-index: 7;
|
| 215 |
+
animation: explode 0.5s ease-out;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
@keyframes explode {
|
| 219 |
+
0% { transform: scale(0); opacity: 1; }
|
| 220 |
+
100% { transform: scale(2); opacity: 0; }
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
#stars-bg {
|
| 224 |
+
position: absolute;
|
| 225 |
+
top: 0;
|
| 226 |
+
left: 0;
|
| 227 |
+
width: 100%;
|
| 228 |
+
height: 100%;
|
| 229 |
+
z-index: 1;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.moving-stars {
|
| 233 |
+
position: absolute;
|
| 234 |
+
width: 2px;
|
| 235 |
+
height: 2px;
|
| 236 |
+
background-color: white;
|
| 237 |
+
border-radius: 50%;
|
| 238 |
+
z-index: 1;
|
| 239 |
+
animation: starMove linear infinite;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
@keyframes starMove {
|
| 243 |
+
0% { transform: translateY(0); opacity: 0; }
|
| 244 |
+
10% { opacity: 1; }
|
| 245 |
+
90% { opacity: 1; }
|
| 246 |
+
100% { transform: translateY(100vh); opacity: 0; }
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.power-up {
|
| 250 |
+
position: absolute;
|
| 251 |
+
width: 30px;
|
| 252 |
+
height: 30px;
|
| 253 |
+
border-radius: 50%;
|
| 254 |
+
background: radial-gradient(circle, #00ffcc, #00aaff);
|
| 255 |
+
box-shadow: 0 0 10px #00ffcc;
|
| 256 |
+
z-index: 4;
|
| 257 |
+
animation: float 3s ease-in-out infinite;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
@keyframes float {
|
| 261 |
+
0% { transform: translateY(0); }
|
| 262 |
+
50% { transform: translateY(-10px); }
|
| 263 |
+
100% { transform: translateY(0); }
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
#shield {
|
| 267 |
+
position: absolute;
|
| 268 |
+
width: 70px;
|
| 269 |
+
height: 70px;
|
| 270 |
+
border-radius: 50%;
|
| 271 |
+
border: 3px dashed rgba(0, 255, 255, 0.5);
|
| 272 |
+
z-index: 4;
|
| 273 |
+
pointer-events: none;
|
| 274 |
+
display: none;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
.instructions {
|
| 278 |
+
background: rgba(0, 0, 0, 0.7);
|
| 279 |
+
padding: 20px;
|
| 280 |
+
border-radius: 10px;
|
| 281 |
+
margin-top: 20px;
|
| 282 |
+
max-width: 500px;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
.instructions p {
|
| 286 |
+
margin-bottom: 10px;
|
| 287 |
+
color: #a9a9ff;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.instructions ul {
|
| 291 |
+
margin-left: 20px;
|
| 292 |
+
margin-bottom: 15px;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.instructions li {
|
| 296 |
+
margin-bottom: 5px;
|
| 297 |
+
color: #a9a9ff;
|
| 298 |
+
}
|
| 299 |
+
</style>
|
| 300 |
+
</head>
|
| 301 |
+
<body>
|
| 302 |
+
<div id="game-container">
|
| 303 |
+
<div id="stars-bg"></div>
|
| 304 |
+
|
| 305 |
+
<div id="start-screen">
|
| 306 |
+
<h1 class="title">GALAXY EXPLORER</h1>
|
| 307 |
+
<p class="subtitle">Navigate through space, collect stars, and avoid asteroids!</p>
|
| 308 |
+
<button id="start-button">START ADVENTURE</button>
|
| 309 |
+
|
| 310 |
+
<div class="instructions">
|
| 311 |
+
<p><i class="fas fa-info-circle"></i> How to play:</p>
|
| 312 |
+
<ul>
|
| 313 |
+
<li>Use arrow keys or WASD to move your spaceship</li>
|
| 314 |
+
<li>Collect stars (★) to increase your score</li>
|
| 315 |
+
<li>Avoid asteroids (●) - they reduce your health</li>
|
| 316 |
+
<li>Collect power-ups (⦿) for special abilities</li>
|
| 317 |
+
<li>Survive as long as you can!</li>
|
| 318 |
+
</ul>
|
| 319 |
+
<p>Good luck, space explorer!</p>
|
| 320 |
+
</div>
|
| 321 |
+
</div>
|
| 322 |
+
|
| 323 |
+
<div id="game-screen">
|
| 324 |
+
<div id="player"></div>
|
| 325 |
+
<div id="shield"></div>
|
| 326 |
+
<div id="hud">
|
| 327 |
+
<span><i class="fas fa-heart"></i> <span id="health">100</span>%</span>
|
| 328 |
+
<span><i class="fas fa-star"></i> <span id="score">0</span></span>
|
| 329 |
+
<span><i class="fas fa-shield-alt"></i> <span id="shield-time">0</span>s</span>
|
| 330 |
+
</div>
|
| 331 |
+
</div>
|
| 332 |
+
|
| 333 |
+
<div id="game-over-screen">
|
| 334 |
+
<h1 class="title">GAME OVER</h1>
|
| 335 |
+
<p class="subtitle">Your spaceship couldn't survive the asteroid field!</p>
|
| 336 |
+
<p class="score">FINAL SCORE: <span id="final-score">0</span></p>
|
| 337 |
+
<p class="high-score">HIGH SCORE: <span id="high-score">0</span></p>
|
| 338 |
+
<button id="restart-button"><i class="fas fa-redo"></i> TRY AGAIN</button>
|
| 339 |
+
</div>
|
| 340 |
+
|
| 341 |
+
<div id="controls">
|
| 342 |
+
<div><i class="fas fa-arrow-up"></i> Move Up</div>
|
| 343 |
+
<div><i class="fas fa-arrow-left"></i> Move Left</div>
|
| 344 |
+
<div><i class="fas fa-arrow-right"></i> Move Right</div>
|
| 345 |
+
<div><i class="fas fa-arrow-down"></i> Move Down</div>
|
| 346 |
+
</div>
|
| 347 |
+
</div>
|
| 348 |
+
|
| 349 |
+
<script>
|
| 350 |
+
// Game variables
|
| 351 |
+
let gameActive = false;
|
| 352 |
+
let score = 0;
|
| 353 |
+
let health = 100;
|
| 354 |
+
let highScore = localStorage.getItem('galaxyExplorerHighScore') || 0;
|
| 355 |
+
let shieldActive = false;
|
| 356 |
+
let shieldTime = 0;
|
| 357 |
+
let starsCollected = 0;
|
| 358 |
+
|
| 359 |
+
// DOM elements
|
| 360 |
+
const gameContainer = document.getElementById('game-container');
|
| 361 |
+
const startScreen = document.getElementById('start-screen');
|
| 362 |
+
const gameScreen = document.getElementById('game-screen');
|
| 363 |
+
const gameOverScreen = document.getElementById('game-over-screen');
|
| 364 |
+
const player = document.getElementById('player');
|
| 365 |
+
const shield = document.getElementById('shield');
|
| 366 |
+
const healthDisplay = document.getElementById('health');
|
| 367 |
+
const scoreDisplay = document.getElementById('score');
|
| 368 |
+
const shieldTimeDisplay = document.getElementById('shield-time');
|
| 369 |
+
const finalScoreDisplay = document.getElementById('final-score');
|
| 370 |
+
const highScoreDisplay = document.getElementById('high-score');
|
| 371 |
+
const startButton = document.getElementById('start-button');
|
| 372 |
+
const restartButton = document.getElementById('restart-button');
|
| 373 |
+
const starsBg = document.getElementById('stars-bg');
|
| 374 |
+
const controls = document.getElementById('controls');
|
| 375 |
+
|
| 376 |
+
// Player properties
|
| 377 |
+
let playerX = 0;
|
| 378 |
+
let playerY = 0;
|
| 379 |
+
const playerSpeed = 5;
|
| 380 |
+
const playerWidth = 50;
|
| 381 |
+
const playerHeight = 50;
|
| 382 |
+
|
| 383 |
+
// Game objects
|
| 384 |
+
let asteroids = [];
|
| 385 |
+
let stars = [];
|
| 386 |
+
let particles = [];
|
| 387 |
+
let powerUps = [];
|
| 388 |
+
|
| 389 |
+
// Key states
|
| 390 |
+
const keys = {
|
| 391 |
+
ArrowUp: false,
|
| 392 |
+
ArrowDown: false,
|
| 393 |
+
ArrowLeft: false,
|
| 394 |
+
ArrowRight: false,
|
| 395 |
+
w: false,
|
| 396 |
+
a: false,
|
| 397 |
+
s: false,
|
| 398 |
+
d: false
|
| 399 |
+
};
|
| 400 |
+
|
| 401 |
+
// Create background stars
|
| 402 |
+
function createBackgroundStars() {
|
| 403 |
+
for (let i = 0; i < 100; i++) {
|
| 404 |
+
const star = document.createElement('div');
|
| 405 |
+
star.className = 'moving-stars';
|
| 406 |
+
star.style.left = `${Math.random() * 100}%`;
|
| 407 |
+
star.style.top = `${Math.random() * 100}%`;
|
| 408 |
+
star.style.width = `${Math.random() * 3 + 1}px`;
|
| 409 |
+
star.style.height = star.style.width;
|
| 410 |
+
star.style.animationDuration = `${Math.random() * 5 + 3}s`;
|
| 411 |
+
star.style.animationDelay = `${Math.random() * 5}s`;
|
| 412 |
+
starsBg.appendChild(star);
|
| 413 |
+
}
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
// Initialize game
|
| 417 |
+
function initGame() {
|
| 418 |
+
// Reset values
|
| 419 |
+
score = 0;
|
| 420 |
+
health = 100;
|
| 421 |
+
shieldActive = false;
|
| 422 |
+
shieldTime = 0;
|
| 423 |
+
starsCollected = 0;
|
| 424 |
+
|
| 425 |
+
// Clear game objects
|
| 426 |
+
asteroids.forEach(asteroid => asteroid.element.remove());
|
| 427 |
+
stars.forEach(star => star.element.remove());
|
| 428 |
+
particles.forEach(particle => particle.element.remove());
|
| 429 |
+
powerUps.forEach(powerUp => powerUp.element.remove());
|
| 430 |
+
|
| 431 |
+
asteroids = [];
|
| 432 |
+
stars = [];
|
| 433 |
+
particles = [];
|
| 434 |
+
powerUps = [];
|
| 435 |
+
|
| 436 |
+
// Position player
|
| 437 |
+
playerX = gameContainer.clientWidth / 2 - playerWidth / 2;
|
| 438 |
+
playerY = gameContainer.clientHeight - playerHeight - 20;
|
| 439 |
+
player.style.left = `${playerX}px`;
|
| 440 |
+
player.style.top = `${playerY}px`;
|
| 441 |
+
|
| 442 |
+
// Hide shield
|
| 443 |
+
shield.style.display = 'none';
|
| 444 |
+
|
| 445 |
+
// Update HUD
|
| 446 |
+
updateHUD();
|
| 447 |
+
|
| 448 |
+
// Show controls for 5 seconds
|
| 449 |
+
controls.style.opacity = 1;
|
| 450 |
+
setTimeout(() => {
|
| 451 |
+
animateControlsOut();
|
| 452 |
+
}, 5000);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
function animateControlsOut() {
|
| 456 |
+
let opacity = 1;
|
| 457 |
+
const fadeOutInterval = setInterval(() => {
|
| 458 |
+
opacity -= 0.05;
|
| 459 |
+
controls.style.opacity = opacity;
|
| 460 |
+
if (opacity <= 0) {
|
| 461 |
+
clearInterval(fadeOutInterval);
|
| 462 |
+
controls.style.display = 'none';
|
| 463 |
+
}
|
| 464 |
+
}, 50);
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
// Start game
|
| 468 |
+
function startGame() {
|
| 469 |
+
gameActive = true;
|
| 470 |
+
startScreen.style.display = 'none';
|
| 471 |
+
gameOverScreen.style.display = 'none';
|
| 472 |
+
gameScreen.style.display = 'block';
|
| 473 |
+
|
| 474 |
+
initGame();
|
| 475 |
+
|
| 476 |
+
// Game loop
|
| 477 |
+
gameLoop();
|
| 478 |
+
|
| 479 |
+
// Spawn objects
|
| 480 |
+
setInterval(spawnAsteroid, 1500);
|
| 481 |
+
setInterval(spawnStar, 2000);
|
| 482 |
+
setInterval(spawnPowerUp, 10000);
|
| 483 |
+
|
| 484 |
+
// Shield timer
|
| 485 |
+
setInterval(updateShield, 1000);
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
// Game over
|
| 489 |
+
function endGame() {
|
| 490 |
+
gameActive = false;
|
| 491 |
+
gameOverScreen.style.display = 'flex';
|
| 492 |
+
finalScoreDisplay.textContent = score;
|
| 493 |
+
highScoreDisplay.textContent = highScore;
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
// Game loop
|
| 497 |
+
function gameLoop() {
|
| 498 |
+
if (!gameActive) return;
|
| 499 |
+
|
| 500 |
+
updatePlayer();
|
| 501 |
+
updateAsteroids();
|
| 502 |
+
updateStars();
|
| 503 |
+
updatePowerUps();
|
| 504 |
+
updateParticles();
|
| 505 |
+
|
| 506 |
+
checkCollisions();
|
| 507 |
+
|
| 508 |
+
requestAnimationFrame(gameLoop);
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
// Update player position
|
| 512 |
+
function updatePlayer() {
|
| 513 |
+
// Movement
|
| 514 |
+
if (keys.ArrowUp || keys.w) playerY -= playerSpeed;
|
| 515 |
+
if (keys.ArrowDown || keys.s) playerY += playerSpeed;
|
| 516 |
+
if (keys.ArrowLeft || keys.a) playerX -= playerSpeed;
|
| 517 |
+
if (keys.ArrowRight || keys.d) playerX += playerSpeed;
|
| 518 |
+
|
| 519 |
+
// Boundary checking
|
| 520 |
+
playerX = Math.max(0, Math.min(gameContainer.clientWidth - playerWidth, playerX));
|
| 521 |
+
playerY = Math.max(0, Math.min(gameContainer.clientHeight - playerHeight, playerY));
|
| 522 |
+
|
| 523 |
+
// Update position
|
| 524 |
+
player.style.left = `${playerX}px`;
|
| 525 |
+
player.style.top = `${playerY}px`;
|
| 526 |
+
|
| 527 |
+
// Update shield position
|
| 528 |
+
if (shieldActive) {
|
| 529 |
+
shield.style.left = `${playerX - 10}px`;
|
| 530 |
+
shield.style.top = `${playerY - 10}px`;
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
// Spawn asteroid
|
| 535 |
+
function spawnAsteroid() {
|
| 536 |
+
if (!gameActive) return;
|
| 537 |
+
|
| 538 |
+
const asteroid = document.createElement('div');
|
| 539 |
+
asteroid.className = 'asteroid';
|
| 540 |
+
|
| 541 |
+
// Random position at top of screen
|
| 542 |
+
const x = Math.random() * (gameContainer.clientWidth - 40);
|
| 543 |
+
const y = -40;
|
| 544 |
+
|
| 545 |
+
asteroid.style.left = `${x}px`;
|
| 546 |
+
asteroid.style.top = `${y}px`;
|
| 547 |
+
|
| 548 |
+
gameScreen.appendChild(asteroid);
|
| 549 |
+
|
| 550 |
+
// Random speed and rotation
|
| 551 |
+
const speed = Math.random() * 3 + 2;
|
| 552 |
+
const rotationSpeed = (Math.random() - 0.5) * 5;
|
| 553 |
+
let rotation = 0;
|
| 554 |
+
|
| 555 |
+
asteroids.push({
|
| 556 |
+
element: asteroid,
|
| 557 |
+
x, y,
|
| 558 |
+
speed,
|
| 559 |
+
rotationSpeed,
|
| 560 |
+
rotation,
|
| 561 |
+
width: 40,
|
| 562 |
+
height: 40
|
| 563 |
+
});
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
// Update asteroids
|
| 567 |
+
function updateAsteroids() {
|
| 568 |
+
asteroids.forEach(asteroid => {
|
| 569 |
+
asteroid.y += asteroid.speed;
|
| 570 |
+
asteroid.rotation += asteroid.rotationSpeed;
|
| 571 |
+
|
| 572 |
+
asteroid.element.style.top = `${asteroid.y}px`;
|
| 573 |
+
asteroid.element.style.transform = `rotate(${asteroid.rotation}deg)`;
|
| 574 |
+
|
| 575 |
+
// Remove if off screen
|
| 576 |
+
if (asteroid.y > gameContainer.clientHeight) {
|
| 577 |
+
asteroid.element.remove();
|
| 578 |
+
asteroids = asteroids.filter(a => a !== asteroid);
|
| 579 |
+
}
|
| 580 |
+
});
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
// Spawn star
|
| 584 |
+
function spawnStar() {
|
| 585 |
+
if (!gameActive || stars.length > 5) return;
|
| 586 |
+
|
| 587 |
+
const star = document.createElement('div');
|
| 588 |
+
star.className = 'star';
|
| 589 |
+
|
| 590 |
+
const x = Math.random() * (gameContainer.clientWidth - 30);
|
| 591 |
+
const y = Math.random() * (gameContainer.clientHeight - 100);
|
| 592 |
+
|
| 593 |
+
star.style.left = `${x}px`;
|
| 594 |
+
star.style.top = `${y}px`;
|
| 595 |
+
|
| 596 |
+
gameScreen.appendChild(star);
|
| 597 |
+
|
| 598 |
+
stars.push({
|
| 599 |
+
element: star,
|
| 600 |
+
x, y,
|
| 601 |
+
width: 30,
|
| 602 |
+
height: 30
|
| 603 |
+
});
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
// Update stars
|
| 607 |
+
function updateStars() {
|
| 608 |
+
stars.forEach(star => {
|
| 609 |
+
// Stars can move slowly
|
| 610 |
+
star.y += 0.2;
|
| 611 |
+
star.x += (Math.random() - 0.5) * 0.5;
|
| 612 |
+
|
| 613 |
+
star.element.style.top = `${star.y}px`;
|
| 614 |
+
star.element.style.left = `${star.x}px`;
|
| 615 |
+
|
| 616 |
+
// Wrap around screen
|
| 617 |
+
if (star.y > gameContainer.clientHeight) {
|
| 618 |
+
star.y = -30;
|
| 619 |
+
}
|
| 620 |
+
if (star.x > gameContainer.clientWidth) {
|
| 621 |
+
star.x = -30;
|
| 622 |
+
} else if (star.x < -30) {
|
| 623 |
+
star.x = gameContainer.clientWidth;
|
| 624 |
+
}
|
| 625 |
+
});
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
// Spawn power-up
|
| 629 |
+
function spawnPowerUp() {
|
| 630 |
+
if (!gameActive || powerUps.length > 0) return;
|
| 631 |
+
|
| 632 |
+
const powerUp = document.createElement('div');
|
| 633 |
+
powerUp.className = 'power-up';
|
| 634 |
+
|
| 635 |
+
// Add icon inside power-up
|
| 636 |
+
const powerUpTypes = ['shield', 'health', 'double-points'];
|
| 637 |
+
const type = powerUpTypes[Math.floor(Math.random() * powerUpTypes.length)];
|
| 638 |
+
|
| 639 |
+
const icon = document.createElement('i');
|
| 640 |
+
if (type === 'shield') {
|
| 641 |
+
icon.className = 'fas fa-shield-alt';
|
| 642 |
+
icon.style.color = '#00ffff';
|
| 643 |
+
} else if (type === 'health') {
|
| 644 |
+
icon.className = 'fas fa-heart';
|
| 645 |
+
icon.style.color = '#ff5555';
|
| 646 |
+
} else {
|
| 647 |
+
icon.className = 'fas fa-star';
|
| 648 |
+
icon.style.color = '#ffcc00';
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
+
powerUp.appendChild(icon);
|
| 652 |
+
|
| 653 |
+
const x = Math.random() * (gameContainer.clientWidth - 30);
|
| 654 |
+
const y = -30;
|
| 655 |
+
|
| 656 |
+
powerUp.style.left = `${x}px`;
|
| 657 |
+
powerUp.style.top = `${y}px`;
|
| 658 |
+
|
| 659 |
+
gameScreen.appendChild(powerUp);
|
| 660 |
+
|
| 661 |
+
powerUps.push({
|
| 662 |
+
element: powerUp,
|
| 663 |
+
x, y,
|
| 664 |
+
width: 30,
|
| 665 |
+
height: 30,
|
| 666 |
+
type
|
| 667 |
+
});
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
// Update power-ups
|
| 671 |
+
function updatePowerUps() {
|
| 672 |
+
powerUps.forEach(powerUp => {
|
| 673 |
+
powerUp.y += 2;
|
| 674 |
+
powerUp.element.style.top = `${powerUp.y}px`;
|
| 675 |
+
|
| 676 |
+
// Remove if off screen
|
| 677 |
+
if (powerUp.y > gameContainer.clientHeight) {
|
| 678 |
+
powerUp.element.remove();
|
| 679 |
+
powerUps = powerUps.filter(p => p !== powerUp);
|
| 680 |
+
}
|
| 681 |
+
});
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
// Check collisions
|
| 685 |
+
function checkCollisions() {
|
| 686 |
+
// Player with stars
|
| 687 |
+
stars.forEach(star => {
|
| 688 |
+
if (checkCollision(playerX, playerY, playerWidth, playerHeight,
|
| 689 |
+
star.x, star.y, star.width, star.height)) {
|
| 690 |
+
// Collect star
|
| 691 |
+
score += 10;
|
| 692 |
+
starsCollected++;
|
| 693 |
+
star.element.remove();
|
| 694 |
+
stars = stars.filter(s => s !== star);
|
| 695 |
+
|
| 696 |
+
// Create particles
|
| 697 |
+
createParticles(star.x + star.width/2, star.y + star.height/2, 10, '#ffcc00');
|
| 698 |
+
|
| 699 |
+
// Update HUD
|
| 700 |
+
updateHUD();
|
| 701 |
+
}
|
| 702 |
+
});
|
| 703 |
+
|
| 704 |
+
// Player with asteroids
|
| 705 |
+
asteroids.forEach(asteroid => {
|
| 706 |
+
if (checkCollision(playerX, playerY, playerWidth, playerHeight,
|
| 707 |
+
asteroid.x, asteroid.y, asteroid.width, asteroid.height)) {
|
| 708 |
+
if (shieldActive) {
|
| 709 |
+
// Shield protects from damage
|
| 710 |
+
asteroid.element.remove();
|
| 711 |
+
asteroids = asteroids.filter(a => a !== asteroid);
|
| 712 |
+
|
| 713 |
+
// Create explosion
|
| 714 |
+
createExplosion(asteroid.x + asteroid.width/2, asteroid.y + asteroid.height/2);
|
| 715 |
+
} else {
|
| 716 |
+
// Take damage
|
| 717 |
+
health -= 10;
|
| 718 |
+
|
| 719 |
+
// Create explosion
|
| 720 |
+
createExplosion(asteroid.x + asteroid.width/2, asteroid.y + asteroid.height/2);
|
| 721 |
+
|
| 722 |
+
// Remove asteroid
|
| 723 |
+
asteroid.element.remove();
|
| 724 |
+
asteroids = asteroids.filter(a => a !== asteroid);
|
| 725 |
+
|
| 726 |
+
// Shake player
|
| 727 |
+
player.style.transform = 'translateX(-5px)';
|
| 728 |
+
setTimeout(() => {
|
| 729 |
+
player.style.transform = 'translateX(5px)';
|
| 730 |
+
setTimeout(() => {
|
| 731 |
+
player.style.transform = 'translateX(0)';
|
| 732 |
+
}, 50);
|
| 733 |
+
}, 50);
|
| 734 |
+
|
| 735 |
+
// Check if game over
|
| 736 |
+
if (health <= 0) {
|
| 737 |
+
health = 0;
|
| 738 |
+
createExplosion(playerX + playerWidth/2, playerY + playerHeight/2, true);
|
| 739 |
+
setTimeout(endGame, 500);
|
| 740 |
+
}
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
// Update HUD
|
| 744 |
+
updateHUD();
|
| 745 |
+
}
|
| 746 |
+
});
|
| 747 |
+
|
| 748 |
+
// Player with power-ups
|
| 749 |
+
powerUps.forEach(powerUp => {
|
| 750 |
+
if (checkCollision(playerX, playerY, playerWidth, playerHeight,
|
| 751 |
+
powerUp.x, powerUp.y, powerUp.width, powerUp.height)) {
|
| 752 |
+
// Apply power-up effect
|
| 753 |
+
if (powerUp.type === 'shield') {
|
| 754 |
+
activateShield(15); // 15 seconds
|
| 755 |
+
} else if (powerUp.type === 'health') {
|
| 756 |
+
health = Math.min(100, health + 30);
|
| 757 |
+
} else {
|
| 758 |
+
score += 50;
|
| 759 |
+
}
|
| 760 |
+
|
| 761 |
+
// Create particles
|
| 762 |
+
createParticles(powerUp.x + powerUp.width/2, powerUp.y + powerUp.height/2, 15, '#00ffcc');
|
| 763 |
+
|
| 764 |
+
// Remove power-up
|
| 765 |
+
powerUp.element.remove();
|
| 766 |
+
powerUps = powerUps.filter(p => p !== powerUp);
|
| 767 |
+
|
| 768 |
+
// Update HUD
|
| 769 |
+
updateHUD();
|
| 770 |
+
}
|
| 771 |
+
});
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
// Check collision between two rectangles
|
| 775 |
+
function checkCollision(x1, y1, w1, h1, x2, y2, w2, h2) {
|
| 776 |
+
return x1 < x2 + w2 &&
|
| 777 |
+
x1 + w1 > x2 &&
|
| 778 |
+
y1 < y2 + h2 &&
|
| 779 |
+
y1 + h1 > y2;
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
// Create explosion effect
|
| 783 |
+
function createExplosion(x, y, isPlayer = false) {
|
| 784 |
+
const explosion = document.createElement('div');
|
| 785 |
+
explosion.className = 'explosion';
|
| 786 |
+
explosion.style.left = `${x - 30}px`;
|
| 787 |
+
explosion.style.top = `${y - 30}px`;
|
| 788 |
+
|
| 789 |
+
gameScreen.appendChild(explosion);
|
| 790 |
+
|
| 791 |
+
// Remove after animation
|
| 792 |
+
setTimeout(() => {
|
| 793 |
+
explosion.remove();
|
| 794 |
+
}, 500);
|
| 795 |
+
|
| 796 |
+
// Create particles for explosion
|
| 797 |
+
const particleCount = isPlayer ? 30 : 15;
|
| 798 |
+
const colors = isPlayer ? ['#ff5555', '#ffcc00', '#ffffff'] : ['#ff5555', '#ff9955'];
|
| 799 |
+
createParticles(x, y, particleCount, colors);
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
// Create particles
|
| 803 |
+
function createParticles(x, y, count, colors) {
|
| 804 |
+
// Convert single color to array if needed
|
| 805 |
+
if (typeof colors === 'string') {
|
| 806 |
+
colors = [colors];
|
| 807 |
+
}
|
| 808 |
+
|
| 809 |
+
for (let i = 0; i < count; i++) {
|
| 810 |
+
const particle = document.createElement('div');
|
| 811 |
+
particle.className = 'particle';
|
| 812 |
+
|
| 813 |
+
// Random color from options
|
| 814 |
+
const color = colors[Math.floor(Math.random() * colors.length)];
|
| 815 |
+
particle.style.backgroundColor = color;
|
| 816 |
+
|
| 817 |
+
// Random size
|
| 818 |
+
const size = Math.random() * 5 + 2;
|
| 819 |
+
particle.style.width = `${size}px`;
|
| 820 |
+
particle.style.height = `${size}px`;
|
| 821 |
+
|
| 822 |
+
// Random position around center
|
| 823 |
+
const angle = Math.random() * Math.PI * 2;
|
| 824 |
+
const distance = Math.random() * 30;
|
| 825 |
+
|
| 826 |
+
const particleX = x + Math.cos(angle) * distance;
|
| 827 |
+
const particleY = y + Math.sin(angle) * distance;
|
| 828 |
+
|
| 829 |
+
particle.style.left = `${particleX}px`;
|
| 830 |
+
particle.style.top = `${particleY}px`;
|
| 831 |
+
|
| 832 |
+
// Random velocity
|
| 833 |
+
const vx = (Math.random() - 0.5) * 5;
|
| 834 |
+
const vy = (Math.random() - 0.5) * 5 - 3;
|
| 835 |
+
|
| 836 |
+
gameScreen.appendChild(particle);
|
| 837 |
+
|
| 838 |
+
particles.push({
|
| 839 |
+
element: particle,
|
| 840 |
+
x: particleX,
|
| 841 |
+
y: particleY,
|
| 842 |
+
vx,
|
| 843 |
+
vy,
|
| 844 |
+
life: 100,
|
| 845 |
+
decay: Math.random() * 3 + 1
|
| 846 |
+
});
|
| 847 |
+
}
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
// Update particles
|
| 851 |
+
function updateParticles() {
|
| 852 |
+
particles.forEach(particle => {
|
| 853 |
+
particle.x += particle.vx;
|
| 854 |
+
particle.y += particle.vy;
|
| 855 |
+
particle.vy += 0.1; // Gravity
|
| 856 |
+
particle.life -= particle.decay;
|
| 857 |
+
|
| 858 |
+
particle.element.style.left = `${particle.x}px`;
|
| 859 |
+
particle.element.style.top = `${particle.y}px`;
|
| 860 |
+
particle.element.style.opacity = particle.life / 100;
|
| 861 |
+
|
| 862 |
+
// Remove if dead
|
| 863 |
+
if (particle.life <= 0) {
|
| 864 |
+
particle.element.remove();
|
| 865 |
+
particles = particles.filter(p => p !== particle);
|
| 866 |
+
}
|
| 867 |
+
});
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
// Activate shield
|
| 871 |
+
function activateShield(duration) {
|
| 872 |
+
shieldActive = true;
|
| 873 |
+
shieldTime = duration;
|
| 874 |
+
shield.style.display = 'block';
|
| 875 |
+
|
| 876 |
+
// Shield pulse effect
|
| 877 |
+
let pulseSize = 1;
|
| 878 |
+
const pulseInterval = setInterval(() => {
|
| 879 |
+
pulseSize = pulseSize === 1 ? 0.9 : 1;
|
| 880 |
+
shield.style.transform = `scale(${pulseSize})`;
|
| 881 |
+
}, 300);
|
| 882 |
+
|
| 883 |
+
// End shield when time is up
|
| 884 |
+
setTimeout(() => {
|
| 885 |
+
clearInterval(pulseInterval);
|
| 886 |
+
shieldActive = false;
|
| 887 |
+
shield.style.display = 'none';
|
| 888 |
+
}, duration * 1000);
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
+
// Update shield timer
|
| 892 |
+
function updateShield() {
|
| 893 |
+
if (shieldActive) {
|
| 894 |
+
shieldTime--;
|
| 895 |
+
if (shieldTime <= 0) {
|
| 896 |
+
shieldActive = false;
|
| 897 |
+
shield.style.display = 'none';
|
| 898 |
+
}
|
| 899 |
+
}
|
| 900 |
+
shieldTimeDisplay.textContent = shieldTime;
|
| 901 |
+
}
|
| 902 |
+
|
| 903 |
+
// Update HUD
|
| 904 |
+
function updateHUD() {
|
| 905 |
+
healthDisplay.textContent = health;
|
| 906 |
+
scoreDisplay.textContent = score;
|
| 907 |
+
shieldTimeDisplay.textContent = shieldTime;
|
| 908 |
+
|
| 909 |
+
// Update high score if needed
|
| 910 |
+
if (score > highScore) {
|
| 911 |
+
highScore = score;
|
| 912 |
+
localStorage.setItem('galaxyExplorerHighScore', highScore);
|
| 913 |
+
}
|
| 914 |
+
}
|
| 915 |
+
|
| 916 |
+
// Event listeners
|
| 917 |
+
startButton.addEventListener('click', startGame);
|
| 918 |
+
restartButton.addEventListener('click', startGame);
|
| 919 |
+
|
| 920 |
+
// Keyboard controls
|
| 921 |
+
document.addEventListener('keydown', (e) => {
|
| 922 |
+
if (keys.hasOwnProperty(e.key)) {
|
| 923 |
+
keys[e.key] = true;
|
| 924 |
+
|
| 925 |
+
// Show controls again if pressed
|
| 926 |
+
if (controls.style.display === 'none') {
|
| 927 |
+
controls.style.display = 'flex';
|
| 928 |
+
controls.style.opacity = 1;
|
| 929 |
+
setTimeout(() => {
|
| 930 |
+
animateControlsOut();
|
| 931 |
+
}, 3000);
|
| 932 |
+
}
|
| 933 |
+
}
|
| 934 |
+
});
|
| 935 |
+
|
| 936 |
+
document.addEventListener('keyup', (e) => {
|
| 937 |
+
if (keys.hasOwnProperty(e.key)) {
|
| 938 |
+
keys[e.key] = false;
|
| 939 |
+
}
|
| 940 |
+
});
|
| 941 |
+
|
| 942 |
+
// Touch controls for mobile
|
| 943 |
+
let touchStartX = 0;
|
| 944 |
+
let touchStartY = 0;
|
| 945 |
+
|
| 946 |
+
gameContainer.addEventListener('touchstart', (e) => {
|
| 947 |
+
touchStartX = e.touches[0].clientX;
|
| 948 |
+
touchStartY = e.touches[0].clientY;
|
| 949 |
+
|
| 950 |
+
// Show controls
|
| 951 |
+
controls.style.display = 'flex';
|
| 952 |
+
controls.style.opacity = 1;
|
| 953 |
+
setTimeout(() => {
|
| 954 |
+
animateControlsOut();
|
| 955 |
+
}, 3000);
|
| 956 |
+
}, false);
|
| 957 |
+
|
| 958 |
+
gameContainer.addEventListener('touchmove', (e) => {
|
| 959 |
+
if (!touchStartX || !touchStartY) return;
|
| 960 |
+
|
| 961 |
+
const touchEndX = e.touches[0].clientX;
|
| 962 |
+
const touchEndY = e.touches[0].clientY;
|
| 963 |
+
|
| 964 |
+
const dx = touchEndX - touchStartX;
|
| 965 |
+
const dy = touchEndY - touchStartY;
|
| 966 |
+
|
| 967 |
+
// Determine direction
|
| 968 |
+
if (Math.abs(dx) > Math.abs(dy)) {
|
| 969 |
+
// Horizontal movement
|
| 970 |
+
if (dx > 0) {
|
| 971 |
+
keys.ArrowRight = true;
|
| 972 |
+
keys.ArrowLeft = false;
|
| 973 |
+
} else {
|
| 974 |
+
keys.ArrowLeft = true;
|
| 975 |
+
keys.ArrowRight = false;
|
| 976 |
+
}
|
| 977 |
+
keys.ArrowUp = false;
|
| 978 |
+
keys.ArrowDown = false;
|
| 979 |
+
} else {
|
| 980 |
+
// Vertical movement
|
| 981 |
+
if (dy > 0) {
|
| 982 |
+
keys.ArrowDown = true;
|
| 983 |
+
keys.ArrowUp = false;
|
| 984 |
+
} else {
|
| 985 |
+
keys.ArrowUp = true;
|
| 986 |
+
keys.ArrowDown = false;
|
| 987 |
+
}
|
| 988 |
+
keys.ArrowLeft = false;
|
| 989 |
+
keys.ArrowRight = false;
|
| 990 |
+
}
|
| 991 |
+
|
| 992 |
+
e.preventDefault();
|
| 993 |
+
}, false);
|
| 994 |
+
|
| 995 |
+
gameContainer.addEventListener('touchend', () => {
|
| 996 |
+
keys.ArrowUp = false;
|
| 997 |
+
keys.ArrowDown = false;
|
| 998 |
+
keys.ArrowLeft = false;
|
| 999 |
+
keys.ArrowRight = false;
|
| 1000 |
+
touchStartX = 0;
|
| 1001 |
+
touchStartY = 0;
|
| 1002 |
+
}, false);
|
| 1003 |
+
|
| 1004 |
+
// Initialize background stars
|
| 1005 |
+
createBackgroundStars();
|
| 1006 |
+
</script>
|
| 1007 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: absolute; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">This website has been generated by <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
|
| 1008 |
+
</html>
|