-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2854 lines (2538 loc) · 113 KB
/
index.html
File metadata and controls
2854 lines (2538 loc) · 113 KB
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
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, user-scalable=no" name="viewport">
<meta content="$ilp.uphold.com/zDFj9FWE4m6e" name="monetization">
<title>SPACEBAR CLICKER</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Open+Sans:wght@400;500;600;700&family=Roboto+Mono:wght@400;500;600&family=Press+Start+2P&display=swap" rel="stylesheet">
<style>
/* 商城样式 */
#shop {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 90%;
max-width: 600px;
height: 80vh;
max-height: 700px;
background-color: #fff;
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
z-index: 2000;
display: flex;
flex-direction: column;
overflow: hidden;
border: 1px solid var(--main-color);
}
#shop-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 20px;
background-color: var(--main-color);
color: white;
}
#shop-header h2 {
margin: 0;
font-size: 1.5em;
font-family: 'Montserrat', sans-serif;
}
#close-shop-btn {
background: none;
border: none;
color: white;
font-size: 2em;
cursor: pointer;
padding: 0 5px;
line-height: 1;
}
#close-shop-btn:hover {
opacity: 0.8;
}
#shop-tabs {
display: flex;
background-color: #f0f0f0;
border-bottom: 1px solid #ddd;
}
.shop-tab {
flex-grow: 1;
padding: 12px 10px;
text-align: center;
cursor: pointer;
border: none;
background-color: transparent;
font-size: 0.95em;
font-weight: 500;
color: var(--text-color);
transition: background-color 0.2s, color 0.2s;
border-bottom: 3px solid transparent;
font-family: 'Open Sans', sans-serif;
}
.shop-tab:hover {
background-color: #e9e9e9;
color: var(--main-color);
}
.shop-tab.active {
background-color: #fff;
color: var(--main-color);
border-bottom-color: var(--highlight-color);
font-weight: 600;
}
#shop-content {
flex-grow: 1;
overflow-y: auto;
padding: 15px;
background-color: var(--background-color);
}
/* 音乐页面卡片特殊样式 */
.music-items-wrapper {
display: flex;
flex-direction: column !important; /* 强制纵向排列 */
gap: 10px;
}
.music-shop-item {
width: 100% !important; /* 强制占满整行 */
margin-bottom: 10px !important;
min-height: 75px !important;
}
.music-shop-item .shop-item-image {
width: 60px !important; /* 更大的图标 */
height: 60px !important;
}
.music-shop-item .shop-item-use,
.music-shop-item .shop-item-buy {
width: auto !important; /* 按钮宽度自适应 */
min-width: 80px; /* 设置最小宽度 */
font-size: 0.75em !important; /* 更小的字体 */
padding: 4px 10px !important; /* 更小的内边距 */
}
.music-shop-item .shop-item-details h3 {
font-size: 1em; /* Further reduced */
margin: 0 0 3px 0; /* Further reduced margin */
color: var(--main-color);
font-family: 'Montserrat', sans-serif;
white-space: nowrap; /* Prevent wrapping */
overflow: hidden; /* Hide overflow */
text-overflow: ellipsis; /* Add ellipsis if text overflows */
}
.music-shop-item .shop-item-details p {
max-height: none !important;
-webkit-line-clamp: initial !important;
overflow: visible !important;
margin-bottom: 6px !important;
color: #555 !important;
line-height: 1.3 !important;
font-size: 0.7em; /* Further reduced */
}
.shop-item {
background-color: #fff;
border-radius: 8px;
padding: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
display: flex;
flex-direction: row;
align-items: flex-start;
text-align: left;
border: 1px solid #e0e0e0;
min-height: 65px;
max-height: 200px;
overflow: hidden;
margin-bottom: 12px;
width: calc(50% - 6px);
box-sizing: border-box;
}
.shop-item.active { /* 用于标记当前正在使用的物品 */
border: 2px solid var(--highlight-color);
box-shadow: 0 0 10px var(--highlight-color);
}
.shop-item-image {
width: 50px; /* Further reduced width for image */
height: 50px; /* Further reduced height for image */
flex-shrink: 0; /* Prevent image from shrinking */
background-color: #f0f0f0;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
margin-top: 6px;
margin-right: 10px; /* Spacing between image and details */
border-radius: 4px;
border: 1px solid #ddd;
}
/* New class for text content next to the image */
.shop-item-details {
display: flex;
flex-direction: column;
flex-grow: 1; /* Takes remaining space */
justify-content: space-between; /* Pushes footer to bottom if item is tall */
height: 100%; /* Allow footer to stick to bottom */
padding: 0; /* Removed padding */
}
.shop-item h3 {
font-size: 0.9em; /* Further reduced */
margin: 0 0 3px 0; /* Further reduced margin */
color: var(--main-color);
font-family: 'Montserrat', sans-serif;
white-space: nowrap; /* Prevent wrapping */
overflow: hidden; /* Hide overflow */
text-overflow: ellipsis; /* Add ellipsis if text overflows */
}
.shop-item p {
font-size: 0.7em; /* Further reduced */
color: #555;
margin: 0 0 7px 0; /* Further reduced margin */
line-height: 1.4; /* Further reduced line-height */
flex-grow: 1; /* Allows description to take available space before footer */
max-height: 6em; /* Limit to 2 lines */
overflow: hidden; /* Hide overflow */
display: -webkit-box;
-webkit-line-clamp: 3; /* Limit to 2 lines */
-webkit-box-orient: vertical;
}
.shop-item-footer {
margin-top: 3px; /* Reduced from auto */
width: 100%; /* Ensure footer takes full width of details */
}
.shop-item-price {
display: flex;
align-items: center;
justify-content: flex-start; /* Changed to left-aligned */
margin-bottom: 5px; /* Reduced from 10px */
font-size: 1em; /* Reduced from 1.2em */
font-weight: 600;
color: var(--secondary-color);
}
.shop-item-price .spacebar { /* 确保商店价格旁边的空格图标正确显示 */
padding-right: 15px; /* 减小大小 */
margin-right: 2px;
transform: scale(0.7); /* 缩小 */
}
.shop-item-buy, .shop-item-use {
width: 100%;
padding: 5px; /* Reduced padding */
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: 600;
font-size: 0.8em; /* Reduced font size */
transition: background-color 0.2s;
font-family: 'Open Sans', sans-serif;
}
.shop-item-buy {
background-color: var(--highlight-color);
color: white;
}
.shop-item-buy:hover {
background-color: #e6ac00; /* darken highlight color */
}
.shop-item-buy:disabled {
background-color: #ccc;
cursor: not-allowed;
}
.shop-item-use {
background-color: var(--secondary-color);
color: white;
}
.shop-item-use:hover {
background-color: #0091a1; /* darken secondary color */
}
.shop-item-use:disabled { /* 用于 "Using" 状态 */
background-color: #aaa;
color: #eee;
cursor: default;
}
/* 响应式调整 */
@media (max-width: 600px) {
#shop {
width: 95%;
height: 90vh;
}
#shop-content {
padding: 10px;
}
.shop-item {
width: 100%;
min-height: 70px;
padding: 8px;
margin-bottom: 10px;
}
.shop-item-image {
width: 50px;
height: 50px;
margin-right: 8px;
}
/* 移动设备上的音乐卡片 */
.music-shop-item .shop-item-image {
width: 55px !important;
height: 55px !important;
}
.music-shop-item .shop-item-use,
.music-shop-item .shop-item-buy {
min-width: 60px;
padding: 3px 8px !important;
}
}
</style>
<style>
:root {
--main-color: #3949ab;
--secondary-color: #00acc1;
--background-color: #f5f5f5;
--highlight-color: #ffc107;
--text-color: #212121;
--error-color: #f44336;
}
body {
user-select: none;
background-color: var(--background-color);
background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444-.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%233949ab' fill-opacity='0.06' fill-rule='evenodd'/%3E%3C/svg%3E");
font-family: 'Open Sans', sans-serif;
overflow: hidden;
color: var(--text-color);
margin: 0;
padding: 0;
}
.hide {
display: none !important;
}
/* 主区域样式 */
#game {
max-width: 1000px;
margin: 0 auto;
padding: 20px;
overflow: hidden;
display: flex;
flex-direction: column;
min-height: calc(100vh - 60px);
}
#header {
text-align: center;
margin-bottom: 20px;
}
#counter {
text-align: center;
font-size: 8rem;
color: var(--main-color);
height: 8rem;
font-weight: 700;
font-family: 'Montserrat', sans-serif;
margin-top: 20px;
margin-bottom: 10px;
}
#counter span {
display: block;
text-align: center;
}
#per_second {
font-size: 1.5rem;
text-align: center;
margin-bottom: 1.2rem;
color: var(--main-color);
font-family: 'Open Sans', sans-serif;
}
/* SpaceBar 按钮样式 */
.sbc {
margin-bottom: 30px;
}
.sbs {
display: block;
font-size: 1.2rem;
color: var(--text-color);
text-align: center;
text-decoration: none;
font-weight: 700;
letter-spacing: 10px;
padding-top: 30px;
padding-bottom: 10px;
font-family: 'Roboto Mono', monospace;
margin: 0 auto;
max-width: 300px;
}
/* Neon Skin */
.sb1.skin-neon {
background: linear-gradient(180deg, #2b044d 0%, #6a0dad 100%);
border-color: #ff00ff;
color: #00ffff;
font-family: 'Roboto Mono', monospace; /* Keep or adjust as needed */
text-shadow: 0 0 5px #00ffff, 0 0 10px #00ffff, 0 0 15px #00ffff;
box-shadow: 0 0 15px #ff00ff, inset 0 0 10px rgba(255, 0, 255, 0.5);
}
/* Retro Skin */
.sb1.skin-retro {
background: linear-gradient(180deg, #ffda79 0%, #ffa502 100%);
border-color: #cc8e35;
color: #7c2c0c;
font-family: 'Press Start 2P', 'Roboto Mono', monospace;
text-shadow: 2px 2px 0 #fff, -1px -1px 0 #a0522d; /* Added subtle shadow for depth */
box-shadow: 3px 3px 0 #7c2c0c, inset 0px 0px 5px rgba(255,255,255,0.3);
border-width: 2px; /* Slightly thinner border for retro feel */
border-bottom-width: 4px;
}
.sb1.skin-retro:active, .sb_active.skin-retro {
border-bottom-width: 2px;
padding-top: 31px; /* Adjust based on border change */
}
/* Cyber Skin */
.sb1.skin-cyber {
background: linear-gradient(45deg, #0a0a0a 0%, #222 100%);
border-color: #00ff41;
color: #00ff41;
font-family: 'Roboto Mono', monospace;
text-shadow: 0 0 3px #00ff41, 0 0 6px #00ff41, 0 0 9px #00ff41;
box-shadow: 0 0 12px rgba(0, 255, 65, 0.7), inset 0 0 8px rgba(0, 255, 65, 0.3);
border-width: 2px;
border-bottom-width: 4px;
}
.sb1.skin-cyber:active, .sb_active.skin-cyber {
border-bottom-width: 2px;
padding-top: 31px; /* Adjust based on border change */
}
.sb1:hover {
/* background: linear-gradient(180deg, #ffffff 0, #f5f5f5 100%); */ /* Removed background change on hover */
transform: translateY(-2px);
box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.sb1 {
border: 3px solid var(--main-color);
border-bottom-width: 6px;
color: var(--main-color);
border-radius: 10px;
/*transition: transform 80ms ease-in, box-shadow 80ms ease-in; */ /* Original, causing issues with layout shifts */
transition: transform 80ms ease-in, box-shadow 80ms ease-in, background 80ms ease-in, color 80ms ease-in; /* Explicit transitions */
background: var(--background-color);
background: linear-gradient(180deg, #ffffff 0, #f0f0f0 100%);
font-family: 'Roboto Mono', monospace;
text-shadow: none;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.sb1:active,
.sb_active {
border-color: var(--main-color);
border-bottom-width: 3px;
padding-top: 33px;
transform: translateY(3px) scale(0.98);
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
/*transition: transform 10ms ease-in, box-shadow 10ms ease-in;*/ /* Original */
transition: transform 10ms ease-in, box-shadow 10ms ease-in, background 10ms ease-in, color 10ms ease-in; /* Explicit transitions, no padding/border */
}
/* 游戏项目区域样式 */
#items-container {
flex: 1;
overflow-y: auto;
margin-bottom: 30px;
}
#items-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
gap: 15px;
padding: 15px;
/* margin-bottom: 20px; */ /* This will be included in the margin shorthand */
max-width: 60%; /* New: To make the grid narrower */
margin: 0 auto 20px; /* New: To center the grid and maintain bottom margin */
}
.item-icon {
position: relative;
width: 80px;
height: 80px;
border-radius: 10px;
background-color: #fff;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
transition: all 0.2s ease;
opacity: 0.7;
border: 1px solid rgba(57, 73, 171, 0.2);
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
/* overflow: hidden; */ /* Removed to allow tooltip visibility */
}
.item-fallback-text {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
font-size: 24px;
font-weight: bold;
color: var(--main-color);
opacity: 0.6;
text-transform: uppercase;
background: linear-gradient(45deg, rgba(57, 73, 171, 0.1), rgba(0, 172, 193, 0.1));
border-radius: 8px;
}
/* 添加项目图标不同状态下的样式 */
.item-icon.keyboard_upgrade {
background-color: #e8f5e9;
}
.item-icon.monkey {
background-color: #fff8e1;
}
.item-icon.laser_gun,
.item-icon.nuclear_gun {
background-color: #ffebee;
}
/* 项目购买动画效果 */
@keyframes itemPurchased {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
.item-purchased {
animation: itemPurchased 0.4s ease-out;
}
/* 波纹动画效果 */
@keyframes rippleEffect {
to {
transform: scale(1.5);
opacity: 0;
}
}
.item-ripple {
position: absolute;
border-radius: 50%;
transform: scale(0);
animation: rippleEffect 0.6s linear;
background-color: rgba(255, 193, 7, 0.4);
}
.item-icon.buyable {
opacity: 1;
box-shadow: 0 4px 8px rgba(0,0,0,0.08);
border: 1px solid rgba(57, 73, 171, 0.3);
background-color: #f9f9f9;
}
.item-icon:hover {
transform: translateY(-5px);
box-shadow: 0 8px 15px rgba(0,0,0,0.15);
z-index: 1; /* 添加z-index使悬停的图标显示在其他图标上面 */
}
.item-icon:active {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.item-count {
position: absolute;
top: -5px;
right: -5px;
background-color: var(--highlight-color);
color: white;
border-radius: 50%;
width: 22px;
height: 22px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 12px;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
border: 1px solid rgba(255,255,255,0.3);
}
.item-tooltip {
position: absolute;
width: 280px;
background: white;
top: 90px;
left: 50%;
padding: 10px;
border-radius: 8px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
pointer-events: none;
text-align: left;
border: 1px solid var(--main-color);
/* JS controlled properties & initial hidden state: */
opacity: 0;
visibility: hidden;
transform: translateX(-50%) translateY(10px); /* Initial hidden state */
transition: opacity 0.2s ease, transform 0.2s ease;
}
.item-title {
color: var(--main-color);
font-family: 'Montserrat', sans-serif;
font-size: 16px;
font-weight: 600;
margin: 0 0 8px 0;
}
.item-description {
font-size: 13px;
margin-bottom: 8px; /* 从10px减小到8px */
line-height: 1.3; /* 从1.4减小到1.3,减小整体高度 */
color: var(--text-color);
}
.item-price {
display: flex;
align-items: center;
margin-top: 8px;
}
.item-cost {
color: var(--secondary-color);
font-weight: 600;
}
.spacebar {
display: inline !important;
background: var(--background-color);
background: linear-gradient(180deg, var(--background-color) 0, var(--secondary-color) 100%);
border: 2px solid var(--main-color);
border-bottom-width: 3px;
color: var(--text-color);
border-radius: 8px;
padding: 0;
padding-right: 30px;
margin-right: 5px;
font-family: 'Roboto Mono', monospace;
}
/* 功能按钮区域样式 */
#function-bar {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 60px;
background-color: var(--main-color);
display: flex;
justify-content: center;
align-items: center;
gap: 20px;
box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
z-index: 1000;
}
.function-btn {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: white;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
cursor: pointer;
transition: transform 0.2s;
border: none;
padding: 0;
}
.function-btn:hover {
transform: scale(1.1);
}
.function-btn:active {
transform: scale(0.95);
}
.function-btn svg {
width: 24px;
height: 24px;
fill: var(--main-color);
}
/* 保留原有的粒子和分数样式 */
.particle {
width: auto;
position: absolute;
pointer-events: none;
left: 0;
right: 0;
}
.score {
font-weight: 700;
font-size: 1.3rem;
color: var(--highlight-color);
text-shadow: 0 1px 3px rgba(0,0,0,0.2);
z-index: 100;
}
.spacebar_particle {
pointer-events: none;
position: absolute;
left: 0;
top: 0;
z-index: -100;
width: 5px;
height: 15px;
opacity: 0.7;
}
/* 响应式布局 */
@media (max-width: 768px) {
#counter {
font-size: 5rem;
height: 5rem;
}
#per_second {
font-size: 1.2rem;
}
#items-grid {
grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
gap: 10px;
}
.item-icon {
width: 70px;
height: 70px;
}
#function-bar {
height: 50px;
gap: 15px;
}
.function-btn {
width: 35px;
height: 35px;
}
.function-btn svg {
width: 20px;
height: 20px;
}
}
@media (max-width: 480px) {
#game {
padding: 10px;
}
#counter {
font-size: 4rem;
height: 4rem;
}
#items-grid {
grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
gap: 8px;
padding: 8px;
}
.item-icon {
width: 60px;
height: 60px;
}
.item-tooltip {
width: 180px;
padding: 8px;
}
}
</style>
</head>
<body>
<div id="game">
<!-- 主区域 -->
<div id="header">
<div id="counter"><span>0</span></div>
<div id="per_second">0</div>
<div class="sbc">
<div class="sbs sb1" id="sb">SPACEBAR</div>
</div>
</div>
<!-- 游戏项目区域 -->
<div id="items-container">
<div id="items-grid">
<!-- 项目图标将通过JS动态生成 -->
</div>
</div>
</div>
<!-- 功能按钮区域 -->
<div id="function-bar">
<button id="reset-btn" class="function-btn" title="Reset Game">
<svg viewBox="0 0 24 24"><path d="M17.65 6.35A7.958 7.958 0 0012 4c-4.42 0-8 3.58-8 8s3.58 8 8 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0112 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>
</button>
<button id="sound-btn" class="function-btn" title="Toggle Sound">
<svg viewBox="0 0 24 24"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>
</button>
<button id="music-btn" class="function-btn" title="Toggle Music">
<svg viewBox="0 0 24 24"><path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"/></svg>
</button>
<button id="shop-btn" class="function-btn" title="Shop">
<svg viewBox="0 0 24 24"><path d="M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z"/></svg>
</button>
</div>
<!-- 商城弹出层 -->
<div id="shop" class="hide">
<div id="shop-header">
<h2 id="shop-title">Shop</h2>
<button id="close-shop-btn">×</button>
</div>
<div id="shop-tabs">
<button class="shop-tab active" data-tab="sounds" id="shop-tab-sounds">Sounds</button>
<button class="shop-tab" data-tab="music" id="shop-tab-music">Music</button>
<button class="shop-tab" data-tab="skins" id="shop-tab-skins">Skins</button>
<button class="shop-tab" data-tab="backgrounds" id="shop-tab-backgrounds">Backgrounds</button>
</div>
<div id="shop-content">
<!-- 商品将在这里通过JS动态生成 -->
</div>
</div>
<script>
// 多语言支持函数
function getLocale() {
// 检查URL参数
const urlParams = new URLSearchParams(window.location.search);
const localeParam = urlParams.get('locale');
if (localeParam) {
localStorage.setItem('spacebar_locale', localeParam);
return localeParam;
}
// 从本地存储加载
const savedLocale = localStorage.getItem('spacebar_locale');
if (savedLocale) {
return savedLocale;
}
// 默认英文
return 'en';
}
// 初始化当前语言
let currentLocale = getLocale();
// 加载多语言文本
let strings = {};
async function loadStrings() {
const url = `message/${currentLocale}/strings.json`;
return fetch(url)
.then(response => response.json())
.then(data => {
strings = data;
updateUIText();
})
.catch(error => {
console.error('Error loading language strings:', error);
// 出错时加载英文作为后备
if (currentLocale !== 'en') {
currentLocale = 'en';
return loadStrings();
}
return Promise.resolve();
});
}
function updateUIText() {
// 更新游戏标题
document.title = getText('game.title', 'SPACEBAR CLICKER');
// 更新主要UI元素
if (strings.game) {
document.getElementById('sb').textContent = getText('game.spacebar_text', 'SPACEBAR');
// 更新功能按钮标题
document.getElementById('reset-btn').setAttribute('title', getText('game.reset_button', 'Reset Game'));
document.getElementById('sound-btn').setAttribute('title', getText('ui.sound_button', 'Toggle Sound'));
document.getElementById('music-btn').setAttribute('title', getText('ui.music_button', 'Toggle Music'));
document.getElementById('shop-btn').setAttribute('title', getText('ui.shop_button', 'Shop'));
// 更新商店UI文本
const shopTitle = gId('shop-title');
if (shopTitle) shopTitle.textContent = getText('ui.shop.title', 'Shop');
const shopTabSkins = gId('shop-tab-skins');
if (shopTabSkins) shopTabSkins.textContent = getText('ui.shop.tabs.skins', 'Skins');
const shopTabBackgrounds = gId('shop-tab-backgrounds');
if (shopTabBackgrounds) shopTabBackgrounds.textContent = getText('ui.shop.tabs.backgrounds', 'Backgrounds');
const shopTabSounds = gId('shop-tab-sounds');
if (shopTabSounds) shopTabSounds.textContent = getText('ui.shop.tabs.sounds', 'Sounds');
const shopTabMusic = gId('shop-tab-music');
if (shopTabMusic) shopTabMusic.textContent = getText('ui.shop.tabs.music', 'Music');
// 添加皮肤选择器(如果不存在)
if (!document.getElementById('theme-selector') && strings.ui?.spacebar_theme) {
const themeSelector = document.createElement('div');
themeSelector.id = 'theme-selector';
themeSelector.style.textAlign = 'center';
themeSelector.style.marginBottom = '15px';
themeSelector.style.marginTop = '15px';
// 添加皮肤标题
const themeTitle = document.createElement('div');
themeTitle.textContent = getText('ui.spacebar_theme_title', 'Spacebar Theme');
themeTitle.style.color = 'var(--main-color)';
themeTitle.style.fontWeight = 'bold';
themeTitle.style.marginBottom = '8px';
themeTitle.style.fontFamily = "'Montserrat', sans-serif";
themeSelector.appendChild(themeTitle);
// 添加皮肤选项
const themeOptions = document.createElement('div');
themeOptions.style.display = 'flex';
themeOptions.style.justifyContent = 'center';
themeOptions.style.gap = '10px';
// 为每种皮肤创建按钮
Object.entries(strings.ui.spacebar_theme).forEach(([key, value]) => {
const themeBtn = document.createElement('button');
themeBtn.textContent = value;
themeBtn.className = 'theme-btn';
themeBtn.dataset.theme = key;
themeBtn.style.padding = '5px 10px';
themeBtn.style.borderRadius = '4px';
themeBtn.style.backgroundColor = 'var(--background-color)';
themeBtn.style.border = '1px solid var(--main-color)';
themeBtn.style.color = 'var(--main-color)';
themeBtn.style.cursor = 'pointer';
themeBtn.style.fontFamily = "'Open Sans', sans-serif";
themeBtn.style.transition = 'all 0.2s ease';
themeBtn.addEventListener('mouseenter', function() {
this.style.backgroundColor = 'var(--main-color)';
this.style.color = 'white';
});
themeBtn.addEventListener('mouseleave', function() {
if (!this.classList.contains('active-theme')) {
this.style.backgroundColor = 'var(--background-color)';
this.style.color = 'var(--main-color)';
}
});
themeBtn.addEventListener('click', function() {
document.querySelectorAll('.theme-btn').forEach(btn => {
btn.classList.remove('active-theme');
btn.style.backgroundColor = 'var(--background-color)';
btn.style.color = 'var(--main-color)';
});
this.classList.add('active-theme');
this.style.backgroundColor = 'var(--main-color)';
this.style.color = 'white';
game.setSpacebarTheme(key);
});
themeOptions.appendChild(themeBtn);
});
themeSelector.appendChild(themeOptions);
// 激活默认皮肤
setTimeout(() => {
const defaultTheme = document.querySelector('.theme-btn[data-theme="default"]');
if (defaultTheme) defaultTheme.click();
}, 100);
}