@muvtacode/cli 0.1.9 → 0.1.10
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/dist/agent/loop.js +4 -1
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/prompt.js +101 -0
- package/dist/agent/prompt.js.map +1 -1
- package/dist/cli.js +102 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/index.js +28 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/i18n/en.js +4 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/pt.js +4 -0
- package/dist/i18n/pt.js.map +1 -1
- package/dist/remote/claudeSessions.js +82 -0
- package/dist/remote/claudeSessions.js.map +1 -0
- package/dist/remote/host.js +530 -0
- package/dist/remote/host.js.map +1 -0
- package/dist/remote/passagem.js +545 -0
- package/dist/remote/passagem.js.map +1 -0
- package/dist/state/templates.js +43 -10
- package/dist/state/templates.js.map +1 -1
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/AssaultRifle_1.mtl +42 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/AssaultRifle_1.obj +1472 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Grip.mtl +12 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Grip.obj +890 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/LICENCA.txt +25 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_1.mtl +52 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_1.obj +1444 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_4.mtl +32 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_4.obj +1789 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Revolver_1.mtl +32 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Revolver_1.obj +1273 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Scope_1.mtl +32 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Scope_1.obj +485 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Shotgun_1.mtl +42 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Shotgun_1.obj +1589 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Silencer_1.mtl +12 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Silencer_1.obj +309 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SniperRifle_1.mtl +52 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SniperRifle_1.obj +1681 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SubmachineGun_1.mtl +42 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SubmachineGun_1.obj +1275 -0
- package/dist/templates/game/adapt-assets-3d-01/files/src/assets/modelos.ts +270 -0
- package/dist/templates/game/adapt-assets-3d-01/meta.json +30 -0
- package/dist/templates/game/adapt-audio-01/files/src/audio/audio.ts +123 -6
- package/dist/templates/game/adapt-audio-01/meta.json +47 -34
- package/dist/templates/game/adapt-camera-rig-01/files/src/camera/rig.ts +226 -55
- package/dist/templates/game/adapt-camera-rig-01/meta.json +53 -38
- package/dist/templates/game/adapt-controle-teclado-01/files/src/controles/teclado.ts +175 -171
- package/dist/templates/game/adapt-controle-teclado-01/meta.json +36 -34
- package/dist/templates/game/adapt-controle-toque-01/files/src/controles/toque.ts +152 -36
- package/dist/templates/game/adapt-controle-toque-01/meta.json +43 -36
- package/dist/templates/game/adapt-dia-noite-01/files/src/world/dianoite.ts +274 -53
- package/dist/templates/game/adapt-dia-noite-01/meta.json +21 -9
- package/dist/templates/game/adapt-hud-01/files/src/hud/hud.ts +859 -263
- package/dist/templates/game/adapt-hud-01/meta.json +69 -36
- package/dist/templates/game/adapt-menu-01/files/src/ui/menu.ts +427 -273
- package/dist/templates/game/adapt-menu-01/meta.json +41 -36
- package/dist/templates/game/adapt-particulas-01/files/src/vfx/particulas.ts +107 -39
- package/dist/templates/game/adapt-particulas-01/meta.json +50 -38
- package/dist/templates/game/adapt-perf-mobile-01/files/src/engine/performance.ts +108 -33
- package/dist/templates/game/adapt-perf-mobile-01/meta.json +20 -6
- package/dist/templates/game/adapt-primeira-pessoa-01/files/src/camera/primeirapessoa.ts +595 -0
- package/dist/templates/game/adapt-primeira-pessoa-01/meta.json +63 -0
- package/dist/templates/game/estruturas-3d-01/files/src/world/estruturas.ts +490 -0
- package/dist/templates/game/estruturas-3d-01/meta.json +13 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/arena.ts +324 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/armas.ts +398 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/cena.ts +801 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/coletaveis.ts +129 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/fisica.ts +257 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/inimigos.ts +608 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/jogador.ts +224 -0
- package/dist/templates/game/fps-3d-01/files/src/main.ts +21 -0
- package/dist/templates/game/fps-3d-01/meta.json +48 -0
- package/dist/templates/game/game-engine-base-01/files/index.html +37 -0
- package/dist/templates/game/game-engine-base-01/files/package.json +19 -0
- package/dist/templates/game/game-engine-base-01/files/src/engine/engine.ts +22 -2
- package/dist/templates/game/game-engine-base-01/files/src/engine/index.ts +22 -2
- package/dist/templates/game/game-engine-base-01/files/src/engine/input.ts +430 -58
- package/dist/templates/game/game-engine-base-01/files/src/engine/layout.ts +192 -0
- package/dist/templates/game/game-engine-base-01/files/tsconfig.json +14 -0
- package/dist/templates/game/game-engine-base-01/files/vite.config.ts +10 -0
- package/dist/templates/game/game-engine-base-01/meta.json +70 -13
- package/dist/templates/game/mundo-3d-01/files/src/world/mundo3d.ts +2953 -73
- package/dist/templates/game/mundo-3d-01/meta.json +125 -6
- package/dist/templates/game/npc-3d-01/files/src/ai/npc3d.ts +658 -0
- package/dist/templates/game/npc-3d-01/meta.json +13 -0
- package/dist/templates/game/personagem-3d-01/files/src/models/personagem3d.ts +428 -107
- package/dist/templates/game/personagem-3d-01/meta.json +60 -6
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
|
-
// Controle por toque: joystick virtual + botões de ação.
|
|
2
|
+
// Controle por toque: joystick virtual + botões de ação + zona de olhar.
|
|
3
3
|
//
|
|
4
4
|
// Decisões que fazem diferença no celular:
|
|
5
5
|
//
|
|
@@ -15,11 +15,24 @@
|
|
|
15
15
|
//
|
|
16
16
|
// 4. Escreve no Input do engine. O gameplay continua chamando input.eixo() e
|
|
17
17
|
// não sabe que veio de toque.
|
|
18
|
+
//
|
|
19
|
+
// 5. RESERVA o dedo que está num controle (`input.reservarPonteiro`) e declara
|
|
20
|
+
// sua área (`input.definirZonaDeControle`). Sem isso, arrastar o joystick
|
|
21
|
+
// também girava a câmera — os dois liam o mesmo pointermove. Com a reserva,
|
|
22
|
+
// a divisão fica clara: metade do joystick anda, a outra metade olha.
|
|
23
|
+
//
|
|
24
|
+
// 6. REGISTRA as zonas que ocupa no layout do engine, para o HUD não desenhar o
|
|
25
|
+
// minimapa em cima dos botões (era exatamente o que acontecia: os dois
|
|
26
|
+
// ficavam no canto inferior direito, e o HUD por estar num z-index maior
|
|
27
|
+
// ganhava).
|
|
18
28
|
// ---------------------------------------------------------------------------
|
|
19
29
|
|
|
20
|
-
import type { Input, Acao } from '../engine';
|
|
30
|
+
import type { Input, Acao, Zona } from '../engine';
|
|
31
|
+
import { safeArea, registrarZonas, removerZonas } from '../engine';
|
|
21
32
|
import { getPalette, alpha } from '../design/tokens';
|
|
22
33
|
|
|
34
|
+
const NOME_ZONA = 'controle-toque';
|
|
35
|
+
|
|
23
36
|
export const tuning = {
|
|
24
37
|
/** Raio do joystick em px (na densidade CSS). */
|
|
25
38
|
raioBase: 62,
|
|
@@ -35,7 +48,13 @@ export const tuning = {
|
|
|
35
48
|
opacidade: 0.32,
|
|
36
49
|
opacidadeAtiva: 0.6,
|
|
37
50
|
/** Margem extra além do safe-area (notch / barra de gestos). */
|
|
38
|
-
margem: 24
|
|
51
|
+
margem: 24,
|
|
52
|
+
/**
|
|
53
|
+
* Fração da altura da tela, a partir do topo, que NÃO aceita joystick.
|
|
54
|
+
* Deixa a faixa superior livre para arrastar a câmera com o polegar esquerdo.
|
|
55
|
+
*/
|
|
56
|
+
fracaoSuperiorLivre: 0.25,
|
|
57
|
+
vibrar: true
|
|
39
58
|
};
|
|
40
59
|
|
|
41
60
|
export interface BotaoToque {
|
|
@@ -84,19 +103,13 @@ export function criarControleToque(
|
|
|
84
103
|
const ctx = canvas.getContext('2d')!;
|
|
85
104
|
|
|
86
105
|
const toques = new Map<number, Toque>();
|
|
106
|
+
/**
|
|
107
|
+
* Quantos dedos seguram cada ação. Sem a contagem, soltar o segundo dedo de
|
|
108
|
+
* um mesmo botão liberava a ação enquanto o primeiro ainda estava apertado.
|
|
109
|
+
*/
|
|
110
|
+
const dedosPorAcao = new Map<Acao, number>();
|
|
87
111
|
let visivel = true;
|
|
88
112
|
|
|
89
|
-
/** Insets do notch/barra de gestos. Sem isso o botão fica embaixo da barra. */
|
|
90
|
-
const safeArea = () => {
|
|
91
|
-
const cs = getComputedStyle(document.documentElement);
|
|
92
|
-
const px = (v: string) => parseFloat(cs.getPropertyValue(v)) || 0;
|
|
93
|
-
return {
|
|
94
|
-
esq: px('--sal') || 0,
|
|
95
|
-
dir: px('--sar') || 0,
|
|
96
|
-
base: px('--sab') || 0
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
113
|
const redimensionar = () => {
|
|
101
114
|
const dpr = Math.min(devicePixelRatio || 1, 2);
|
|
102
115
|
canvas.width = Math.round(innerWidth * dpr);
|
|
@@ -108,30 +121,47 @@ export function criarControleToque(
|
|
|
108
121
|
redimensionar();
|
|
109
122
|
addEventListener('resize', redimensionar);
|
|
110
123
|
|
|
124
|
+
const noLadoDoJoystick = () => tuning.ladoDoJoystick === 'esquerda';
|
|
125
|
+
|
|
111
126
|
/** Posição de repouso do joystick (usada quando flutuante = false). */
|
|
112
127
|
const ancoraJoystick = () => {
|
|
113
128
|
const sa = safeArea();
|
|
114
129
|
const y = innerHeight - tuning.raioBase - tuning.margem - sa.base;
|
|
115
|
-
const x =
|
|
130
|
+
const x = noLadoDoJoystick()
|
|
116
131
|
? tuning.raioBase + tuning.margem + sa.esq
|
|
117
132
|
: innerWidth - tuning.raioBase - tuning.margem - sa.dir;
|
|
118
133
|
return { x, y };
|
|
119
134
|
};
|
|
120
135
|
|
|
121
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* Centro de cada botão: o 0 no canto, os outros em ANÉIS em volta dele, ao
|
|
138
|
+
* alcance do polegar. Os ângulos são em graus a partir do "para cima" e
|
|
139
|
+
* crescem para dentro da tela.
|
|
140
|
+
*
|
|
141
|
+
* A versão anterior girava 0,62 rad por botão num raio só: a 90 px isso põe
|
|
142
|
+
* centros a 55 px um do outro, com botões de 76 px de diâmetro — do 3º botão
|
|
143
|
+
* em diante eles se sobrepunham (e o toque na sobra caía no botão errado), e
|
|
144
|
+
* o 4º saía pela borda de baixo da tela. Dois anéis cabem 6 botões sem
|
|
145
|
+
* encostar: no anel de dentro 60° de passo, no de fora (raio dobrado) 30°.
|
|
146
|
+
*/
|
|
147
|
+
const ANEIS: ReadonlyArray<{ raio: number; graus: number }> = [
|
|
148
|
+
{ raio: 0, graus: 0 },
|
|
149
|
+
{ raio: 1, graus: 15 }, { raio: 1, graus: 75 },
|
|
150
|
+
{ raio: 2, graus: 10 }, { raio: 2, graus: 40 }, { raio: 2, graus: 70 }
|
|
151
|
+
];
|
|
122
152
|
const posicaoBotao = (ordem: number) => {
|
|
123
153
|
const sa = safeArea();
|
|
124
154
|
const passo = tuning.raioBotao * 2 + tuning.espacamentoBotao;
|
|
125
155
|
const baseY = innerHeight - tuning.raioBotao - tuning.margem - sa.base;
|
|
126
|
-
const baseX =
|
|
156
|
+
const baseX = noLadoDoJoystick()
|
|
127
157
|
? innerWidth - tuning.raioBotao - tuning.margem - sa.dir
|
|
128
158
|
: tuning.raioBotao + tuning.margem + sa.esq;
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
159
|
+
const slot = ANEIS[Math.min(Math.max(0, ordem), ANEIS.length - 1)]!;
|
|
160
|
+
const rad = (slot.graus * Math.PI) / 180;
|
|
161
|
+
// "Para dentro" é para a esquerda quando os botões estão à direita.
|
|
162
|
+
const dentro = noLadoDoJoystick() ? -1 : 1;
|
|
163
|
+
const r = slot.raio * passo;
|
|
164
|
+
return { x: baseX + dentro * Math.sin(rad) * r, y: baseY - Math.cos(rad) * r };
|
|
135
165
|
};
|
|
136
166
|
|
|
137
167
|
const dentroDoBotao = (x: number, y: number): Acao | null => {
|
|
@@ -142,29 +172,94 @@ export function criarControleToque(
|
|
|
142
172
|
return null;
|
|
143
173
|
};
|
|
144
174
|
|
|
145
|
-
|
|
146
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Região onde o joystick pode nascer: metade escolhida da tela, exceto a
|
|
177
|
+
* faixa de cima. A faixa livre é o que permite girar a câmera com QUALQUER
|
|
178
|
+
* polegar em vez de só com o direito.
|
|
179
|
+
*/
|
|
180
|
+
const podeNascerJoystick = (x: number, y: number): boolean => {
|
|
181
|
+
if (y < innerHeight * tuning.fracaoSuperiorLivre) return false;
|
|
182
|
+
return noLadoDoJoystick() ? x < innerWidth / 2 : x >= innerWidth / 2;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/** Área que pertence a este controle — o Input consulta para não girar a câmera. */
|
|
186
|
+
const ehZonaDeControle = (x: number, y: number): boolean => {
|
|
187
|
+
if (!visivel) return false;
|
|
188
|
+
if (dentroDoBotao(x, y)) return true;
|
|
189
|
+
if (tuning.flutuante) return podeNascerJoystick(x, y);
|
|
190
|
+
const a = ancoraJoystick();
|
|
191
|
+
return Math.hypot(x - a.x, y - a.y) <= tuning.raioBase * 1.25;
|
|
192
|
+
};
|
|
193
|
+
input.definirZonaDeControle(ehZonaDeControle);
|
|
194
|
+
|
|
195
|
+
// Retângulos ocupados, para o HUD escolher outro canto.
|
|
196
|
+
const calcularZonas = (): Zona[] => {
|
|
197
|
+
if (!visivel) return [];
|
|
198
|
+
const zonas: Zona[] = [];
|
|
199
|
+
|
|
200
|
+
const a = ancoraJoystick();
|
|
201
|
+
const rj = tuning.raioBase;
|
|
202
|
+
zonas.push({ x: a.x - rj, y: a.y - rj, largura: rj * 2, altura: rj * 2 });
|
|
203
|
+
|
|
204
|
+
if (botoes.length) {
|
|
205
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
206
|
+
for (const b of botoes) {
|
|
207
|
+
const p = posicaoBotao(b.ordem);
|
|
208
|
+
x0 = Math.min(x0, p.x - tuning.raioBotao);
|
|
209
|
+
y0 = Math.min(y0, p.y - tuning.raioBotao);
|
|
210
|
+
x1 = Math.max(x1, p.x + tuning.raioBotao);
|
|
211
|
+
y1 = Math.max(y1, p.y + tuning.raioBotao);
|
|
212
|
+
}
|
|
213
|
+
zonas.push({ x: x0, y: y0, largura: x1 - x0, altura: y1 - y0 });
|
|
214
|
+
}
|
|
215
|
+
return zonas;
|
|
216
|
+
};
|
|
217
|
+
registrarZonas(NOME_ZONA, calcularZonas);
|
|
218
|
+
|
|
219
|
+
const segurar = (acao: Acao) => {
|
|
220
|
+
const n = (dedosPorAcao.get(acao) ?? 0) + 1;
|
|
221
|
+
dedosPorAcao.set(acao, n);
|
|
222
|
+
if (n === 1) input.definirExterno(acao, true);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const soltar = (acao: Acao) => {
|
|
226
|
+
const n = (dedosPorAcao.get(acao) ?? 1) - 1;
|
|
227
|
+
if (n <= 0) {
|
|
228
|
+
dedosPorAcao.delete(acao);
|
|
229
|
+
input.definirExterno(acao, false);
|
|
230
|
+
} else {
|
|
231
|
+
dedosPorAcao.set(acao, n);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
147
234
|
|
|
148
235
|
// ------------------------------------------------------------- eventos
|
|
149
236
|
const aoDescer = (e: PointerEvent) => {
|
|
150
237
|
if (!visivel) return;
|
|
238
|
+
// Mouse no desktop não deve acionar joystick virtual: quem tem mouse quer
|
|
239
|
+
// que o arraste gire a câmera.
|
|
240
|
+
if (e.pointerType === 'mouse') return;
|
|
241
|
+
|
|
151
242
|
const acao = dentroDoBotao(e.clientX, e.clientY);
|
|
152
243
|
if (acao) {
|
|
244
|
+
input.reservarPonteiro(e.pointerId);
|
|
153
245
|
toques.set(e.pointerId, {
|
|
154
246
|
id: e.pointerId, origemX: e.clientX, origemY: e.clientY,
|
|
155
247
|
x: e.clientX, y: e.clientY, alvo: acao
|
|
156
248
|
});
|
|
157
|
-
|
|
249
|
+
segurar(acao);
|
|
158
250
|
vibrar(8);
|
|
159
251
|
return;
|
|
160
252
|
}
|
|
161
|
-
if (!
|
|
253
|
+
if (!podeNascerJoystick(e.clientX, e.clientY)) return;
|
|
162
254
|
|
|
255
|
+
input.reservarPonteiro(e.pointerId);
|
|
163
256
|
const origem = tuning.flutuante ? { x: e.clientX, y: e.clientY } : ancoraJoystick();
|
|
164
257
|
toques.set(e.pointerId, {
|
|
165
258
|
id: e.pointerId, origemX: origem.x, origemY: origem.y,
|
|
166
259
|
x: e.clientX, y: e.clientY, alvo: 'joystick'
|
|
167
260
|
});
|
|
261
|
+
// Joystick fixo já responde ao primeiro contato, sem esperar o arraste.
|
|
262
|
+
if (!tuning.flutuante) atualizarEixo(toques.get(e.pointerId)!);
|
|
168
263
|
};
|
|
169
264
|
|
|
170
265
|
const aoMover = (e: PointerEvent) => {
|
|
@@ -182,9 +277,10 @@ export function criarControleToque(
|
|
|
182
277
|
input.eixoVirtual.x = 0;
|
|
183
278
|
input.eixoVirtual.y = 0;
|
|
184
279
|
} else {
|
|
185
|
-
|
|
280
|
+
soltar(t.alvo);
|
|
186
281
|
}
|
|
187
282
|
toques.delete(e.pointerId);
|
|
283
|
+
input.liberarPonteiro(e.pointerId);
|
|
188
284
|
};
|
|
189
285
|
|
|
190
286
|
const atualizarEixo = (t: Toque) => {
|
|
@@ -203,6 +299,7 @@ export function criarControleToque(
|
|
|
203
299
|
};
|
|
204
300
|
|
|
205
301
|
const vibrar = (ms: number) => {
|
|
302
|
+
if (!tuning.vibrar) return;
|
|
206
303
|
if (typeof navigator !== 'undefined' && navigator.vibrate) navigator.vibrate(ms);
|
|
207
304
|
};
|
|
208
305
|
|
|
@@ -210,6 +307,9 @@ export function criarControleToque(
|
|
|
210
307
|
canvasJogo.addEventListener('pointermove', aoMover);
|
|
211
308
|
canvasJogo.addEventListener('pointerup', aoSubir);
|
|
212
309
|
canvasJogo.addEventListener('pointercancel', aoSubir);
|
|
310
|
+
// O dedo pode subir fora do canvas (arrastou para a barra de status).
|
|
311
|
+
addEventListener('pointerup', aoSubir);
|
|
312
|
+
addEventListener('pointercancel', aoSubir);
|
|
213
313
|
|
|
214
314
|
// ------------------------------------------------------------- desenho
|
|
215
315
|
const desenhar = (): void => {
|
|
@@ -220,8 +320,9 @@ export function criarControleToque(
|
|
|
220
320
|
// Joystick: só aparece quando o dedo está nele, se for flutuante.
|
|
221
321
|
const tJoy = [...toques.values()].find((t) => t.alvo === 'joystick');
|
|
222
322
|
if (tJoy || !tuning.flutuante) {
|
|
223
|
-
const
|
|
224
|
-
const
|
|
323
|
+
const ancora = ancoraJoystick();
|
|
324
|
+
const cx = tJoy ? tJoy.origemX : ancora.x;
|
|
325
|
+
const cy = tJoy ? tJoy.origemY : ancora.y;
|
|
225
326
|
|
|
226
327
|
anel(cx, cy, tuning.raioBase, p.contorno, tuning.opacidade);
|
|
227
328
|
|
|
@@ -238,13 +339,15 @@ export function criarControleToque(
|
|
|
238
339
|
// Botões
|
|
239
340
|
for (const b of botoes) {
|
|
240
341
|
const pos = posicaoBotao(b.ordem);
|
|
241
|
-
const ativo =
|
|
342
|
+
const ativo = (dedosPorAcao.get(b.acao) ?? 0) > 0;
|
|
242
343
|
disco(pos.x, pos.y, tuning.raioBotao, ativo ? p.acento : p.superficie,
|
|
243
344
|
ativo ? tuning.opacidadeAtiva : tuning.opacidade);
|
|
244
345
|
anel(pos.x, pos.y, tuning.raioBotao, p.contorno, tuning.opacidade + 0.15);
|
|
245
346
|
|
|
246
347
|
ctx.fillStyle = alpha(p.texto, 0.85);
|
|
247
|
-
|
|
348
|
+
// Rótulo de palavra ("FOGO", "MIRA") encolhe para caber no círculo.
|
|
349
|
+
const escala = b.rotulo.length > 2 ? 0.4 : 0.62;
|
|
350
|
+
ctx.font = `bold ${tuning.raioBotao * escala}px system-ui, sans-serif`;
|
|
248
351
|
ctx.textAlign = 'center';
|
|
249
352
|
ctx.textBaseline = 'middle';
|
|
250
353
|
ctx.fillText(b.rotulo, pos.x, pos.y + 1);
|
|
@@ -266,25 +369,38 @@ export function criarControleToque(
|
|
|
266
369
|
ctx.stroke();
|
|
267
370
|
};
|
|
268
371
|
|
|
372
|
+
const largarTudo = () => {
|
|
373
|
+
input.eixoVirtual.x = 0;
|
|
374
|
+
input.eixoVirtual.y = 0;
|
|
375
|
+
for (const t of toques.values()) {
|
|
376
|
+
if (t.alvo !== 'joystick') soltar(t.alvo);
|
|
377
|
+
input.liberarPonteiro(t.id);
|
|
378
|
+
}
|
|
379
|
+
toques.clear();
|
|
380
|
+
dedosPorAcao.clear();
|
|
381
|
+
};
|
|
382
|
+
|
|
269
383
|
return {
|
|
270
384
|
desenhar,
|
|
271
385
|
get visivel() { return visivel; },
|
|
272
386
|
set visivel(v: boolean) {
|
|
273
387
|
visivel = v;
|
|
274
388
|
if (!v) {
|
|
275
|
-
|
|
276
|
-
input.eixoVirtual.y = 0;
|
|
277
|
-
for (const t of toques.values()) if (t.alvo !== 'joystick') input.definirExterno(t.alvo, false);
|
|
278
|
-
toques.clear();
|
|
389
|
+
largarTudo();
|
|
279
390
|
ctx.clearRect(0, 0, innerWidth, innerHeight);
|
|
280
391
|
}
|
|
281
392
|
},
|
|
282
393
|
dispose() {
|
|
394
|
+
largarTudo();
|
|
283
395
|
canvasJogo.removeEventListener('pointerdown', aoDescer);
|
|
284
396
|
canvasJogo.removeEventListener('pointermove', aoMover);
|
|
285
397
|
canvasJogo.removeEventListener('pointerup', aoSubir);
|
|
286
398
|
canvasJogo.removeEventListener('pointercancel', aoSubir);
|
|
399
|
+
removeEventListener('pointerup', aoSubir);
|
|
400
|
+
removeEventListener('pointercancel', aoSubir);
|
|
287
401
|
removeEventListener('resize', redimensionar);
|
|
402
|
+
removerZonas(NOME_ZONA);
|
|
403
|
+
input.definirZonaDeControle(null);
|
|
288
404
|
canvas.remove();
|
|
289
405
|
}
|
|
290
406
|
};
|
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"categoria": "game",
|
|
3
|
-
"framework": "three",
|
|
4
|
-
"linguagem": "typescript",
|
|
5
|
-
"compatibilidade": {
|
|
6
|
-
"banco": [],
|
|
7
|
-
"auth": []
|
|
8
|
-
},
|
|
9
|
-
"versao": "1.0
|
|
10
|
-
"id": "adapt-controle-toque-01",
|
|
11
|
-
"nome": "Adaptação: Controle por Toque (mobile)",
|
|
12
|
-
"dependencias": [],
|
|
13
|
-
"tags": [
|
|
14
|
-
"game",
|
|
15
|
-
"jogo",
|
|
16
|
-
"controle",
|
|
17
|
-
"toque",
|
|
18
|
-
"touch",
|
|
19
|
-
"mobile",
|
|
20
|
-
"celular",
|
|
21
|
-
"joystick",
|
|
22
|
-
"analogico",
|
|
23
|
-
"botao",
|
|
24
|
-
"virtual",
|
|
25
|
-
"adaptacao"
|
|
26
|
-
],
|
|
27
|
-
"recursos_suportados": [
|
|
28
|
-
"joystick-virtual",
|
|
29
|
-
"botoes-de-acao",
|
|
30
|
-
"multi-toque",
|
|
31
|
-
"zona-morta",
|
|
32
|
-
"safe-area",
|
|
33
|
-
"joystick-flutuante"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
{
|
|
2
|
+
"categoria": "game",
|
|
3
|
+
"framework": "three",
|
|
4
|
+
"linguagem": "typescript",
|
|
5
|
+
"compatibilidade": {
|
|
6
|
+
"banco": [],
|
|
7
|
+
"auth": []
|
|
8
|
+
},
|
|
9
|
+
"versao": "2.1.0",
|
|
10
|
+
"id": "adapt-controle-toque-01",
|
|
11
|
+
"nome": "Adaptação: Controle por Toque (mobile)",
|
|
12
|
+
"dependencias": [],
|
|
13
|
+
"tags": [
|
|
14
|
+
"game",
|
|
15
|
+
"jogo",
|
|
16
|
+
"controle",
|
|
17
|
+
"toque",
|
|
18
|
+
"touch",
|
|
19
|
+
"mobile",
|
|
20
|
+
"celular",
|
|
21
|
+
"joystick",
|
|
22
|
+
"analogico",
|
|
23
|
+
"botao",
|
|
24
|
+
"virtual",
|
|
25
|
+
"adaptacao"
|
|
26
|
+
],
|
|
27
|
+
"recursos_suportados": [
|
|
28
|
+
"joystick-virtual",
|
|
29
|
+
"botoes-de-acao",
|
|
30
|
+
"multi-toque",
|
|
31
|
+
"zona-morta",
|
|
32
|
+
"safe-area",
|
|
33
|
+
"joystick-flutuante",
|
|
34
|
+
"reserva-de-dedo",
|
|
35
|
+
"zona-de-olhar-separada",
|
|
36
|
+
"registro-de-zonas-para-o-hud",
|
|
37
|
+
"contagem-de-dedos-por-botao",
|
|
38
|
+
"canhoto",
|
|
39
|
+
"ate-6-botoes-sem-sobreposicao",
|
|
40
|
+
"rotulo-que-cabe-no-botao"
|
|
41
|
+
],
|
|
42
|
+
"descricao": "OBRIGATÓRIA em jogo mobile. Joystick virtual analógico + botões de ação desenhados em canvas próprio (não DOM, não trava o jogo). Multi-toque real: mover e atirar ao mesmo tempo. Modo flutuante (o joystick nasce onde o dedo encostou), zona morta configurável, layout para canhoto e safe-area medido de verdade. Divide a tela com a câmera do jeito certo: RESERVA no engine o dedo que está num controle e DECLARA a área que ocupa, então metade da tela anda e a outra metade olha — sem isso, arrastar o joystick girava a câmera junto. Também REGISTRA seus retângulos no layout do engine, que é como o HUD descobre que não pode pôr o minimapa em cima dos botões. Escreve direto no Input do engine, então o gameplay não sabe que é toque. Até 6 botões em dois anéis em volta do principal, sem sobreposição (antes, do 3º em diante os botões se encavalavam e o 4º saía pela borda) — o FPS usa 4: FOGO, MIRA, R e trocar arma."
|
|
43
|
+
}
|