Add 2 files
Browse files- README.md +7 -5
- index.html +1404 -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: alda
|
| 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,1404 @@
|
|
| 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>Super Mario Lite</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
|
| 10 |
+
|
| 11 |
+
body {
|
| 12 |
+
margin: 0;
|
| 13 |
+
padding: 0;
|
| 14 |
+
overflow: hidden;
|
| 15 |
+
font-family: 'Press Start 2P', cursive;
|
| 16 |
+
background-color: #6be0fd;
|
| 17 |
+
touch-action: manipulation;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
#game-container {
|
| 21 |
+
position: relative;
|
| 22 |
+
width: 100vw;
|
| 23 |
+
height: 100vh;
|
| 24 |
+
overflow: hidden;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
#game-canvas {
|
| 28 |
+
position: absolute;
|
| 29 |
+
top: 0;
|
| 30 |
+
left: 0;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
#start-screen, #game-over-screen, #win-screen {
|
| 34 |
+
position: absolute;
|
| 35 |
+
top: 0;
|
| 36 |
+
left: 0;
|
| 37 |
+
width: 100%;
|
| 38 |
+
height: 100%;
|
| 39 |
+
display: flex;
|
| 40 |
+
flex-direction: column;
|
| 41 |
+
justify-content: center;
|
| 42 |
+
align-items: center;
|
| 43 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 44 |
+
z-index: 10;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
#game-over-screen, #win-screen {
|
| 48 |
+
display: none;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.btn {
|
| 52 |
+
background-color: #e52521;
|
| 53 |
+
color: white;
|
| 54 |
+
border: none;
|
| 55 |
+
padding: 15px 30px;
|
| 56 |
+
font-size: 16px;
|
| 57 |
+
font-family: 'Press Start 2P', cursive;
|
| 58 |
+
cursor: pointer;
|
| 59 |
+
border-radius: 10px;
|
| 60 |
+
box-shadow: 0 5px 0 #81261f;
|
| 61 |
+
transition: all 0.1s;
|
| 62 |
+
margin-top: 20px;
|
| 63 |
+
letter-spacing: 1px;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.btn:active {
|
| 67 |
+
transform: translateY(5px);
|
| 68 |
+
box-shadow: 0 0 0 #81261f;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.title {
|
| 72 |
+
color: white;
|
| 73 |
+
font-size: 36px;
|
| 74 |
+
text-align: center;
|
| 75 |
+
text-shadow: 4px 4px 0 #e52521;
|
| 76 |
+
margin-bottom: 30px;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.score-display {
|
| 80 |
+
position: absolute;
|
| 81 |
+
top: 20px;
|
| 82 |
+
left: 20px;
|
| 83 |
+
color: white;
|
| 84 |
+
font-size: 18px;
|
| 85 |
+
text-shadow: 2px 2px 0 #000;
|
| 86 |
+
z-index: 5;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.time-display {
|
| 90 |
+
position: absolute;
|
| 91 |
+
top: 20px;
|
| 92 |
+
right: 20px;
|
| 93 |
+
color: white;
|
| 94 |
+
font-size: 18px;
|
| 95 |
+
text-shadow: 2px 2px 0 #000;
|
| 96 |
+
z-index: 5;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.ground {
|
| 100 |
+
position: absolute;
|
| 101 |
+
bottom: 0;
|
| 102 |
+
width: 300%;
|
| 103 |
+
height: 60px;
|
| 104 |
+
background-color: #56b949;
|
| 105 |
+
z-index: 2;
|
| 106 |
+
background-image:
|
| 107 |
+
linear-gradient(transparent 95%, #3a7d33 95%),
|
| 108 |
+
linear-gradient(90deg, transparent 50%, #3a7d33 50%);
|
| 109 |
+
background-size: 20px 20px;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.brick {
|
| 113 |
+
position: absolute;
|
| 114 |
+
width: 40px;
|
| 115 |
+
height: 40px;
|
| 116 |
+
background-color: #b85a20;
|
| 117 |
+
border-radius: 3px;
|
| 118 |
+
border: 3px solid #8c3f10;
|
| 119 |
+
box-shadow: inset -3px -3px 0 rgba(0,0,0,0.2);
|
| 120 |
+
z-index: 2;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.coin {
|
| 124 |
+
position: absolute;
|
| 125 |
+
width: 20px;
|
| 126 |
+
height: 20px;
|
| 127 |
+
background-color: #f9d423;
|
| 128 |
+
border-radius: 50%;
|
| 129 |
+
border: 2px solid #e2b007;
|
| 130 |
+
box-shadow: 0 0 5px gold;
|
| 131 |
+
z-index: 2;
|
| 132 |
+
animation: coinSpin 1.5s infinite linear;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
@keyframes coinSpin {
|
| 136 |
+
0% { transform: rotateY(0); }
|
| 137 |
+
100% { transform: rotateY(360deg); }
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.mario {
|
| 141 |
+
position: absolute;
|
| 142 |
+
width: 40px;
|
| 143 |
+
height: 60px;
|
| 144 |
+
background-color: #e52521;
|
| 145 |
+
border-radius: 10px 10px 0 0;
|
| 146 |
+
z-index: 3;
|
| 147 |
+
transition: transform 0.1s;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
.mario::before {
|
| 151 |
+
content: "";
|
| 152 |
+
position: absolute;
|
| 153 |
+
top: -10px;
|
| 154 |
+
left: 5px;
|
| 155 |
+
width: 30px;
|
| 156 |
+
height: 15px;
|
| 157 |
+
background-color: #e52521;
|
| 158 |
+
border-radius: 50% 50% 0 0;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.mario::after {
|
| 162 |
+
content: "";
|
| 163 |
+
position: absolute;
|
| 164 |
+
top: -5px;
|
| 165 |
+
left: 10px;
|
| 166 |
+
width: 20px;
|
| 167 |
+
height: 10px;
|
| 168 |
+
background-color: #f3b9b8;
|
| 169 |
+
border-radius: 10px 10px 0 0;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.mario .cap {
|
| 173 |
+
position: absolute;
|
| 174 |
+
top: -15px;
|
| 175 |
+
left: 5px;
|
| 176 |
+
width: 30px;
|
| 177 |
+
height: 10px;
|
| 178 |
+
background-color: #1144ee;
|
| 179 |
+
border-radius: 5px 0 0 5px;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.mario .cap::before {
|
| 183 |
+
content: "";
|
| 184 |
+
position: absolute;
|
| 185 |
+
top: -5px;
|
| 186 |
+
left: 0;
|
| 187 |
+
width: 30px;
|
| 188 |
+
height: 5px;
|
| 189 |
+
background-color: #1144ee;
|
| 190 |
+
border-radius: 5px 5px 0 0;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
.mario .eyes {
|
| 194 |
+
position: absolute;
|
| 195 |
+
top: 0;
|
| 196 |
+
left: 10px;
|
| 197 |
+
width: 20px;
|
| 198 |
+
height: 5px;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.mario .eyes::before,
|
| 202 |
+
.mario .eyes::after {
|
| 203 |
+
content: "";
|
| 204 |
+
position: absolute;
|
| 205 |
+
width: 5px;
|
| 206 |
+
height: 5px;
|
| 207 |
+
background-color: #000;
|
| 208 |
+
border-radius: 50%;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
.mario .eyes::before {
|
| 212 |
+
left: 0;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.mario .eyes::after {
|
| 216 |
+
right: 0;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.mario .mustache {
|
| 220 |
+
position: absolute;
|
| 221 |
+
top: 5px;
|
| 222 |
+
left: 5px;
|
| 223 |
+
width: 30px;
|
| 224 |
+
height: 5px;
|
| 225 |
+
background-color: #4d2a1e;
|
| 226 |
+
border-radius: 5px;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
.mario .mustache::before,
|
| 230 |
+
.mario .mustache::after {
|
| 231 |
+
content: "";
|
| 232 |
+
position: absolute;
|
| 233 |
+
width: 5px;
|
| 234 |
+
height: 3px;
|
| 235 |
+
background-color: #4d2a1e;
|
| 236 |
+
border-radius: 50%;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.mario .mustache::before {
|
| 240 |
+
left: 0;
|
| 241 |
+
top: 2px;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.mario .mustache::after {
|
| 245 |
+
right: 0;
|
| 246 |
+
top: 2px;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.mario .torso {
|
| 250 |
+
position: absolute;
|
| 251 |
+
top: 20px;
|
| 252 |
+
left: 5px;
|
| 253 |
+
width: 30px;
|
| 254 |
+
height: 25px;
|
| 255 |
+
background-color: #e52521;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
.mario .overalls {
|
| 259 |
+
position: absolute;
|
| 260 |
+
top: 25px;
|
| 261 |
+
left: 0;
|
| 262 |
+
width: 40px;
|
| 263 |
+
height: 25px;
|
| 264 |
+
background-color: #1144ee;
|
| 265 |
+
border-radius: 0 0 5px 5px;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
.mario .overalls::before {
|
| 269 |
+
content: "";
|
| 270 |
+
position: absolute;
|
| 271 |
+
top: 0;
|
| 272 |
+
left: 15px;
|
| 273 |
+
width: 10px;
|
| 274 |
+
height: 10px;
|
| 275 |
+
background-color: #f3b9b8;
|
| 276 |
+
border-radius: 2px;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.mario .buttons {
|
| 280 |
+
position: absolute;
|
| 281 |
+
top: 30px;
|
| 282 |
+
left: 15px;
|
| 283 |
+
width: 10px;
|
| 284 |
+
height: 10px;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
.mario .buttons::before,
|
| 288 |
+
.mario .buttons::after {
|
| 289 |
+
content: "";
|
| 290 |
+
position: absolute;
|
| 291 |
+
width: 10px;
|
| 292 |
+
height: 2px;
|
| 293 |
+
background-color: gold;
|
| 294 |
+
border-radius: 2px;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.mario .buttons::before {
|
| 298 |
+
top: 0;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.mario .buttons::after {
|
| 302 |
+
top: 5px;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
.mario .arms {
|
| 306 |
+
position: absolute;
|
| 307 |
+
top: 25px;
|
| 308 |
+
left: 0;
|
| 309 |
+
width: 40px;
|
| 310 |
+
height: 10px;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
.mario .arms::before,
|
| 314 |
+
.mario .arms::after {
|
| 315 |
+
content: "";
|
| 316 |
+
position: absolute;
|
| 317 |
+
width: 5px;
|
| 318 |
+
height: 15px;
|
| 319 |
+
background-color: #e52521;
|
| 320 |
+
border-radius: 2px;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
.mario .arms::before {
|
| 324 |
+
left: 0;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
.mario .arms::after {
|
| 328 |
+
right: 0;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
.mario .legs {
|
| 332 |
+
position: absolute;
|
| 333 |
+
bottom: 0;
|
| 334 |
+
left: 5px;
|
| 335 |
+
width: 30px;
|
| 336 |
+
height: 15px;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
.mario .legs::before,
|
| 340 |
+
.mario .legs::after {
|
| 341 |
+
content: "";
|
| 342 |
+
position: absolute;
|
| 343 |
+
width: 10px;
|
| 344 |
+
height: 15px;
|
| 345 |
+
background-color: #1144ee;
|
| 346 |
+
border-radius: 0 0 2px 2px;
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
.mario .legs::before {
|
| 350 |
+
left: 0;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
.mario .legs::after {
|
| 354 |
+
right: 0;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
.enemy {
|
| 358 |
+
position: absolute;
|
| 359 |
+
width: 40px;
|
| 360 |
+
height: 40px;
|
| 361 |
+
background-color: #6abe30;
|
| 362 |
+
border-radius: 50%;
|
| 363 |
+
z-index: 2;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
.enemy::before {
|
| 367 |
+
content: "";
|
| 368 |
+
position: absolute;
|
| 369 |
+
top: 0;
|
| 370 |
+
left: 0;
|
| 371 |
+
width: 40px;
|
| 372 |
+
height: 20px;
|
| 373 |
+
background-color: #6abe30;
|
| 374 |
+
border-radius: 20px 20px 0 0;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
.enemy::after {
|
| 378 |
+
content: "";
|
| 379 |
+
position: absolute;
|
| 380 |
+
top: -3px;
|
| 381 |
+
left: 5px;
|
| 382 |
+
width: 30px;
|
| 383 |
+
height: 15px;
|
| 384 |
+
background-color: #8dce68;
|
| 385 |
+
border-radius: 15px 15px 0 0;
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
.enemy .eyes {
|
| 389 |
+
position: absolute;
|
| 390 |
+
top: 5px;
|
| 391 |
+
left: 10px;
|
| 392 |
+
width: 20px;
|
| 393 |
+
height: 5px;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
.enemy .eyes::before,
|
| 397 |
+
.enemy .eyes::after {
|
| 398 |
+
content: "";
|
| 399 |
+
position: absolute;
|
| 400 |
+
width: 5px;
|
| 401 |
+
height: 5px;
|
| 402 |
+
background-color: #000;
|
| 403 |
+
border-radius: 50%;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
.enemy .eyes::before {
|
| 407 |
+
left: 0;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
.enemy .eyes::after {
|
| 411 |
+
right: 0;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
.castle {
|
| 415 |
+
position: absolute;
|
| 416 |
+
width: 80px;
|
| 417 |
+
height: 120px;
|
| 418 |
+
background-color: #853a11;
|
| 419 |
+
z-index: 2;
|
| 420 |
+
border-radius: 10px 10px 0 0;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
.castle::before {
|
| 424 |
+
content: "";
|
| 425 |
+
position: absolute;
|
| 426 |
+
top: -20px;
|
| 427 |
+
left: 10px;
|
| 428 |
+
width: 60px;
|
| 429 |
+
height: 20px;
|
| 430 |
+
background-color: #853a11;
|
| 431 |
+
clip-path: polygon(0% 100%, 10% 0%, 20% 100%, 30% 0%, 40% 100%, 50% 0%, 60% 100%, 70% 0%, 80% 100%, 90% 0%, 100% 100%);
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
.castle .door {
|
| 435 |
+
position: absolute;
|
| 436 |
+
bottom: 0;
|
| 437 |
+
left: 20px;
|
| 438 |
+
width: 40px;
|
| 439 |
+
height: 60px;
|
| 440 |
+
background-color: #5a2a0c;
|
| 441 |
+
border-radius: 5px 5px 0 0;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
.castle .flag-pole {
|
| 445 |
+
position: absolute;
|
| 446 |
+
top: -40px;
|
| 447 |
+
left: 5px;
|
| 448 |
+
width: 3px;
|
| 449 |
+
height: 80px;
|
| 450 |
+
background-color: #fff;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
.castle .flag {
|
| 454 |
+
position: absolute;
|
| 455 |
+
top: -40px;
|
| 456 |
+
left: 8px;
|
| 457 |
+
width: 30px;
|
| 458 |
+
height: 20px;
|
| 459 |
+
background-color: #e52521;
|
| 460 |
+
clip-path: polygon(0% 0%, 80% 0%, 100% 50%, 80% 100%, 0% 100%);
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
.pipe {
|
| 464 |
+
position: absolute;
|
| 465 |
+
width: 60px;
|
| 466 |
+
height: 80px;
|
| 467 |
+
background-color: #379937;
|
| 468 |
+
z-index: 2;
|
| 469 |
+
border-radius: 5px 5px 0 0;
|
| 470 |
+
border: 4px solid #266926;
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
.cloud {
|
| 474 |
+
position: absolute;
|
| 475 |
+
background-color: white;
|
| 476 |
+
border-radius: 50%;
|
| 477 |
+
opacity: 0.9;
|
| 478 |
+
z-index: 0;
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
@keyframes jump {
|
| 482 |
+
0%, 100% { transform: translateY(0); }
|
| 483 |
+
50% { transform: translateY(-20px); }
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
.jumping {
|
| 487 |
+
animation: jump 0.5s ease;
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
.crouching {
|
| 491 |
+
transform: scaleY(0.9) translateY(10px);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
.sliding {
|
| 495 |
+
transform: translateX(-10px);
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
.small {
|
| 499 |
+
transform: scale(0.7);
|
| 500 |
+
height: 40px !important;
|
| 501 |
+
}
|
| 502 |
+
</style>
|
| 503 |
+
</head>
|
| 504 |
+
<body>
|
| 505 |
+
<div id="game-container">
|
| 506 |
+
<div class="score-display" id="score">SCORE: 0</div>
|
| 507 |
+
<div class="time-display" id="time">TIME: 300</div>
|
| 508 |
+
|
| 509 |
+
<div id="start-screen">
|
| 510 |
+
<h1 class="title">SUPER MARIO LITE</h1>
|
| 511 |
+
<button class="btn" id="start-btn">START GAME</button>
|
| 512 |
+
<div class="mt-8 text-white text-center text-sm">
|
| 513 |
+
<p>Arrow Keys to Move</p>
|
| 514 |
+
<p>Space to Jump</p>
|
| 515 |
+
<p>Collect Coins, Avoid Enemies</p>
|
| 516 |
+
</div>
|
| 517 |
+
</div>
|
| 518 |
+
|
| 519 |
+
<div id="game-over-screen">
|
| 520 |
+
<h1 class="title">GAME OVER</h1>
|
| 521 |
+
<div class="text-white text-center mb-6">
|
| 522 |
+
<p>SCORE: <span id="final-score">0</span></p>
|
| 523 |
+
<p>HIGH SCORE: <span id="high-score">0</span></p>
|
| 524 |
+
</div>
|
| 525 |
+
<button class="btn" id="restart-btn">PLAY AGAIN</button>
|
| 526 |
+
</div>
|
| 527 |
+
|
| 528 |
+
<div id="win-screen">
|
| 529 |
+
<h1 class="title">YOU WIN!</h1>
|
| 530 |
+
<div class="text-white text-center mb-6">
|
| 531 |
+
<p>SCORE: <span id="win-score">0</span></p>
|
| 532 |
+
<p>HIGH SCORE: <span id="win-high-score">0</span></p>
|
| 533 |
+
</div>
|
| 534 |
+
<button class="btn" id="win-restart-btn">PLAY AGAIN</button>
|
| 535 |
+
</div>
|
| 536 |
+
|
| 537 |
+
<div class="ground"></div>
|
| 538 |
+
</div>
|
| 539 |
+
|
| 540 |
+
<script>
|
| 541 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 542 |
+
const gameContainer = document.getElementById('game-container');
|
| 543 |
+
const startScreen = document.getElementById('start-screen');
|
| 544 |
+
const gameOverScreen = document.getElementById('game-over-screen');
|
| 545 |
+
const winScreen = document.getElementById('win-screen');
|
| 546 |
+
const startBtn = document.getElementById('start-btn');
|
| 547 |
+
const restartBtn = document.getElementById('restart-btn');
|
| 548 |
+
const winRestartBtn = document.getElementById('win-restart-btn');
|
| 549 |
+
const scoreDisplay = document.getElementById('score');
|
| 550 |
+
const timeDisplay = document.getElementById('time');
|
| 551 |
+
const finalScoreDisplay = document.getElementById('final-score');
|
| 552 |
+
const highScoreDisplay = document.getElementById('high-score');
|
| 553 |
+
const winScoreDisplay = document.getElementById('win-score');
|
| 554 |
+
const winHighScoreDisplay = document.getElementById('win-high-score');
|
| 555 |
+
|
| 556 |
+
let gameRunning = false;
|
| 557 |
+
let score = 0;
|
| 558 |
+
let highScore = localStorage.getItem('marioHighScore') || 0;
|
| 559 |
+
let time = 300;
|
| 560 |
+
let mario;
|
| 561 |
+
let ground;
|
| 562 |
+
let enemies = [];
|
| 563 |
+
let coins = [];
|
| 564 |
+
let bricks = [];
|
| 565 |
+
let pipes = [];
|
| 566 |
+
let clouds = [];
|
| 567 |
+
let castle = null;
|
| 568 |
+
let gravity = 0.5;
|
| 569 |
+
let jumpForce = -12;
|
| 570 |
+
let marioVelocityY = 0;
|
| 571 |
+
let marioPositionX = 100;
|
| 572 |
+
let marioPositionY = 300;
|
| 573 |
+
let marioDirection = 'right';
|
| 574 |
+
let isJumping = false;
|
| 575 |
+
let isCrouching = false;
|
| 576 |
+
let isSliding = false;
|
| 577 |
+
let isInvincible = false;
|
| 578 |
+
let gameSpeed = 3;
|
| 579 |
+
let cameraOffset = 0;
|
| 580 |
+
let lastTime = 0;
|
| 581 |
+
let gameLoopId;
|
| 582 |
+
let timeInterval;
|
| 583 |
+
let isAlive = true;
|
| 584 |
+
let levelComplete = false;
|
| 585 |
+
|
| 586 |
+
highScoreDisplay.textContent = highScore;
|
| 587 |
+
winHighScoreDisplay.textContent = highScore;
|
| 588 |
+
|
| 589 |
+
// Create Mario
|
| 590 |
+
function createMario() {
|
| 591 |
+
mario = document.createElement('div');
|
| 592 |
+
mario.className = 'mario';
|
| 593 |
+
mario.innerHTML = `
|
| 594 |
+
<div class="cap"></div>
|
| 595 |
+
<div class="eyes"></div>
|
| 596 |
+
<div class="mustache"></div>
|
| 597 |
+
<div class="torso"></div>
|
| 598 |
+
<div class="overalls"></div>
|
| 599 |
+
<div class="buttons"></div>
|
| 600 |
+
<div class="arms"></div>
|
| 601 |
+
<div class="legs"></div>
|
| 602 |
+
`;
|
| 603 |
+
mario.style.left = marioPositionX + 'px';
|
| 604 |
+
mario.style.bottom = marioPositionY + 'px';
|
| 605 |
+
gameContainer.appendChild(mario);
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
// Create ground
|
| 609 |
+
function createGround() {
|
| 610 |
+
ground = document.querySelector('.ground');
|
| 611 |
+
}
|
| 612 |
+
|
| 613 |
+
// Create enemies
|
| 614 |
+
function createEnemy(x, y) {
|
| 615 |
+
const enemy = document.createElement('div');
|
| 616 |
+
enemy.className = 'enemy';
|
| 617 |
+
enemy.innerHTML = `<div class="eyes"></div>`;
|
| 618 |
+
enemy.style.left = x + 'px';
|
| 619 |
+
enemy.style.bottom = y + 'px';
|
| 620 |
+
gameContainer.appendChild(enemy);
|
| 621 |
+
|
| 622 |
+
enemies.push({
|
| 623 |
+
element: enemy,
|
| 624 |
+
x: x,
|
| 625 |
+
y: y,
|
| 626 |
+
direction: -1,
|
| 627 |
+
speed: Math.random() * 1 + 1
|
| 628 |
+
});
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
// Create coins
|
| 632 |
+
function createCoin(x, y) {
|
| 633 |
+
const coin = document.createElement('div');
|
| 634 |
+
coin.className = 'coin';
|
| 635 |
+
coin.style.left = x + 'px';
|
| 636 |
+
coin.style.bottom = y + 'px';
|
| 637 |
+
gameContainer.appendChild(coin);
|
| 638 |
+
|
| 639 |
+
coins.push({
|
| 640 |
+
element: coin,
|
| 641 |
+
x: x,
|
| 642 |
+
y: y,
|
| 643 |
+
collected: false
|
| 644 |
+
});
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
// Create bricks
|
| 648 |
+
function createBrick(x, y, hasCoin = false) {
|
| 649 |
+
const brick = document.createElement('div');
|
| 650 |
+
brick.className = 'brick';
|
| 651 |
+
brick.style.left = x + 'px';
|
| 652 |
+
brick.style.bottom = y + 'px';
|
| 653 |
+
gameContainer.appendChild(brick);
|
| 654 |
+
|
| 655 |
+
bricks.push({
|
| 656 |
+
element: brick,
|
| 657 |
+
x: x,
|
| 658 |
+
y: y,
|
| 659 |
+
hasCoin: hasCoin,
|
| 660 |
+
hit: false
|
| 661 |
+
});
|
| 662 |
+
|
| 663 |
+
if (hasCoin) {
|
| 664 |
+
createCoin(x + 10, y + 45);
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
// Create pipes
|
| 669 |
+
function createPipe(x, y, height = 80) {
|
| 670 |
+
const pipe = document.createElement('div');
|
| 671 |
+
pipe.className = 'pipe';
|
| 672 |
+
pipe.style.left = x + 'px';
|
| 673 |
+
pipe.style.bottom = y + 'px';
|
| 674 |
+
pipe.style.height = height + 'px';
|
| 675 |
+
gameContainer.appendChild(pipe);
|
| 676 |
+
|
| 677 |
+
pipes.push({
|
| 678 |
+
element: pipe,
|
| 679 |
+
x: x,
|
| 680 |
+
y: y,
|
| 681 |
+
height: height
|
| 682 |
+
});
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
// Create clouds
|
| 686 |
+
function createCloud(x, y, size) {
|
| 687 |
+
const cloud = document.createElement('div');
|
| 688 |
+
cloud.className = 'cloud';
|
| 689 |
+
cloud.style.left = x + 'px';
|
| 690 |
+
cloud.style.bottom = y + 'px';
|
| 691 |
+
cloud.style.width = size + 'px';
|
| 692 |
+
cloud.style.height = size / 2 + 'px';
|
| 693 |
+
gameContainer.appendChild(cloud);
|
| 694 |
+
|
| 695 |
+
clouds.push({
|
| 696 |
+
element: cloud,
|
| 697 |
+
x: x,
|
| 698 |
+
y: y,
|
| 699 |
+
size: size
|
| 700 |
+
});
|
| 701 |
+
}
|
| 702 |
+
|
| 703 |
+
// Create castle
|
| 704 |
+
function createCastle(x) {
|
| 705 |
+
castle = document.createElement('div');
|
| 706 |
+
castle.className = 'castle';
|
| 707 |
+
castle.innerHTML = `
|
| 708 |
+
<div class="door"></div>
|
| 709 |
+
<div class="flag-pole"></div>
|
| 710 |
+
<div class="flag"></div>
|
| 711 |
+
`;
|
| 712 |
+
castle.style.left = x + 'px';
|
| 713 |
+
castle.style.bottom = '60px';
|
| 714 |
+
gameContainer.appendChild(castle);
|
| 715 |
+
|
| 716 |
+
return {
|
| 717 |
+
element: castle,
|
| 718 |
+
x: x
|
| 719 |
+
};
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
// Setup level
|
| 723 |
+
function setupLevel() {
|
| 724 |
+
// Clear existing elements
|
| 725 |
+
const existingEnemies = document.querySelectorAll('.enemy');
|
| 726 |
+
const existingCoins = document.querySelectorAll('.coin');
|
| 727 |
+
const existingBricks = document.querySelectorAll('.brick');
|
| 728 |
+
const existingPipes = document.querySelectorAll('.pipe');
|
| 729 |
+
const existingClouds = document.querySelectorAll('.cloud');
|
| 730 |
+
const existingCastle = document.querySelector('.castle');
|
| 731 |
+
|
| 732 |
+
existingEnemies.forEach(enemy => enemy.remove());
|
| 733 |
+
existingCoins.forEach(coin => coin.remove());
|
| 734 |
+
existingBricks.forEach(brick => brick.remove());
|
| 735 |
+
existingPipes.forEach(pipe => pipe.remove());
|
| 736 |
+
existingClouds.forEach(cloud => cloud.remove());
|
| 737 |
+
if (existingCastle) existingCastle.remove();
|
| 738 |
+
|
| 739 |
+
// Reset arrays
|
| 740 |
+
enemies = [];
|
| 741 |
+
coins = [];
|
| 742 |
+
bricks = [];
|
| 743 |
+
pipes = [];
|
| 744 |
+
clouds = [];
|
| 745 |
+
castle = null;
|
| 746 |
+
|
| 747 |
+
// Create game objects
|
| 748 |
+
// Ground is already created in HTML
|
| 749 |
+
|
| 750 |
+
// Clouds
|
| 751 |
+
createCloud(200, 400, 80);
|
| 752 |
+
createCloud(500, 350, 100);
|
| 753 |
+
createCloud(800, 450, 60);
|
| 754 |
+
|
| 755 |
+
// Bricks and coins
|
| 756 |
+
for (let i = 0; i < 5; i++) {
|
| 757 |
+
createBrick(300 + i * 50, 100, i % 2 === 0);
|
| 758 |
+
}
|
| 759 |
+
|
| 760 |
+
// Some standalone coins
|
| 761 |
+
createCoin(200, 150);
|
| 762 |
+
createCoin(250, 200);
|
| 763 |
+
createCoin(700, 150);
|
| 764 |
+
|
| 765 |
+
// Pipes
|
| 766 |
+
createPipe(400, 60, 100);
|
| 767 |
+
createPipe(600, 60, 80);
|
| 768 |
+
|
| 769 |
+
// Enemies
|
| 770 |
+
createEnemy(500, 60);
|
| 771 |
+
createEnemy(800, 60);
|
| 772 |
+
|
| 773 |
+
// Castle at the end
|
| 774 |
+
castle = createCastle(1200);
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
// Jump function
|
| 778 |
+
function jump() {
|
| 779 |
+
if (!isJumping && gameRunning && isAlive && !levelComplete) {
|
| 780 |
+
isJumping = true;
|
| 781 |
+
marioVelocityY = jumpForce;
|
| 782 |
+
mario.classList.add('jumping');
|
| 783 |
+
|
| 784 |
+
// Remove jumping class after animation
|
| 785 |
+
setTimeout(() => {
|
| 786 |
+
mario.classList.remove('jumping');
|
| 787 |
+
}, 500);
|
| 788 |
+
}
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
// Crouch function
|
| 792 |
+
function crouch() {
|
| 793 |
+
if (!isJumping && gameRunning && isAlive && !levelComplete) {
|
| 794 |
+
isCrouching = true;
|
| 795 |
+
mario.classList.add('crouching');
|
| 796 |
+
}
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
// Stop crouching
|
| 800 |
+
function stopCrouch() {
|
| 801 |
+
if (isCrouching) {
|
| 802 |
+
isCrouching = false;
|
| 803 |
+
mario.classList.remove('crouching');
|
| 804 |
+
}
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
// Slide function
|
| 808 |
+
function slide() {
|
| 809 |
+
if (!isSliding && gameRunning && isAlive && !levelComplete) {
|
| 810 |
+
isSliding = true;
|
| 811 |
+
mario.classList.add('sliding');
|
| 812 |
+
|
| 813 |
+
setTimeout(() => {
|
| 814 |
+
isSliding = false;
|
| 815 |
+
mario.classList.remove('sliding');
|
| 816 |
+
}, 200);
|
| 817 |
+
}
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
// Check collisions
|
| 821 |
+
function checkCollisions() {
|
| 822 |
+
// Mario's hitbox
|
| 823 |
+
const marioLeft = marioPositionX + 5;
|
| 824 |
+
const marioRight = marioPositionX + 35;
|
| 825 |
+
const marioTop = marioPositionY + 50;
|
| 826 |
+
const marioBottom = marioPositionY + 10;
|
| 827 |
+
|
| 828 |
+
// Ground collision
|
| 829 |
+
if (marioPositionY <= 60) {
|
| 830 |
+
marioPositionY = 60;
|
| 831 |
+
marioVelocityY = 0;
|
| 832 |
+
isJumping = false;
|
| 833 |
+
}
|
| 834 |
+
|
| 835 |
+
// Brick collisions
|
| 836 |
+
for (const brick of bricks) {
|
| 837 |
+
const brickLeft = brick.x;
|
| 838 |
+
const brickRight = brick.x + 40;
|
| 839 |
+
const brickTop = brick.y + 40;
|
| 840 |
+
const brickBottom = brick.y;
|
| 841 |
+
|
| 842 |
+
// Check if Mario is hitting the brick from below
|
| 843 |
+
if (marioRight > brickLeft &&
|
| 844 |
+
marioLeft < brickRight &&
|
| 845 |
+
marioBottom < brickTop &&
|
| 846 |
+
marioTop > brickBottom &&
|
| 847 |
+
marioVelocityY > 0) {
|
| 848 |
+
|
| 849 |
+
marioPositionY = brickBottom - 60;
|
| 850 |
+
marioVelocityY = 0;
|
| 851 |
+
isJumping = false;
|
| 852 |
+
|
| 853 |
+
if (!brick.hit && brick.hasCoin) {
|
| 854 |
+
// Hit a brick with coin
|
| 855 |
+
score += 100;
|
| 856 |
+
scoreDisplay.textContent = `SCORE: ${score}`;
|
| 857 |
+
brick.hit = true;
|
| 858 |
+
brick.element.classList.add('hit');
|
| 859 |
+
|
| 860 |
+
// Make coin jump out
|
| 861 |
+
for (const coin of coins) {
|
| 862 |
+
if (coin.x === brick.x + 10 && coin.y === brick.y + 45 && !coin.collected) {
|
| 863 |
+
coin.collected = true;
|
| 864 |
+
coin.element.style.display = 'none';
|
| 865 |
+
|
| 866 |
+
// Show collected effect
|
| 867 |
+
const effect = document.createElement('div');
|
| 868 |
+
effect.className = 'coin';
|
| 869 |
+
effect.style.left = (brick.x + 10) + 'px';
|
| 870 |
+
effect.style.bottom = (brick.y + 45) + 'px';
|
| 871 |
+
gameContainer.appendChild(effect);
|
| 872 |
+
|
| 873 |
+
// Animate coin
|
| 874 |
+
let effectY = brick.y + 45;
|
| 875 |
+
let effectVelocity = -10;
|
| 876 |
+
|
| 877 |
+
const animateCoin = () => {
|
| 878 |
+
effectY += effectVelocity;
|
| 879 |
+
effectVelocity += 0.5;
|
| 880 |
+
effect.style.bottom = effectY + 'px';
|
| 881 |
+
|
| 882 |
+
if (effectY < brick.y + 45 - 100 || effectY > brick.y + 45) {
|
| 883 |
+
effect.remove();
|
| 884 |
+
} else {
|
| 885 |
+
requestAnimationFrame(animateCoin);
|
| 886 |
+
}
|
| 887 |
+
};
|
| 888 |
+
|
| 889 |
+
animateCoin();
|
| 890 |
+
}
|
| 891 |
+
}
|
| 892 |
+
}
|
| 893 |
+
}
|
| 894 |
+
}
|
| 895 |
+
|
| 896 |
+
// Pipe collisions (stop walking through pipes)
|
| 897 |
+
for (const pipe of pipes) {
|
| 898 |
+
const pipeLeft = pipe.x;
|
| 899 |
+
const pipeRight = pipe.x + 60;
|
| 900 |
+
const pipeHeight = pipe.height;
|
| 901 |
+
|
| 902 |
+
if (marioRight > pipeLeft &&
|
| 903 |
+
marioLeft < pipeRight &&
|
| 904 |
+
marioPositionY < pipeHeight) {
|
| 905 |
+
|
| 906 |
+
// Stop Mario from moving left/right through pipe
|
| 907 |
+
if (marioDirection === 'right') {
|
| 908 |
+
marioPositionX = pipeLeft - 40;
|
| 909 |
+
} else {
|
| 910 |
+
marioPositionX = pipeRight + 5;
|
| 911 |
+
}
|
| 912 |
+
}
|
| 913 |
+
}
|
| 914 |
+
|
| 915 |
+
// Enemy collisions
|
| 916 |
+
if (!isInvincible) {
|
| 917 |
+
for (const enemy of enemies) {
|
| 918 |
+
const enemyLeft = enemy.x;
|
| 919 |
+
const enemyRight = enemy.x + 40;
|
| 920 |
+
const enemyTop = enemy.y + 40;
|
| 921 |
+
const enemyBottom = enemy.y;
|
| 922 |
+
|
| 923 |
+
// Check if Mario is landing on enemy
|
| 924 |
+
if (marioRight > enemyLeft &&
|
| 925 |
+
marioLeft < enemyRight &&
|
| 926 |
+
marioBottom < enemyTop &&
|
| 927 |
+
marioTop > enemyBottom) {
|
| 928 |
+
|
| 929 |
+
// If Mario is falling onto enemy from above
|
| 930 |
+
if (marioVelocityY > 0 && marioBottom < enemyTop + 20) {
|
| 931 |
+
enemy.element.remove();
|
| 932 |
+
enemies = enemies.filter(e => e !== enemy);
|
| 933 |
+
score += 200;
|
| 934 |
+
scoreDisplay.textContent = `SCORE: ${score}`;
|
| 935 |
+
|
| 936 |
+
// Bounce after stomping
|
| 937 |
+
marioVelocityY = jumpForce / 2;
|
| 938 |
+
isJumping = true;
|
| 939 |
+
} else {
|
| 940 |
+
// Mario gets hit by enemy
|
| 941 |
+
getHurt();
|
| 942 |
+
}
|
| 943 |
+
}
|
| 944 |
+
}
|
| 945 |
+
}
|
| 946 |
+
|
| 947 |
+
// Coin collection
|
| 948 |
+
for (const coin of coins) {
|
| 949 |
+
if (!coin.collected) {
|
| 950 |
+
const coinLeft = coin.x;
|
| 951 |
+
const coinRight = coin.x + 20;
|
| 952 |
+
const coinTop = coin.y + 20;
|
| 953 |
+
const coinBottom = coin.y;
|
| 954 |
+
|
| 955 |
+
if (marioRight > coinLeft &&
|
| 956 |
+
marioLeft < coinRight &&
|
| 957 |
+
marioBottom < coinTop &&
|
| 958 |
+
marioTop > coinBottom) {
|
| 959 |
+
|
| 960 |
+
coin.collected = true;
|
| 961 |
+
coin.element.remove();
|
| 962 |
+
score += 100;
|
| 963 |
+
scoreDisplay.textContent = `SCORE: ${score}`;
|
| 964 |
+
}
|
| 965 |
+
}
|
| 966 |
+
}
|
| 967 |
+
|
| 968 |
+
// Castle collision (level complete)
|
| 969 |
+
if (castle) {
|
| 970 |
+
const castleLeft = castle.x;
|
| 971 |
+
const castleRight = castle.x + 80;
|
| 972 |
+
|
| 973 |
+
if (marioRight > castleLeft && marioLeft < castleRight) {
|
| 974 |
+
completeLevel();
|
| 975 |
+
}
|
| 976 |
+
}
|
| 977 |
+
}
|
| 978 |
+
|
| 979 |
+
// Get hurt function
|
| 980 |
+
function getHurt() {
|
| 981 |
+
if (!isInvincible) {
|
| 982 |
+
isInvincible = true;
|
| 983 |
+
isAlive = false;
|
| 984 |
+
|
| 985 |
+
// Make Mario jump back
|
| 986 |
+
marioVelocityY = -10;
|
| 987 |
+
|
| 988 |
+
// Show hurt animation
|
| 989 |
+
mario.classList.add('small');
|
| 990 |
+
|
| 991 |
+
setTimeout(() => {
|
| 992 |
+
gameOver();
|
| 993 |
+
}, 1000);
|
| 994 |
+
}
|
| 995 |
+
}
|
| 996 |
+
|
| 997 |
+
// Complete level function
|
| 998 |
+
function completeLevel() {
|
| 999 |
+
levelComplete = true;
|
| 1000 |
+
gameRunning = false;
|
| 1001 |
+
|
| 1002 |
+
// Stop timers
|
| 1003 |
+
clearInterval(timeInterval);
|
| 1004 |
+
cancelAnimationFrame(gameLoopId);
|
| 1005 |
+
|
| 1006 |
+
// Calculate final score (bonus for time remaining)
|
| 1007 |
+
const timeBonus = Math.floor(time / 10) * 50;
|
| 1008 |
+
score += timeBonus;
|
| 1009 |
+
|
| 1010 |
+
// Update high score
|
| 1011 |
+
if (score > highScore) {
|
| 1012 |
+
highScore = score;
|
| 1013 |
+
localStorage.setItem('marioHighScore', highScore);
|
| 1014 |
+
}
|
| 1015 |
+
|
| 1016 |
+
winScoreDisplay.textContent = score;
|
| 1017 |
+
winHighScoreDisplay.textContent = highScore;
|
| 1018 |
+
|
| 1019 |
+
// Show win screen
|
| 1020 |
+
winScreen.style.display = 'flex';
|
| 1021 |
+
|
| 1022 |
+
// Fireworks celebration
|
| 1023 |
+
createFireworks();
|
| 1024 |
+
}
|
| 1025 |
+
|
| 1026 |
+
// Create fireworks effect
|
| 1027 |
+
function createFireworks() {
|
| 1028 |
+
const colors = ['#ff0000', '#ff9900', '#ffff00', '#33cc33', '#3399ff', '#cc66ff'];
|
| 1029 |
+
|
| 1030 |
+
for (let i = 0; i < 10; i++) {
|
| 1031 |
+
setTimeout(() => {
|
| 1032 |
+
const x = Math.random() * window.innerWidth;
|
| 1033 |
+
const y = Math.random() * window.innerHeight / 2;
|
| 1034 |
+
const color = colors[Math.floor(Math.random() * colors.length)];
|
| 1035 |
+
|
| 1036 |
+
const firework = document.createElement('div');
|
| 1037 |
+
firework.style.position = 'absolute';
|
| 1038 |
+
firework.style.left = x + 'px';
|
| 1039 |
+
firework.style.top = y + 'px';
|
| 1040 |
+
firework.style.width = '5px';
|
| 1041 |
+
firework.style.height = '5px';
|
| 1042 |
+
firework.style.backgroundColor = color;
|
| 1043 |
+
firework.style.borderRadius = '50%';
|
| 1044 |
+
firework.style.zIndex = '5';
|
| 1045 |
+
gameContainer.appendChild(firework);
|
| 1046 |
+
|
| 1047 |
+
// Animate firework
|
| 1048 |
+
let particles = [];
|
| 1049 |
+
for (let j = 0; j < 20; j++) {
|
| 1050 |
+
const particle = document.createElement('div');
|
| 1051 |
+
particle.style.position = 'absolute';
|
| 1052 |
+
particle.style.left = x + 'px';
|
| 1053 |
+
particle.style.top = y + 'px';
|
| 1054 |
+
particle.style.width = '3px';
|
| 1055 |
+
particle.style.height = '3px';
|
| 1056 |
+
particle.style.backgroundColor = color;
|
| 1057 |
+
particle.style.borderRadius = '50%';
|
| 1058 |
+
particle.style.zIndex = '5';
|
| 1059 |
+
gameContainer.appendChild(particle);
|
| 1060 |
+
|
| 1061 |
+
particles.push({
|
| 1062 |
+
element: particle,
|
| 1063 |
+
velocityX: (Math.random() - 0.5) * 8,
|
| 1064 |
+
velocityY: (Math.random() - 0.5) * 8
|
| 1065 |
+
});
|
| 1066 |
+
}
|
| 1067 |
+
|
| 1068 |
+
// Animate particles
|
| 1069 |
+
const animateParticles = () => {
|
| 1070 |
+
let allOut = true;
|
| 1071 |
+
|
| 1072 |
+
for (const particle of particles) {
|
| 1073 |
+
const rect = particle.element.getBoundingClientRect();
|
| 1074 |
+
|
| 1075 |
+
// Update position
|
| 1076 |
+
const currentLeft = parseFloat(particle.element.style.left);
|
| 1077 |
+
const currentTop = parseFloat(particle.element.style.top);
|
| 1078 |
+
|
| 1079 |
+
particle.element.style.left = (currentLeft + particle.velocityX) + 'px';
|
| 1080 |
+
particle.element.style.top = (currentTop + particle.velocityY) + 'px';
|
| 1081 |
+
|
| 1082 |
+
// Add gravity
|
| 1083 |
+
particle.velocityY += 0.2;
|
| 1084 |
+
|
| 1085 |
+
// Fade out
|
| 1086 |
+
const currentOpacity = parseFloat(particle.element.style.opacity || 1);
|
| 1087 |
+
particle.element.style.opacity = (currentOpacity - 0.03) + '';
|
| 1088 |
+
|
| 1089 |
+
// Check if still visible
|
| 1090 |
+
if (currentOpacity > 0 &&
|
| 1091 |
+
currentTop < window.innerHeight &&
|
| 1092 |
+
currentLeft < window.innerWidth &&
|
| 1093 |
+
currentLeft > 0) {
|
| 1094 |
+
allOut = false;
|
| 1095 |
+
}
|
| 1096 |
+
}
|
| 1097 |
+
|
| 1098 |
+
if (!allOut) {
|
| 1099 |
+
requestAnimationFrame(animateParticles);
|
| 1100 |
+
} else {
|
| 1101 |
+
// Remove particles
|
| 1102 |
+
firework.remove();
|
| 1103 |
+
for (const particle of particles) {
|
| 1104 |
+
particle.element.remove();
|
| 1105 |
+
}
|
| 1106 |
+
}
|
| 1107 |
+
};
|
| 1108 |
+
|
| 1109 |
+
animateParticles();
|
| 1110 |
+
|
| 1111 |
+
}, i * 300);
|
| 1112 |
+
}
|
| 1113 |
+
}
|
| 1114 |
+
|
| 1115 |
+
// Game over function
|
| 1116 |
+
function gameOver() {
|
| 1117 |
+
gameRunning = false;
|
| 1118 |
+
isAlive = false;
|
| 1119 |
+
|
| 1120 |
+
// Stop timers
|
| 1121 |
+
clearInterval(timeInterval);
|
| 1122 |
+
cancelAnimationFrame(gameLoopId);
|
| 1123 |
+
|
| 1124 |
+
// Update high score
|
| 1125 |
+
if (score > highScore) {
|
| 1126 |
+
highScore = score;
|
| 1127 |
+
localStorage.setItem('marioHighScore', highScore);
|
| 1128 |
+
highScoreDisplay.textContent = highScore;
|
| 1129 |
+
}
|
| 1130 |
+
|
| 1131 |
+
finalScoreDisplay.textContent = score;
|
| 1132 |
+
|
| 1133 |
+
// Show game over screen
|
| 1134 |
+
gameOverScreen.style.display = 'flex';
|
| 1135 |
+
}
|
| 1136 |
+
|
| 1137 |
+
// Timer countdown
|
| 1138 |
+
function startTimer() {
|
| 1139 |
+
time = 300;
|
| 1140 |
+
timeDisplay.textContent = `TIME: ${time}`;
|
| 1141 |
+
|
| 1142 |
+
timeInterval = setInterval(() => {
|
| 1143 |
+
if (gameRunning) {
|
| 1144 |
+
time--;
|
| 1145 |
+
timeDisplay.textContent = `TIME: ${time}`;
|
| 1146 |
+
|
| 1147 |
+
if (time <= 0) {
|
| 1148 |
+
gameOver();
|
| 1149 |
+
}
|
| 1150 |
+
}
|
| 1151 |
+
}, 1000);
|
| 1152 |
+
}
|
| 1153 |
+
|
| 1154 |
+
// Game loop
|
| 1155 |
+
function gameLoop(timestamp) {
|
| 1156 |
+
if (!gameRunning || !isAlive || levelComplete) return;
|
| 1157 |
+
|
| 1158 |
+
// Calculate delta time for smooth movement
|
| 1159 |
+
const deltaTime = timestamp - lastTime;
|
| 1160 |
+
lastTime = timestamp;
|
| 1161 |
+
|
| 1162 |
+
// Move Mario horizontally if arrow keys are pressed
|
| 1163 |
+
if (rightPressed && !levelComplete) {
|
| 1164 |
+
marioDirection = 'right';
|
| 1165 |
+
marioPositionX += gameSpeed;
|
| 1166 |
+
|
| 1167 |
+
// Camera follows Mario
|
| 1168 |
+
if (marioPositionX > window.innerWidth / 3) {
|
| 1169 |
+
cameraOffset = marioPositionX - window.innerWidth / 3;
|
| 1170 |
+
}
|
| 1171 |
+
} else if (leftPressed && marioPositionX > 0 && !levelComplete) {
|
| 1172 |
+
marioDirection = 'left';
|
| 1173 |
+
marioPositionX -= gameSpeed;
|
| 1174 |
+
|
| 1175 |
+
// Don't let Mario go back beyond camera
|
| 1176 |
+
if (marioPositionX < cameraOffset) {
|
| 1177 |
+
marioPositionX = cameraOffset;
|
| 1178 |
+
}
|
| 1179 |
+
}
|
| 1180 |
+
|
| 1181 |
+
// Apply gravity
|
| 1182 |
+
marioVelocityY += gravity;
|
| 1183 |
+
marioPositionY += marioVelocityY;
|
| 1184 |
+
|
| 1185 |
+
// Update Mario's position
|
| 1186 |
+
mario.style.left = (marioPositionX - cameraOffset) + 'px';
|
| 1187 |
+
mario.style.bottom = marioPositionY + 'px';
|
| 1188 |
+
|
| 1189 |
+
// Flip Mario based on direction
|
| 1190 |
+
if (marioDirection === 'left') {
|
| 1191 |
+
mario.style.transform = 'scaleX(-1)';
|
| 1192 |
+
} else {
|
| 1193 |
+
mario.style.transform = 'scaleX(1)';
|
| 1194 |
+
}
|
| 1195 |
+
|
| 1196 |
+
// Move enemies
|
| 1197 |
+
for (const enemy of enemies) {
|
| 1198 |
+
enemy.x += enemy.speed * enemy.direction;
|
| 1199 |
+
enemy.element.style.left = (enemy.x - cameraOffset) + 'px';
|
| 1200 |
+
|
| 1201 |
+
// Simple AI - turn around at edges or when hitting another enemy
|
| 1202 |
+
if (enemy.x - cameraOffset < 0 || enemy.x - cameraOffset > window.innerWidth - 40) {
|
| 1203 |
+
enemy.direction *= -1;
|
| 1204 |
+
}
|
| 1205 |
+
|
| 1206 |
+
// Check if enemy falls off platform
|
| 1207 |
+
let hasGround = false;
|
| 1208 |
+
|
| 1209 |
+
// Check if there's ground below
|
| 1210 |
+
if (enemy.y === 60) {
|
| 1211 |
+
hasGround = true;
|
| 1212 |
+
} else {
|
| 1213 |
+
// Check if standing on brick
|
| 1214 |
+
for (const brick of bricks) {
|
| 1215 |
+
const brickLeft = brick.x;
|
| 1216 |
+
const brickRight = brick.x + 40;
|
| 1217 |
+
const brickTop = brick.y + 40;
|
| 1218 |
+
|
| 1219 |
+
if (enemy.x + 20 > brickLeft &&
|
| 1220 |
+
enemy.x + 20 < brickRight &&
|
| 1221 |
+
enemy.y + 40 >= brickTop &&
|
| 1222 |
+
enemy.y + 40 <= brickTop + 20) {
|
| 1223 |
+
hasGround = true;
|
| 1224 |
+
break;
|
| 1225 |
+
}
|
| 1226 |
+
}
|
| 1227 |
+
}
|
| 1228 |
+
|
| 1229 |
+
if (!hasGround) {
|
| 1230 |
+
enemy.direction *= -1;
|
| 1231 |
+
}
|
| 1232 |
+
}
|
| 1233 |
+
|
| 1234 |
+
// Move clouds
|
| 1235 |
+
for (const cloud of clouds) {
|
| 1236 |
+
cloud.x -= 0.5;
|
| 1237 |
+
cloud.element.style.left = (cloud.x - cameraOffset) + 'px';
|
| 1238 |
+
|
| 1239 |
+
// Reset cloud when off screen
|
| 1240 |
+
if (cloud.x - cameraOffset < -cloud.size) {
|
| 1241 |
+
cloud.x = window.innerWidth + cameraOffset;
|
| 1242 |
+
}
|
| 1243 |
+
}
|
| 1244 |
+
|
| 1245 |
+
// Move ground (parallax effect)
|
| 1246 |
+
ground.style.transform = `translateX(-${cameraOffset * 0.7}px)`;
|
| 1247 |
+
|
| 1248 |
+
// Check collisions
|
| 1249 |
+
checkCollisions();
|
| 1250 |
+
|
| 1251 |
+
// Continue loop
|
| 1252 |
+
gameLoopId = requestAnimationFrame(gameLoop);
|
| 1253 |
+
}
|
| 1254 |
+
|
| 1255 |
+
// Event listeners
|
| 1256 |
+
let rightPressed = false;
|
| 1257 |
+
let leftPressed = false;
|
| 1258 |
+
let downPressed = false;
|
| 1259 |
+
|
| 1260 |
+
document.addEventListener('keydown', (e) => {
|
| 1261 |
+
if (!gameRunning) return;
|
| 1262 |
+
|
| 1263 |
+
switch (e.key) {
|
| 1264 |
+
case 'ArrowRight':
|
| 1265 |
+
rightPressed = true;
|
| 1266 |
+
break;
|
| 1267 |
+
case 'ArrowLeft':
|
| 1268 |
+
leftPressed = true;
|
| 1269 |
+
break;
|
| 1270 |
+
case 'ArrowDown':
|
| 1271 |
+
downPressed = true;
|
| 1272 |
+
crouch();
|
| 1273 |
+
break;
|
| 1274 |
+
case ' ':
|
| 1275 |
+
jump();
|
| 1276 |
+
break;
|
| 1277 |
+
}
|
| 1278 |
+
});
|
| 1279 |
+
|
| 1280 |
+
document.addEventListener('keyup', (e) => {
|
| 1281 |
+
switch (e.key) {
|
| 1282 |
+
case 'ArrowRight':
|
| 1283 |
+
rightPressed = false;
|
| 1284 |
+
break;
|
| 1285 |
+
case 'ArrowLeft':
|
| 1286 |
+
leftPressed = false;
|
| 1287 |
+
break;
|
| 1288 |
+
case 'ArrowDown':
|
| 1289 |
+
downPressed = false;
|
| 1290 |
+
stopCrouch();
|
| 1291 |
+
break;
|
| 1292 |
+
case ' ':
|
| 1293 |
+
// Space key release - nothing needed
|
| 1294 |
+
break;
|
| 1295 |
+
}
|
| 1296 |
+
});
|
| 1297 |
+
|
| 1298 |
+
// Touch controls for mobile
|
| 1299 |
+
let touchStartX = 0;
|
| 1300 |
+
|
| 1301 |
+
document.addEventListener('touchstart', (e) => {
|
| 1302 |
+
if (!gameRunning) return;
|
| 1303 |
+
|
| 1304 |
+
touchStartX = e.touches[0].clientX;
|
| 1305 |
+
|
| 1306 |
+
// If touch is in lower half of screen, treat as jump
|
| 1307 |
+
if (e.touches[0].clientY > window.innerHeight / 2) {
|
| 1308 |
+
jump();
|
| 1309 |
+
}
|
| 1310 |
+
});
|
| 1311 |
+
|
| 1312 |
+
document.addEventListener('touchmove', (e) => {
|
| 1313 |
+
if (!gameRunning) return;
|
| 1314 |
+
|
| 1315 |
+
const touchX = e.touches[0].clientX;
|
| 1316 |
+
const diff = touchX - touchStartX;
|
| 1317 |
+
|
| 1318 |
+
if (Math.abs(diff) > 10) {
|
| 1319 |
+
if (diff > 0) {
|
| 1320 |
+
// Swipe right
|
| 1321 |
+
rightPressed = true;
|
| 1322 |
+
leftPressed = false;
|
| 1323 |
+
} else {
|
| 1324 |
+
// Swipe left
|
| 1325 |
+
leftPressed = true;
|
| 1326 |
+
rightPressed = false;
|
| 1327 |
+
}
|
| 1328 |
+
}
|
| 1329 |
+
});
|
| 1330 |
+
|
| 1331 |
+
document.addEventListener('touchend', () => {
|
| 1332 |
+
rightPressed = false;
|
| 1333 |
+
leftPressed = false;
|
| 1334 |
+
});
|
| 1335 |
+
|
| 1336 |
+
// Click/tap to jump on mobile
|
| 1337 |
+
document.addEventListener('click', (e) => {
|
| 1338 |
+
if (!gameRunning && (e.target === startBtn || e.target === restartBtn || e.target === winRestartBtn)) {
|
| 1339 |
+
return;
|
| 1340 |
+
}
|
| 1341 |
+
|
| 1342 |
+
if (gameRunning && isAlive && !levelComplete && e.clientY > window.innerHeight / 2) {
|
| 1343 |
+
jump();
|
| 1344 |
+
}
|
| 1345 |
+
});
|
| 1346 |
+
|
| 1347 |
+
// Start game buttons
|
| 1348 |
+
startBtn.addEventListener('click', () => {
|
| 1349 |
+
startScreen.style.display = 'none';
|
| 1350 |
+
startGame();
|
| 1351 |
+
});
|
| 1352 |
+
|
| 1353 |
+
restartBtn.addEventListener('click', startGame);
|
| 1354 |
+
winRestartBtn.addEventListener('click', startGame);
|
| 1355 |
+
|
| 1356 |
+
// Start game function
|
| 1357 |
+
function startGame() {
|
| 1358 |
+
// Reset game state
|
| 1359 |
+
gameRunning = true;
|
| 1360 |
+
isAlive = true;
|
| 1361 |
+
levelComplete = false;
|
| 1362 |
+
score = 0;
|
| 1363 |
+
time = 300;
|
| 1364 |
+
marioPositionX = 100;
|
| 1365 |
+
marioPositionY = 300;
|
| 1366 |
+
marioVelocityY = 0;
|
| 1367 |
+
cameraOffset = 0;
|
| 1368 |
+
rightPressed = false;
|
| 1369 |
+
leftPressed = false;
|
| 1370 |
+
downPressed = false;
|
| 1371 |
+
|
| 1372 |
+
// Update displays
|
| 1373 |
+
scoreDisplay.textContent = `SCORE: ${score}`;
|
| 1374 |
+
timeDisplay.textContent = `TIME: ${time}`;
|
| 1375 |
+
|
| 1376 |
+
// Hide screens
|
| 1377 |
+
startScreen.style.display = 'none';
|
| 1378 |
+
gameOverScreen.style.display = 'none';
|
| 1379 |
+
winScreen.style.display = 'none';
|
| 1380 |
+
|
| 1381 |
+
// Clear existing Mario
|
| 1382 |
+
const existingMario = document.querySelector('.mario');
|
| 1383 |
+
if (existingMario) existingMario.remove();
|
| 1384 |
+
|
| 1385 |
+
// Create game elements
|
| 1386 |
+
createMario();
|
| 1387 |
+
createGround();
|
| 1388 |
+
setupLevel();
|
| 1389 |
+
|
| 1390 |
+
// Start timer
|
| 1391 |
+
clearInterval(timeInterval);
|
| 1392 |
+
startTimer();
|
| 1393 |
+
|
| 1394 |
+
// Start game loop
|
| 1395 |
+
lastTime = performance.now();
|
| 1396 |
+
gameLoopId = requestAnimationFrame(gameLoop);
|
| 1397 |
+
}
|
| 1398 |
+
|
| 1399 |
+
// Initialize game
|
| 1400 |
+
startScreen.style.display = 'flex';
|
| 1401 |
+
});
|
| 1402 |
+
</script>
|
| 1403 |
+
<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=Assad3l/alda" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
| 1404 |
+
</html>
|