@vibechain/os 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +111 -208
- package/README.md +7 -7
- package/dist/cli.js +1 -1
- package/dist/scaffold.js +10 -4
- package/examples/vibexp-app/README.md +19 -3
- package/examples/vibexp-app/store/icon.png +0 -0
- package/examples/vibexp-app/store/screenshot-1.png +0 -0
- package/examples/vibexp-app/vibemarket.json +21 -1
- package/package.json +3 -2
- package/examples/chonk-stack/card-slice.ts +0 -17
- package/examples/chonk-stack/cat3d.ts +0 -57
- package/examples/chonk-stack/game.css +0 -174
- package/examples/chonk-stack/index.html +0 -32
- package/examples/chonk-stack/main.ts +0 -149
- package/examples/chonk-stack/model.ts +0 -40
- package/examples/chonk-stack/renderer.ts +0 -263
- package/examples/chonk-stack/skins.ts +0 -47
- package/examples/chonk-stack/vibemarket.json +0 -21
- package/examples/collection-room/index.html +0 -3
- package/examples/collection-room/main.ts +0 -31
- package/examples/collection-room/vibemarket.json +0 -12
- package/examples/tsconfig.json +0 -4
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
:root { color-scheme: dark; font-family: Arial, Helvetica, sans-serif; color: #f6efff; background: #090519; font-synthesis: none; --foil: #f47bd5; --cyan: #87fff0; --lime: #bdff63; --muted: #b8a8d4; }
|
|
2
|
-
* { box-sizing: border-box; }
|
|
3
|
-
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
|
|
4
|
-
button { font: inherit; color: inherit; cursor: pointer; border: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
|
|
5
|
-
button:disabled { cursor: default; }
|
|
6
|
-
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }
|
|
7
|
-
button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
|
|
8
|
-
[hidden] { display: none !important; }
|
|
9
|
-
#stack { position: relative; width: 100%; height: 100%; isolation: isolate; overflow: hidden; }
|
|
10
|
-
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: manipulation; }
|
|
11
|
-
.top { position: absolute; left: 28px; right: 28px; top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 28px; pointer-events: none; z-index: 3; }
|
|
12
|
-
.wordmark { color: #fff4fb; font-size: 22px; font-weight: 900; font-style: italic; letter-spacing: -1px; line-height: 1; display: grid; flex-shrink: 0; }
|
|
13
|
-
.wordmark span { font: 8px monospace; letter-spacing: 2px; margin-top: 7px; color: var(--cyan); }
|
|
14
|
-
.top-right { display: flex; align-items: center; gap: 20px; }
|
|
15
|
-
.best-stat { text-align: right; }
|
|
16
|
-
.best-stat span { display: block; color: var(--muted); font: 8px monospace; letter-spacing: 1.1px; }
|
|
17
|
-
.best-stat b { display: block; margin-top: 5px; font: 700 24px/1 monospace; font-variant-numeric: tabular-nums; }
|
|
18
|
-
.top-right button { pointer-events: auto; width: 44px; height: 44px; border: 1px solid #9f80c766; border-radius: 12px; background: #170c31d9; display: grid; place-items: center; }
|
|
19
|
-
.top-right button:hover { background: #39214e; }
|
|
20
|
-
.run-hud { display: none; align-items: center; gap: clamp(20px, 3vw, 46px); padding: 16px 24px; border: 1px solid #977aa544; border-radius: 16px; background: linear-gradient(120deg,#23142fe8,#0c091ee8); box-shadow: inset 0 1px #fff1,0 8px 30px #04010b44; }
|
|
21
|
-
.is-playing .run-hud, .is-paused .run-hud { display: flex; }
|
|
22
|
-
.is-ended .top { display: none; }
|
|
23
|
-
.score { display: flex; align-items: center; gap: 12px; }
|
|
24
|
-
.score strong { min-width: 38px; font: 900 italic 48px/.9 Arial,sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -2px; color: #fff4fa; }
|
|
25
|
-
.score > span { font: 9px/1.5 monospace; letter-spacing: 1.6px; color: var(--muted); }
|
|
26
|
-
.width-stat { width: clamp(85px, 11vw, 160px); }
|
|
27
|
-
.stat-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font: 9px monospace; letter-spacing: 1px; color: var(--muted); }
|
|
28
|
-
.stat-label b { font-size: 11px; font-weight: normal; letter-spacing: 0; color: #fff4fa; }
|
|
29
|
-
#width-meter { margin-top: 10px; height: 7px; border-radius: 2px; background: #67527844; overflow: hidden; }
|
|
30
|
-
#width-fill { display: block; height: 100%; background: var(--cyan); transform-origin: left; transition: transform .25s ease-out, background .2s; }
|
|
31
|
-
#width-meter[data-narrow=true] #width-fill { background: var(--foil); }
|
|
32
|
-
.streak-stat { position: relative; width: 120px; }
|
|
33
|
-
#streak-pips { display: flex; gap: 5px; margin-top: 10px; }
|
|
34
|
-
#streak-pips i { height: 7px; flex: 1; background: #67527844; border-radius: 2px; transform: skewX(-15deg); transition: background .15s; }
|
|
35
|
-
#streak-pips i[data-lit=true] { background: var(--lime); box-shadow: 0 0 10px #bdff6333; }
|
|
36
|
-
.streak-help { position: absolute; top: calc(100% + 25px); right: 0; white-space: nowrap; font: 8px monospace; letter-spacing: .8px; color: var(--muted); }
|
|
37
|
-
.overlay { position: absolute; inset: 0; display: flex; align-items: center; flex-direction: column; justify-content: center; pointer-events: none; z-index: 2; }
|
|
38
|
-
.overlay button { pointer-events: auto; }
|
|
39
|
-
.intro-copy { position: absolute; left: 6%; top: 21%; text-align: left; pointer-events: none; }
|
|
40
|
-
.eyebrow { display: block; font: 9px monospace; letter-spacing: 2.3px; }
|
|
41
|
-
.intro-copy .eyebrow { color: var(--cyan); font-size: 10px; letter-spacing: 3px; }
|
|
42
|
-
h1 { font: 900 italic clamp(42px,5.8vw,81px)/.88 Arial,sans-serif; letter-spacing: -4px; margin: 22px 0; }
|
|
43
|
-
h1 em { color: var(--foil); text-shadow: 0 0 40px #ed45cc44; font-size: .72em; letter-spacing: -3px; }
|
|
44
|
-
p { font-size: 13px; line-height: 1.5; }
|
|
45
|
-
.primary { background: var(--lime); color: #18102d; padding: 17px 23px; border-radius: 10px; min-width: 210px; display: flex; justify-content: space-between; align-items: center; gap: 28px; font-size: 14px; font-weight: bold; font-style: italic; text-transform: uppercase; box-shadow: 0 0 24px #beff6320,0 5px 0 #6c853344; transition: translate .15s, background .15s; }
|
|
46
|
-
.primary:hover { background: #d3ff93; translate: 0 -2px; }
|
|
47
|
-
.primary:active { translate: 0 2px; }
|
|
48
|
-
.primary span { font-style: normal; }
|
|
49
|
-
#intro > .primary { position: absolute; left: 6%; bottom: 24%; }
|
|
50
|
-
#intro > small { position: absolute; left: 6%; bottom: calc(24% - 25px); font: 8px monospace; letter-spacing: 1.8px; color: var(--muted); }
|
|
51
|
-
h2 { font-size: 40px; letter-spacing: -2px; margin: 14px 0 0; }
|
|
52
|
-
.overlay h2 { color: #fff4fa; font-style: italic; text-transform: uppercase; }
|
|
53
|
-
#result, .pause-overlay { background: #0905199e; backdrop-filter: blur(5px); }
|
|
54
|
-
.result-card, .pause-card { width: min(360px,calc(100% - 40px)); text-align: center; border: 1px solid #b68ace66; background: linear-gradient(155deg,#39233be8,#100a22f0); border-radius: 22px; padding: 30px; box-shadow: 0 30px 90px #0007,inset 0 1px #fff1; }
|
|
55
|
-
.result-card .eyebrow, .pause-card .eyebrow { color: var(--cyan); }
|
|
56
|
-
.result-card h2 { font-size: 30px; letter-spacing: -1.2px; }
|
|
57
|
-
.result-score { display: grid; gap: 8px; padding: 24px 0; }
|
|
58
|
-
.result-score strong { font: 900 italic 92px/.85 Arial,sans-serif; letter-spacing: -5px; }
|
|
59
|
-
.result-score span { font: 8px monospace; letter-spacing: 2px; color: var(--muted); }
|
|
60
|
-
.result-stats { display: flex; justify-content: space-between; border-top: 1px solid #977aa544; padding-top: 17px; margin-bottom: 24px; }
|
|
61
|
-
.result-stats > span { display: grid; gap: 8px; font: 7px monospace; letter-spacing: 1px; color: var(--muted); }
|
|
62
|
-
.result-stats b { color: #fff4fa; font: 18px monospace; }
|
|
63
|
-
.result-card .primary, .pause-card .primary { width: 100%; min-width: 0; }
|
|
64
|
-
.pause-card .primary { margin-top: 30px; }
|
|
65
|
-
.bottom { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); width: min(680px,calc(100% - 56px)); display: grid; grid-template-columns: 1fr 1.15fr .85fr; align-items: stretch; gap: 8px; padding: 8px; z-index: 3; border: 1px solid #977aa55c; border-radius: 18px; background: linear-gradient(110deg,#25172ee8,#0c091eed); box-shadow: 0 12px 36px #0006,inset 0 1px #fff1; }
|
|
66
|
-
.is-intro .bottom, .is-ended .bottom, .is-paused .bottom { width: min(420px,calc(100% - 56px)); grid-template-columns: 1.2fr 1fr; }
|
|
67
|
-
.cat-button { display: flex; align-items: center; background: transparent; border-radius: 11px; color: #f7efff; text-align: left; padding: 2px 8px 2px 2px; gap: 8px; min-width: 0; }
|
|
68
|
-
.cat-button:hover, .shop-button:hover { background: #684d772e; }
|
|
69
|
-
.cat-button canvas { width: 48px; height: 44px; flex-shrink: 0; }
|
|
70
|
-
.cat-button small { display: flex; gap: 8px; font: 8px monospace; letter-spacing: .8px; margin-bottom: 5px; color: var(--muted); white-space: nowrap; }
|
|
71
|
-
.cat-button b { font-size: 12px; white-space: nowrap; display: block; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
|
|
72
|
-
.cat-button svg { width: 15px; height: 15px; margin-left: auto; color: var(--muted); }
|
|
73
|
-
.shop-button { background: transparent; border-radius: 11px; color: #f6efff; padding: 8px 10px; font-size: 11px; font-weight: bold; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 10px; }
|
|
74
|
-
.shop-button > svg { width: 27px; height: 27px; color: var(--foil); }
|
|
75
|
-
.shop-button > span { text-align: left; }
|
|
76
|
-
.drop-button { padding: 16px 18px; min-height: 56px; border-radius: 10px; background: var(--lime); color: #201432; box-shadow: 0 0 24px #baff5f14,inset 0 -3px #0002; font-weight: bold; font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-transform: uppercase; font-style: italic; transition: background .15s; }
|
|
77
|
-
.drop-button:hover { background: #d3ff93; }
|
|
78
|
-
.drop-button:active { background: #a8eb4f; }
|
|
79
|
-
.drop-button kbd { font: 8px monospace; padding: 4px 6px; border: 1px solid #20143244; border-radius: 4px; }
|
|
80
|
-
#callout { position: absolute; top: 20%; left: 0; right: 0; text-align: center; font: 900 italic clamp(20px,3vw,29px) Arial,sans-serif; pointer-events: none; color: var(--lime); text-shadow: 0 0 24px #bfff7d66; }
|
|
81
|
-
#collection { width: min(600px,calc(100% - 28px)); max-height: calc(100% - 36px); overflow: auto; border: 1px solid #74529399; border-radius: 20px; background: #160c29f5; color: #f7efff; padding: 26px; box-shadow: 0 35px 110px #01000699; }
|
|
82
|
-
#collection::backdrop { background: #070216aa; backdrop-filter: blur(8px); }
|
|
83
|
-
#collection header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
|
|
84
|
-
#collection .eyebrow { color: var(--cyan); }
|
|
85
|
-
#collection header h2 { font: 900 italic 28px Arial,sans-serif; letter-spacing: -1.5px; }
|
|
86
|
-
#collection header button { background: #322045; color: #fff; border-radius: 12px; width: 44px; height: 44px; font-size: 25px; flex-shrink: 0; }
|
|
87
|
-
.collection-summary { display: flex; justify-content: space-between; font: 9px monospace; color: var(--muted); margin-top: 22px; }
|
|
88
|
-
#skins { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 12px; }
|
|
89
|
-
#skins button { position: relative; display: flex; flex-direction: column; align-items: center; border-radius: 12px; padding: 10px 5px 14px; background: #2a1841; border: 1px solid #7b5da659; border-top: 2px solid var(--skin-color); min-width: 0; }
|
|
90
|
-
#skins button[aria-pressed=true] { border-color: var(--lime); background: #2c382b; box-shadow: 0 0 22px #adff6616; }
|
|
91
|
-
#skins button[aria-pressed=true] small { color: var(--lime); }
|
|
92
|
-
#skins button:disabled { background: #211530; }
|
|
93
|
-
#skins button:disabled canvas { opacity: .42; }
|
|
94
|
-
.skin-rarity { font: 7px monospace; letter-spacing: 1.1px; color: var(--skin-color); }
|
|
95
|
-
#skins canvas { width: 90px; max-width: 100%; height: 85px; margin-top: 8px; }
|
|
96
|
-
#skins b { font-size: 11px; margin-top: 8px; text-align: center; color: #f6eaff; }
|
|
97
|
-
#skins small { font: 7px monospace; letter-spacing: .7px; margin-top: 7px; color: var(--muted); }
|
|
98
|
-
#collection p { font-size: 11px; color: var(--muted); margin: 18px 0; }
|
|
99
|
-
#collection > .primary { width: 100%; margin-top: 14px; }
|
|
100
|
-
#error { position: absolute; bottom: 108px; left: 20px; right: 20px; border-radius: 12px; padding: 12px 16px; background: #251433f2; color: #ffdee9; border: 1px solid #b46798; font-size: 11px; z-index: 5; margin: 0; }
|
|
101
|
-
#error button { margin-left: 10px; text-decoration: underline; background: none; min-height: 24px; }
|
|
102
|
-
@media (max-width: 950px) {
|
|
103
|
-
.is-playing .wordmark, .is-paused .wordmark { display: none; }
|
|
104
|
-
.run-hud { flex: 1; justify-content: space-between; }
|
|
105
|
-
.top { gap: 20px; }
|
|
106
|
-
.top-right { gap: 14px; }
|
|
107
|
-
}
|
|
108
|
-
@media (max-width: 650px) {
|
|
109
|
-
.intro-copy { left: 0; right: 0; top: 13%; text-align: center; }
|
|
110
|
-
.intro-copy .eyebrow { font-size: 8px; letter-spacing: 2.5px; }
|
|
111
|
-
h1 { font-size: 52px; letter-spacing: -3px; margin: 17px 0 10px; }
|
|
112
|
-
h1 em { letter-spacing: -2px; }
|
|
113
|
-
#intro > .primary { left: 50%; transform: translateX(-50%); bottom: 20%; padding: 15px 20px; }
|
|
114
|
-
#intro > small { left: 0; right: 0; bottom: calc(20% - 25px); text-align: center; }
|
|
115
|
-
.wordmark { font-size: 17px; }
|
|
116
|
-
.wordmark span { font-size: 6px; }
|
|
117
|
-
.top { top: 16px; left: 16px; right: 16px; gap: 8px; }
|
|
118
|
-
.is-playing .best-stat, .is-paused .best-stat { display: none; }
|
|
119
|
-
.run-hud { border: 0; background: transparent; box-shadow: none; padding: 0; gap: 12px; }
|
|
120
|
-
.score { display: grid; gap: 5px; }
|
|
121
|
-
.score strong { font-size: 38px; min-width: 25px; }
|
|
122
|
-
.score > span { font-size: 7px; letter-spacing: .4px; white-space: nowrap; }
|
|
123
|
-
.score > span br { display: none; }
|
|
124
|
-
.width-stat { width: 75px; min-width: 55px; flex: 1; }
|
|
125
|
-
.stat-label { font-size: 8px; letter-spacing: 0; gap: 4px; }
|
|
126
|
-
.stat-label b { font-size: 10px; }
|
|
127
|
-
.streak-stat { width: 65px; flex-shrink: 0; }
|
|
128
|
-
.streak-help { top: calc(100% + 10px); font-size: 7px; letter-spacing: .3px; }
|
|
129
|
-
#width-meter, #streak-pips { margin-top: 8px; }
|
|
130
|
-
.top-right button { border-radius: 10px; }
|
|
131
|
-
.bottom { width: calc(100% - 28px); bottom: 14px; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px; border-radius: 16px; }
|
|
132
|
-
.is-intro .bottom, .is-ended .bottom, .is-paused .bottom { width: calc(100% - 28px); }
|
|
133
|
-
.drop-button { grid-row: 2; grid-column: 1 / -1; justify-content: center; gap: 16px; min-height: 48px; padding: 12px 16px; }
|
|
134
|
-
.drop-button kbd { display: none; }
|
|
135
|
-
.cat-button { padding-right: 6px; gap: 6px; }
|
|
136
|
-
.cat-button canvas { width: 40px; height: 38px; }
|
|
137
|
-
.cat-button small { font-size: 7px; gap: 5px; }
|
|
138
|
-
.cat-button b { font-size: 11px; max-width: 104px; }
|
|
139
|
-
.cat-button svg { display: none; }
|
|
140
|
-
.shop-button { justify-self: end; gap: 8px; font-size: 11px; }
|
|
141
|
-
.shop-button > svg { width: 23px; height: 23px; }
|
|
142
|
-
#callout { top: 18%; }
|
|
143
|
-
#collection { padding: 20px; }
|
|
144
|
-
#collection header h2 { font-size: 24px; }
|
|
145
|
-
#collection .eyebrow { font-size: 7px; letter-spacing: 1.5px; }
|
|
146
|
-
#skins { gap: 6px; }
|
|
147
|
-
#skins b { font-size: 9px; }
|
|
148
|
-
#skins canvas { width: 75px; height: 70px; }
|
|
149
|
-
#skins small, .skin-rarity { font-size: 7px; }
|
|
150
|
-
.collection-summary { font-size: 8px; }
|
|
151
|
-
.eyebrow { font-size: 8px; }
|
|
152
|
-
.is-playing #error { bottom: 140px; }
|
|
153
|
-
}
|
|
154
|
-
@media (max-height: 530px) {
|
|
155
|
-
.top { top: 12px; }
|
|
156
|
-
.bottom { bottom: 12px; }
|
|
157
|
-
.run-hud { padding-top: 10px; padding-bottom: 10px; }
|
|
158
|
-
.result-card { padding: 20px; width: 300px; }
|
|
159
|
-
.result-score { padding: 14px 0; }
|
|
160
|
-
.result-score strong { font-size: 56px; }
|
|
161
|
-
.result-stats { margin-bottom: 16px; padding-top: 12px; }
|
|
162
|
-
.result-card h2 { font-size: 26px; }
|
|
163
|
-
.is-ended .bottom { display: none; }
|
|
164
|
-
}
|
|
165
|
-
@media (max-height: 530px) and (min-width: 651px) {
|
|
166
|
-
h1 { font-size: 50px; }
|
|
167
|
-
#intro > .primary { bottom: 24%; }
|
|
168
|
-
#intro > small { bottom: calc(24% - 22px); }
|
|
169
|
-
#callout { top: 27%; }
|
|
170
|
-
}
|
|
171
|
-
@media (prefers-reduced-motion: reduce) {
|
|
172
|
-
*, *:before, *:after { transition: none !important; animation: none !important; }
|
|
173
|
-
#result, .pause-overlay, #collection::backdrop { backdrop-filter: none; }
|
|
174
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Chonk Stack</title><link rel="stylesheet" href="./game.css"></head>
|
|
4
|
-
<body>
|
|
5
|
-
<main id="stack" aria-label="Chonk Stack">
|
|
6
|
-
<canvas id="board" aria-label="Your tower of trading cards"></canvas>
|
|
7
|
-
<header class="top">
|
|
8
|
-
<div class="wordmark">CHONK<span>STACK / 3D</span></div>
|
|
9
|
-
<div class="run-hud" aria-label="Run stats">
|
|
10
|
-
<div class="score" aria-live="polite" aria-atomic="true"><strong id="score">0</strong><span>CARDS <br>HIGH</span></div>
|
|
11
|
-
<div class="width-stat"><div class="stat-label"><span>WIDTH</span><b id="width-value">100%</b></div><div id="width-meter" role="meter" aria-label="Remaining card width" aria-valuemin="0" aria-valuemax="100" aria-valuenow="100"><i id="width-fill"></i></div></div>
|
|
12
|
-
<div class="streak-stat"><div class="stat-label"><span>PERFECT</span><b id="combo">×0</b></div><div id="streak-pips" aria-hidden="true"><i></i><i></i><i></i></div><span class="streak-help" id="streak-help">3 IN A ROW → WIDER CARD</span></div>
|
|
13
|
-
</div>
|
|
14
|
-
<div class="top-right"><div class="best-stat"><span>SESSION BEST</span><b id="best">0</b></div><button id="pause" aria-label="Pause game" hidden><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8 6v12M16 6v12"/></svg></button></div>
|
|
15
|
-
</header>
|
|
16
|
-
<section id="intro" class="overlay">
|
|
17
|
-
<div class="intro-copy"><span class="eyebrow">AFTER HOURS ARCADE</span><h1>STACK THE<br><em>IMPOSSIBLE.</em></h1></div>
|
|
18
|
-
<button id="play" class="primary">Let’s stack <span>↗</span></button><small>TAP OR SPACE TO DROP</small>
|
|
19
|
-
</section>
|
|
20
|
-
<section id="result" class="overlay" hidden aria-label="Run result"><div class="result-card"><span id="result-label" class="eyebrow">RUN COMPLETE</span><h2 id="result-title">Nice stack.</h2><div class="result-score"><strong id="result-score">0</strong><span>CARDS HIGH</span></div><div class="result-stats"><span>BEST STREAK <b id="result-streak">×0</b></span><span>SESSION BEST <b id="result-best">0</b></span></div><button id="again" class="primary">Play again <span>↻</span></button></div></section>
|
|
21
|
-
<section id="paused" class="overlay pause-overlay" hidden><div class="pause-card"><span class="eyebrow">TOWER SAVED</span><h2>Paused.</h2><button id="resume" class="primary">Resume <span>▶</span></button></div></section>
|
|
22
|
-
<div id="callout" aria-live="polite"></div>
|
|
23
|
-
<footer class="bottom">
|
|
24
|
-
<button id="wardrobe" class="cat-button" aria-haspopup="dialog"><canvas id="avatar" width="100" height="90" aria-hidden="true"></canvas><span><small>YOUR CHONK <span id="wardrobe-count">1/6</span></small><b id="cat-name">Cloud</b></span><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 5h5v5H5zM14 5h5v5h-5zM5 14h5v5H5zM14 14h5v5h-5z"/></svg></button>
|
|
25
|
-
<button id="drop" class="drop-button" hidden><span>Drop card</span><kbd>SPACE</kbd><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v16m-6-6 6 6 6-6"/></svg></button>
|
|
26
|
-
<button id="shop" class="shop-button"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m4 6 12-3 4 15-12 3zM8 8h8M10 16h5"/></svg><span>After Hours ↗</span></button>
|
|
27
|
-
</footer>
|
|
28
|
-
<dialog id="collection" aria-labelledby="collection-title"><header><div><span class="eyebrow">AFTER HOURS COLLECTION</span><h2 id="collection-title">YOUR CHONKS.</h2></div><button id="close-collection" aria-label="Close collection">×</button></header><div class="collection-summary"><span id="owned-count">1 / 6 available</span><span>Cosmetic skins</span></div><div id="skins"></div><p>Collect a card from an After Hours pack to unlock its chonk.</p><button id="collection-shop" class="primary">Explore packs <span>↗</span></button></dialog>
|
|
29
|
-
<p id="error" role="alert" hidden></p>
|
|
30
|
-
</main>
|
|
31
|
-
<script defer src="./game.js"></script>
|
|
32
|
-
</body></html>
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { connectGameSdk, watchInventory, type GameSdk } from "@vibechain/os";
|
|
2
|
-
import { StackRenderer } from "./renderer";
|
|
3
|
-
import { START_WIDTH } from "./model";
|
|
4
|
-
import { drawCat, ownedSkins, SKINS } from "./skins";
|
|
5
|
-
import "./game.css";
|
|
6
|
-
|
|
7
|
-
function element<T extends HTMLElement>(id: string): T {
|
|
8
|
-
const node = document.getElementById(id);
|
|
9
|
-
if (!node) throw Error(`Missing game element: ${id}`);
|
|
10
|
-
return node as T;
|
|
11
|
-
}
|
|
12
|
-
const root = element("stack"), board = element<HTMLCanvasElement>("board");
|
|
13
|
-
const intro = element("intro"), result = element("result"), paused = element("paused");
|
|
14
|
-
const collection = element<HTMLDialogElement>("collection"), error = element("error");
|
|
15
|
-
const dropButton = element<HTMLButtonElement>("drop"), pauseButton = element<HTMLButtonElement>("pause");
|
|
16
|
-
const abort = new AbortController();
|
|
17
|
-
let sdk: GameSdk | undefined;
|
|
18
|
-
let inventory: ReturnType<typeof watchInventory> | undefined;
|
|
19
|
-
let selected = 0, owned = new Set([0]), best = 0;
|
|
20
|
-
let playing = false, isPaused = false, disposed = false;
|
|
21
|
-
let calloutTimer = 0, previousWidth = START_WIDTH;
|
|
22
|
-
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
23
|
-
|
|
24
|
-
// HUD work happens on accepted drops, never inside the render loop.
|
|
25
|
-
function syncHud() {
|
|
26
|
-
const { score, combo, layers, ended } = renderer.state;
|
|
27
|
-
const percent = ended ? 0 : Math.round(layers[layers.length - 1].width / START_WIDTH * 100);
|
|
28
|
-
element("score").textContent = String(score);
|
|
29
|
-
element("width-value").textContent = `${percent}%`;
|
|
30
|
-
element("width-meter").setAttribute("aria-valuenow", String(percent));
|
|
31
|
-
element("width-meter").dataset.narrow = String(percent < 30);
|
|
32
|
-
element("width-fill").style.transform = `scaleX(${percent / 100})`;
|
|
33
|
-
element("combo").textContent = `×${combo}`;
|
|
34
|
-
element("streak-pips").querySelectorAll("i").forEach((pip, index) => { pip.dataset.lit = String(combo > index); });
|
|
35
|
-
element("streak-help").textContent = combo >= 3 ? "WIDTH BOOST ACTIVE" : "3 IN A ROW → WIDER CARD";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function showError(message: string) { error.textContent = message; error.hidden = !message; }
|
|
39
|
-
const renderer = new StackRenderer(board, (score, combo, ended) => {
|
|
40
|
-
syncHud();
|
|
41
|
-
const currentWidth = renderer.state.layers[renderer.state.layers.length - 1].width;
|
|
42
|
-
const restoredWidth = currentWidth > previousWidth; previousWidth = currentWidth;
|
|
43
|
-
window.clearTimeout(calloutTimer);
|
|
44
|
-
const callout = element("callout");
|
|
45
|
-
callout.textContent = ended ? "" : restoredWidth ? "Perfect. Wider card!" : combo >= 2 ? `Perfect ×${combo}` : combo ? "Perfect." : "";
|
|
46
|
-
if (!ended && !reduceMotion.matches) {
|
|
47
|
-
element("score").animate([{ transform: "translateY(4px)", opacity: .5 }, { transform: "translateY(0)", opacity: 1 }], { duration: 200, easing: "ease-out" });
|
|
48
|
-
if (combo) callout.animate([{ opacity: 0, transform: "translateY(10px) scale(.94)" }, { opacity: 1, transform: "translateY(0) scale(1)" }], { duration: 200, easing: "ease-out" });
|
|
49
|
-
}
|
|
50
|
-
calloutTimer = window.setTimeout(() => { callout.textContent = ""; }, 950);
|
|
51
|
-
if (ended) {
|
|
52
|
-
const newBest = score > best;
|
|
53
|
-
playing = false; best = Math.max(best, score);
|
|
54
|
-
element("best").textContent = String(best);
|
|
55
|
-
root.className = "is-ended"; result.hidden = false; dropButton.hidden = true; pauseButton.hidden = true;
|
|
56
|
-
element("result-label").textContent = newBest ? "NEW SESSION BEST" : "RUN COMPLETE";
|
|
57
|
-
element("result-title").textContent = score === 0 ? "One more try?" : score >= 20 ? "Above the clouds." : "Nice stack.";
|
|
58
|
-
element("result-score").textContent = String(score);
|
|
59
|
-
element("result-streak").textContent = `×${renderer.state.bestCombo}`;
|
|
60
|
-
element("result-best").textContent = String(best);
|
|
61
|
-
element<HTMLButtonElement>("again").focus({ preventScroll: true });
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
function pause(value: boolean) {
|
|
66
|
-
if (!playing) return;
|
|
67
|
-
isPaused = value; renderer.pause(value); paused.hidden = !value;
|
|
68
|
-
dropButton.hidden = value; pauseButton.hidden = value;
|
|
69
|
-
root.className = value ? "is-paused" : "is-playing";
|
|
70
|
-
if (value) element("resume").focus({ preventScroll: true });
|
|
71
|
-
}
|
|
72
|
-
function start() {
|
|
73
|
-
intro.hidden = true; result.hidden = true; paused.hidden = true;
|
|
74
|
-
root.className = "is-playing"; playing = true; isPaused = false;
|
|
75
|
-
dropButton.hidden = false; pauseButton.hidden = false;
|
|
76
|
-
window.clearTimeout(calloutTimer); element("callout").textContent = "";
|
|
77
|
-
previousWidth = START_WIDTH; renderer.start(); syncHud(); dropButton.focus({ preventScroll: true });
|
|
78
|
-
}
|
|
79
|
-
function drawAvatar(canvas: HTMLCanvasElement, skin: number) {
|
|
80
|
-
const c = canvas.getContext("2d");
|
|
81
|
-
if (!c) return;
|
|
82
|
-
c.clearRect(0, 0, canvas.width, canvas.height);
|
|
83
|
-
drawCat(c, canvas.width / 2, canvas.height - 5, Math.min(canvas.width * 0.9, canvas.height), skin);
|
|
84
|
-
}
|
|
85
|
-
function renderCollection() {
|
|
86
|
-
if (!owned.has(selected)) selected = 0;
|
|
87
|
-
renderer.setSkin(selected);
|
|
88
|
-
element("cat-name").textContent = SKINS[selected].name;
|
|
89
|
-
element("wardrobe-count").textContent = `${owned.size}/${SKINS.length}`;
|
|
90
|
-
element("owned-count").textContent = `${owned.size} / ${SKINS.length} available`;
|
|
91
|
-
element("wardrobe").setAttribute("aria-label", `Choose chonk, ${SKINS[selected].name} equipped, ${owned.size} of ${SKINS.length} available`);
|
|
92
|
-
drawAvatar(element<HTMLCanvasElement>("avatar"), selected);
|
|
93
|
-
const grid = element("skins"); grid.replaceChildren();
|
|
94
|
-
SKINS.forEach((skin, index) => {
|
|
95
|
-
const button = document.createElement("button"); button.type = "button";
|
|
96
|
-
button.setAttribute("aria-label", `${owned.has(index) ? "Equip" : "Locked"} ${skin.name}`);
|
|
97
|
-
button.setAttribute("aria-pressed", String(selected === index)); button.disabled = !owned.has(index);
|
|
98
|
-
button.style.setProperty("--skin-color", skin.accent);
|
|
99
|
-
const rarity = document.createElement("span"); rarity.className = "skin-rarity"; rarity.textContent = skin.label;
|
|
100
|
-
const avatar = document.createElement("canvas"); avatar.width = 180; avatar.height = 170; avatar.setAttribute("aria-hidden", "true");
|
|
101
|
-
drawAvatar(avatar, index);
|
|
102
|
-
const name = document.createElement("b"); name.textContent = skin.name;
|
|
103
|
-
const label = document.createElement("small"); label.textContent = selected === index ? "✓ EQUIPPED" : owned.has(index) ? "EQUIP ↗" : "LOCKED";
|
|
104
|
-
button.append(rarity, avatar, name, label);
|
|
105
|
-
button.onclick = () => { if (!owned.has(index)) return; selected = index; renderCollection(); collection.close(); element("wardrobe").focus({ preventScroll: true }); };
|
|
106
|
-
grid.append(button);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
element("play").onclick = start; element("again").onclick = start;
|
|
110
|
-
dropButton.onclick = () => renderer.input(); board.onclick = () => renderer.input();
|
|
111
|
-
pauseButton.onclick = () => pause(true); element("resume").onclick = () => { pause(false); dropButton.focus({ preventScroll: true }); };
|
|
112
|
-
element("wardrobe").onclick = () => { pause(true); collection.showModal(); };
|
|
113
|
-
element("close-collection").onclick = () => collection.close();
|
|
114
|
-
const shop = async () => {
|
|
115
|
-
pause(true); if (collection.open) collection.close();
|
|
116
|
-
if (!sdk) { showError("The collection is connecting. You can keep playing."); return; }
|
|
117
|
-
try { await sdk.showShop(); } catch (reason) { showError(reason instanceof Error ? reason.message : "Reopen the game to reconnect the collection."); }
|
|
118
|
-
};
|
|
119
|
-
element("shop").onclick = () => { void shop(); }; element("collection-shop").onclick = () => { void shop(); };
|
|
120
|
-
window.addEventListener("keydown", event => {
|
|
121
|
-
if (collection.open || event.repeat) return;
|
|
122
|
-
if (event.key === "Escape" && playing) { event.preventDefault(); pause(!isPaused); return; }
|
|
123
|
-
if (event.code !== "Space") return;
|
|
124
|
-
// Buttons already translate Space into one click; never double-drop.
|
|
125
|
-
if (event.target instanceof HTMLElement && event.target.closest("button,a,input")) return;
|
|
126
|
-
event.preventDefault(); if (!playing) start(); else if (isPaused) pause(false); else renderer.input();
|
|
127
|
-
}, { signal: abort.signal });
|
|
128
|
-
document.addEventListener("visibilitychange", () => { if (document.hidden) pause(true); }, { signal: abort.signal });
|
|
129
|
-
window.addEventListener("blur", () => pause(true), { signal: abort.signal });
|
|
130
|
-
|
|
131
|
-
renderCollection(); root.className = "is-intro";
|
|
132
|
-
performance.mark("chonk-stack-first-frame");
|
|
133
|
-
void connectGameSdk(abort.signal).then(async connection => {
|
|
134
|
-
if (disposed) { connection.destroy(); return; }
|
|
135
|
-
sdk = connection;
|
|
136
|
-
await sdk.ready(); // Free play doesn't wait for catalog or paginated inventory.
|
|
137
|
-
if (disposed) return;
|
|
138
|
-
inventory = watchInventory(sdk, {
|
|
139
|
-
onChange(value) { owned = ownedSkins(value.cards); renderCollection(); showError(""); },
|
|
140
|
-
onError() {
|
|
141
|
-
// Cosmetic authority fails closed. Never retain an unverified entitlement.
|
|
142
|
-
owned = new Set([0]); renderCollection(); showError("Collection refresh failed. Starter is available.");
|
|
143
|
-
const retry = document.createElement("button"); retry.textContent = "Retry"; retry.onclick = () => { void inventory?.refresh(); }; error.append(retry);
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
}).catch(() => { if (!disposed) showError("Playing offline. Open through VibeMarket to use your collection."); });
|
|
147
|
-
window.addEventListener("pagehide", () => {
|
|
148
|
-
disposed = true; inventory?.destroy(); sdk?.destroy(); renderer.destroy(); abort.abort(); window.clearTimeout(calloutTimer);
|
|
149
|
-
}, { once: true });
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export interface CardLayer { x: number; width: number; level: number; perfect: boolean }
|
|
2
|
-
export interface StackState {
|
|
3
|
-
layers: CardLayer[]; moving: CardLayer; direction: 1 | -1;
|
|
4
|
-
score: number; combo: number; bestCombo: number; ended: boolean;
|
|
5
|
-
}
|
|
6
|
-
export const BOARD_WIDTH = 480;
|
|
7
|
-
export const START_WIDTH = 228;
|
|
8
|
-
export const RETAINED_LAYERS = 36;
|
|
9
|
-
export function newStack(): StackState {
|
|
10
|
-
return { layers: [{ x: 126, width: START_WIDTH, level: 0, perfect: false }],
|
|
11
|
-
moving: { x: 18, width: START_WIDTH, level: 1, perfect: false },
|
|
12
|
-
direction: 1, score: 0, combo: 0, bestCombo: 0, ended: false };
|
|
13
|
-
}
|
|
14
|
-
export function advance(state: StackState, seconds: number) {
|
|
15
|
-
if (state.ended) return;
|
|
16
|
-
const distance = Math.max(0, Math.min(seconds, 0.05)) * Math.min(220, 105 + state.score * 3.2);
|
|
17
|
-
const min = 16, max = BOARD_WIDTH - 16 - state.moving.width;
|
|
18
|
-
state.moving.x += distance * state.direction;
|
|
19
|
-
if (state.moving.x > max) { state.moving.x = 2 * max - state.moving.x; state.direction = -1; }
|
|
20
|
-
if (state.moving.x < min) { state.moving.x = 2 * min - state.moving.x; state.direction = 1; }
|
|
21
|
-
}
|
|
22
|
-
export function drop(state: StackState): { perfect: boolean; offcut: CardLayer | null } {
|
|
23
|
-
if (state.ended) return { perfect: false, offcut: null };
|
|
24
|
-
const top = state.layers[state.layers.length - 1], moving = state.moving;
|
|
25
|
-
const delta = moving.x - top.x;
|
|
26
|
-
const perfect = Math.abs(delta) <= Math.min(5, top.width * 0.08);
|
|
27
|
-
const left = Math.max(moving.x, top.x), right = Math.min(moving.x + moving.width, top.x + top.width);
|
|
28
|
-
if (right - left < 5) { state.ended = true; return { perfect: false, offcut: { ...moving } }; }
|
|
29
|
-
const offcut = perfect ? null : { x: delta > 0 ? right : moving.x, width: Math.abs(delta), level: moving.level, perfect: false };
|
|
30
|
-
state.combo = perfect ? state.combo + 1 : 0;
|
|
31
|
-
state.bestCombo = Math.max(state.bestCombo, state.combo);
|
|
32
|
-
const width = perfect ? Math.min(START_WIDTH, top.width + (state.combo >= 3 ? 8 : 0)) : right - left;
|
|
33
|
-
const x = perfect ? top.x - (width - top.width) / 2 : left;
|
|
34
|
-
state.score++;
|
|
35
|
-
state.layers.push({ x, width, level: state.score, perfect });
|
|
36
|
-
if (state.layers.length > RETAINED_LAYERS) state.layers.shift();
|
|
37
|
-
state.direction = state.score % 2 ? -1 : 1;
|
|
38
|
-
state.moving = { x: state.direction === 1 ? 16 : BOARD_WIDTH - 16 - width, width, level: state.score + 1, perfect: false };
|
|
39
|
-
return { perfect, offcut };
|
|
40
|
-
}
|