-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
716 lines (603 loc) · 22.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS 3D Rounded Cubes Grid</title>
<style>
@font-face {
font-family: "proxima-soft";
src: url("fonts/proxima-soft-13.woff") format('woff');
font-weight: bold;
}
@font-face {
font-family: 'r-type-iii';
src: url("fonts/r-type-iii-the-third-lightning-small.woff") format('woff');
}
@font-face {
font-family: 'sync-bold';
src: url("fonts/sync-bold.woff") format('woff');
font-weight: bold;
}
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
perspective: 1000px; /* Adjusted perspective value for a subtler 3D effect */
background: black;
overflow: hidden;
cursor: none;
}
.background {
position: absolute;
width: 734px;
height: 564px;
opacity: 1.0;
}
.background .loader {
color: white;
font-family: 'proxima-soft', sans-serif;
font-size: 26px;
font-weight: 400;
padding: 38px;
}
.background .ready {
color: white;
font-family: 'proxima-soft', sans-serif;
font-size: 29px;
font-weight: 400;
width: 100%;
}
.background .watermark {
color: yellow;
font-family: 'proxima-soft', sans-serif;
font-size: 30px;
font-weight: 400;
line-height: 24px;
opacity: 0.4;
}
.text-loader {
margin-top: 32px;
position: absolute;
}
.text-ready {
margin-top: 50px;
position: absolute;
width: 100%;
text-align: center;
}
.text-watermark {
margin-top: 34px;
margin-right: 28px;
float: right;
text-align: center;
}
.scene {
zoom: 0.605;
margin-top: 40px;
display: flex;
flex-wrap: wrap;
width: 1040px; /* Adjusted width for 8x4 grid with increased spacing */
height: 460px; /* Adjusted height for 8x4 grid with increased spacing */
justify-content: center;
align-items: center;
align-content: center;
transform-style: preserve-3d;
}
.empty, .populated {
margin: 30px;
}
.empty {
transform: rotateY(0deg) rotateX(0deg) scale(1.0);
}
.populated {
transform: rotateY(0deg) rotateX(0deg) scale(1.4);
}
.empty div {
filter: saturate(2.0) !important;
}
.populated div {
filter: saturate(3.5) !important;
}
.populated div img {
filter: saturate(0.285) !important
}
.selected-empty div {
filter: saturate(2.5) !important;
}
.selected-populated div {
filter: saturate(4) hue-rotate(340deg) !important
}
.selected-populated div img {
filter: saturate(0.25) !important
}
.populated .middle {
opacity: 1;
}
.populated .front {
clip-path: polygon(0% 0%, 0% 100%, 10% 100%, 10% 10%, 90% 10%, 90% 90%, 10% 90%, 10% 100%, 100% 100%, 100% 0%);
}
.cube {
width: 56px;
height: 56px;
position: relative;
transform-style: preserve-3d;
}
.cube div img {
position: absolute;
width: 85%;
height: 85%;
top: 5%;
left: 5%;
}
.cube div {
position: absolute;
width: 56px;
height: 56px;
border-radius: 6px;
/* background: rgba(128, 16, 140, 0.4); */
/* background: rgba(200, 60, 217, 0.20); */
/* background: linear-gradient(45deg, rgba(200, 60, 217, 0.02), rgba(128, 16, 140, 1)); */
background: linear-gradient(45deg, #59007705, #420356ff);
/* filter: brightness(1.75); */
/* filter: saturate(2.0); */
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
/* backdrop-filter: blur(7.8px); */
/* border: 1px solid rgba(200, 60, 217, 0.05); */
border: 1px solid rgba(0, 0, 0, 0.25);
opacity: 0.9;
}
.front { transform: rotateY( 0deg) translateZ(25px); }
.back { transform: rotateY(180deg) translateZ(25px); }
.right { transform: rotateY( 90deg) translateZ(25px); }
.left { transform: rotateY(-90deg) translateZ(25px); }
.top { transform: rotateX( 90deg) translateZ(25px); }
.bottom { transform: rotateX(-90deg) translateZ(25px); }
.middle {
transform: rotateY(0deg) translateZ(6px);
background: none !important;
border: none !important;
}
.grid-container {
position: absolute;
width: 734px;
height: 564px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, black 10%, rgba(0, 0, 0, 50%) 25%, transparent 60%);
background-image: linear-gradient(90deg, #5d5d5d 2px, transparent 0), linear-gradient(180deg, #5d5d5d 2px, transparent 0);
background-size: 20px 20px;
background-position: 6px 4px;
opacity: 0.75;
}
.info {
opacity: 1;
margin-left: -8px;
margin-right: -8px;
margin-top: 44px;
width: 100%;
height: 140px;
color: #ddd;
background: linear-gradient(#500082d8, #800057d8 50%);
border: 4px solid #ccc;
/* opacity: 0.85; */
font-family: 'proxima-soft', sans-serif;
font-size: 32px;
font-weight: 400;
display: flex;
}
.info div {
overflow: hidden;
}
.info-left {
width: 34%;
}
.info-left img {
padding: 18px;
width: 314px;
}
.info-right {
flex-grow: 1;
padding: 24px;
font-size: 41px;
padding-left: 10px;
width: 66%;
}
.game-type {
line-height: 40px;
margin-top: 10px;
float: left;
padding-top: 4px;
padding-bottom: 0px;
padding-left: 18px;
padding-right: 18px;
border: 3px solid white;
}
.game-info {
margin-left: 14px;
line-height: 74px;
font-size: 36px;
}
.start {
position: absolute;
right: 0;
margin-top: 120px;
margin-right: 60px;
color: transparent;
/* background-image: linear-gradient(90deg, transparent 2px, blue 0), linear-gradient(180deg, transparent 2px, blue 0);
background-size: 20px 20px;
background-clip: text; */
/* font-family: 'r-type-iii', sans-serif; */
font-family: 'sync-bold', sans-serif;
font-size: 68px;
font-weight: 400;
line-height: 90px;
text-align: center;
}
.start span {
margin-left: -26px;
/* letter-spacing: -2px; */
/* background-color: #800477; */
background-image: linear-gradient(90deg, black 1px, transparent 0), linear-gradient(180deg, black 1px, transparent 0), linear-gradient(135deg, #6612a9, #420356);
background-position: -1.5px -1.5px;
background-size: 14px 14px;
background-clip: text;
/* -webkit-text-stroke-width: 1px; */
/* -webkit-text-stroke-color: black; */
}
.start span::before {
content: attr(data-text);
position: absolute;
color: #420356;
transform: translateZ(-8px);
text-shadow: 1px 1px 0 black, 2px 2px 0 #420356;
z-index: -1;
}
.start-banner {
position: absolute;
top: 272px;
left: 80px;
width: 200px;
}
.start-text {
font-family: 'proxima-soft', sans-serif;
font-weight: 400;
color: white;
}
.start-name {
font-size: 28px;
position: absolute;
top: 352px;
left: 82px;
}
.start-company {
/* font-size: 24px; */
font-size: 20px;
position: absolute;
top: 396px;
left: 82px;
}
.start-desc {
/* font-size: 27px; */
font-size: 26px;
line-height: 31px;
position: absolute;
top: 426px;
left: 82px;
width: 570px;
max-height: 60px;
overflow: hidden;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.fade-in {
animation: fadeIn 500ms forwards;
}
.fade-out {
animation: fadeOut 500ms forwards;
opacity: 0; /* Ensure it's hidden after animation */
}
.hidden {
/* display: none !important; */
opacity: 0 !important;
}
</style>
</head>
<body>
<div class="grid-container hidden"></div>
<div class="background hidden">
<div class="text-loader"><span class="loader">cubeboot loader</span></div>
<div class="text-ready hidden"><span class="ready">Ready to play the game?</span></div>
<div class="text-watermark"><span class="watermark">MOCKUP<br/>cubeboot</span></div>
<div class="start hidden">
<span data-text="P">P</span>
<span data-text="R">R</span>
<span data-text="E">E</span>
<span data-text="S">S</span>
<span data-text="S">S</span>
<br>
<span data-text="S">S</span>
<span data-text="T">T</span>
<span data-text="A">A</span>
<span data-text="R">R</span>
<span data-text="T">T</span>
</div>
<img class="start-banner hidden" src="assets/banner.png" />
<div class="start-text start-name hidden"><span>SOME GAME</span></div>
<div class="start-text start-company hidden"><span>ME</span></div>
<div class="start-text start-desc hidden"><span>Hello there</span></div>
</div>
<div class="scene hidden">
<div class="info hidden">
<div class="info-left hidden">
<img src="assets/banner.png" />
</div>
<div class="info-right hidden">
<span>SOME GAME NAME</span>
<br>
<span class="game-type">ISO</span>
<span class="game-info">The game is really fun and you should</span>
</div>
</div>
</div>
<script>
function hideElement(element) {
element.classList.remove('hidden');
element.classList.remove('fade-in');
element.classList.add('fade-out');
}
function showElement(element) {
element.classList.remove('hidden');
element.classList.remove('fade-out');
element.classList.add('fade-in');
}
function hideElementNow(element) {
element.classList.add('hidden');
}
function showElementNow(element) {
element.classList.remove('hidden');
}
const bg = document.querySelector('.background');
const grid = document.querySelector('.grid-container');
const scene = document.querySelector('.scene');
const info = document.querySelector('.info');
const rows = 4;
const cols = 8;
const gameCount = 12;
const populatedRows = Math.floor(gameCount / 8);
const populatedExtra = gameCount % 8;
console.log("populatedRows", populatedRows);
console.log("populatedExtra", populatedExtra);
const selectInfoBanner = document.querySelector('.info-left img');
const selectInfoName = document.querySelectorAll('.info-right span')[0];
const selectInfoDesc = document.querySelectorAll('.info-right span')[2];
const selectInfoLeft = document.querySelector('.info-left');
const selectInfoRight = document.querySelector('.info-right');
const startBanner = document.querySelector('.start-banner');
const startName = document.querySelector('.start-name');
const startCompany = document.querySelector('.start-company');
const startDesc = document.querySelector('.start-desc');
let games = [];
function showGame(index) {
console.log("showGame", index);
const game = games[index];
selectInfoBanner.src = game.banner_path;
selectInfoName.textContent = game.display_name;
selectInfoDesc.textContent = game.short_desc;
startBanner.src = game.banner_path;
startName.textContent = game.display_name;
startCompany.textContent = "OPEN SOURCE";
startDesc.textContent = game.long_desc;
showElementNow(selectInfoLeft);
showElementNow(selectInfoRight);
}
async function setupCubes() {
const resp = await fetch('games.json');
games = await resp.json();
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
const cube = document.createElement('div');
cube.classList.add('cube');
if (i < populatedRows || i == populatedRows && j < populatedExtra) {
cube.classList.add('populated');
} else {
cube.classList.add('empty');
}
const faces = ['front', 'back', 'right', 'left', 'top', 'bottom'];
faces.forEach(face => {
const faceDiv = document.createElement('div');
faceDiv.classList.add(face);
cube.appendChild(faceDiv);
});
if (cube.classList.contains('populated')) {
const faceDiv = document.createElement('div');
faceDiv.classList.add('middle');
const img = document.createElement('img');
img.src = games[i * cols + j].icon_path;
faceDiv.appendChild(img);
cube.appendChild(faceDiv);
}
scene.insertBefore(cube, info);
}
}
showGame(0);
info.classList.remove('hidden');
requestAnimationFrame(animate);
}
setupCubes();
// Add the selected class to one cube for animation
let selectedIndex = 0;
let currentPage = 0;
const PAGE_SELECTING = 0;
const PAGE_LOADING = 1;
const startText = document.querySelector('.start');
const readyText = document.querySelector('.text-ready');
const loaderText = document.querySelector('.text-loader');
function selectingKeydownHandler(event) {
const previousSelectedIndex = selectedIndex;
if (event.key === 'Enter' || event.key === 'x' || event.key === 'z') {
hideElement(scene);
hideElement(loaderText);
showElement(startText);
showElement(readyText);
showElement(startBanner);
showElement(startName);
showElement(startCompany);
showElement(startDesc);
currentPage = PAGE_LOADING;
}
if (event.key === 'ArrowRight') {
if ((selectedIndex % 8) == (8 - 1)) {
console.log("input err");
}
else {
selectedIndex++;
}
}
if (event.key === 'ArrowLeft') {
if ((selectedIndex % 8) == 0) {
console.log("input err");
}
else {
selectedIndex--;
}
}
if (event.key === 'ArrowDown') {
if ((selectedIndex + 8) > (4 * 8 - 1)) {
console.log("input err");
} else {
selectedIndex += 8;
}
}
if (event.key === 'ArrowUp') {
if ((selectedIndex - 8) < 0) {
console.log("input err");
} else {
selectedIndex -= 8;
}
}
if (selectedIndex !== previousSelectedIndex) {
animate();
}
}
function loadingKeydownHandler(event) {
if (event.key === 'Enter' || event.key === 'x' || event.key === 'z') {
showElement(scene);
showElement(loaderText);
hideElement(startText);
hideElement(readyText);
hideElement(startBanner);
hideElement(startName);
hideElement(startCompany);
hideElement(startDesc);
currentPage = PAGE_SELECTING;
}
}
let fullFade = true;
function toggleFade() {
if (fullFade) {
showElement(bg);
showElement(grid);
showElement(scene);
fullFade = false;
} else {
hideElement(bg);
hideElement(grid);
hideElement(scene);
fullFade = true;
}
}
setTimeout(toggleFade, 500);
function keydownHandler(event) {
if (event.key === ' ') {
toggleFade();
}
if (currentPage === PAGE_SELECTING) {
selectingKeydownHandler(event);
} else if (currentPage === PAGE_LOADING) {
loadingKeydownHandler(event);
}
}
document.addEventListener('keydown', keydownHandler);
function animate() {
const previousSelectedCube = document.querySelector('.selected');
const selectedCube = scene.children[selectedIndex];
if (selectedCube != previousSelectedCube) {
if (previousSelectedCube !== null) {
previousSelectedCube.classList.remove('selected');
previousSelectedCube.classList.remove('selected-empty');
previousSelectedCube.classList.remove('selected-populated');
previousSelectedCube.style.transform = "";
}
selectedCube.classList.add('selected');
if (selectedCube.classList.contains('empty')) {
selectedCube.classList.add('selected-empty');
hideElementNow(selectInfoLeft);
hideElementNow(selectInfoRight);
} else {
selectedCube.classList.add('selected-populated');
console.log(previousSelectedCube);
console.log(selectedCube);
showGame(selectedIndex);
}
}
let scale = 1.0;
if (selectedCube.classList.contains('empty')) {
scale = 1.6;
} else {
scale = 2.3;
}
const time = performance.now() / 1000;
// cube
const wobbleX = Math.sin(time * 2) * 5; // Wobble +-5px
const wobbleY = Math.cos(time * 2) * 5; // Wobble +-5px
const rotation = Math.sin(time) * 5; // Rotate +-5 degrees
selectedCube.style.transform = `translate(${wobbleX}px, ${wobbleY}px) rotate(${rotation}deg) rotateX(${rotation}deg) rotateY(${rotation}deg) scale(${scale})`;
// start text
const amplitude = 2; // Amplitude of the dance
const frequency = 2; // Frequency of the dance
const rotationAmplitude = 3; // Amplitude of rotation
const swayAmplitude = 8; // Amplitude of rotation
const x = amplitude * Math.sin(frequency * time);
const y = amplitude * Math.abs(Math.cos(frequency * time)) * 2;
const z = amplitude * Math.sin(frequency * time / 2); // Add some Z movement
const rotateY = swayAmplitude * Math.sin(time) * 4;
const rotateXZ = rotationAmplitude * Math.sin(frequency * time / 2);
startText.style.transform = `translate3d(${x}px, ${y}px, ${z}px) rotateY(${rotateY}deg) rotateX(8deg) rotateZ(${rotateXZ}deg) scale(0.90)`;
requestAnimationFrame(animate);
}
function resize() {
// clear changes
document.body.style.zoom = '';
document.body.style.height = '';
// document.body.style.transform = '';
const rect = bg.getBoundingClientRect();
let factor = document.body.clientWidth / rect.width;
if (factor * rect.height > document.body.clientHeight) {
factor = document.body.clientHeight / rect.height;
}
console.log("factor", factor);
document.body.style.zoom = factor;
document.body.style.height = `${100 / factor}vh`;
// document.body.style.transform = `scale(${100 / factor})`;
}
window.addEventListener('resize', resize);
resize();
</script>
</body>
</html>