add templates

This commit is contained in:
2026-06-24 21:00:19 -03:00
parent f80223e0ed
commit b210ed4f92
17 changed files with 866 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import { ApiHelpers } from "../../../../interpreters/ApiHelpers.js";
/**
* Retorna a função de init do js-interpreter para o jogo Exemplo.
* É aqui que a ponte entre o interpretador sandboxed e a cena Phaser é construída:
* cada função registrada expõe um método da cena como uma chamada segura para o aluno.
*
* @param {ExemploScene} scene - Instância da cena Phaser ativa
* @param {Object} config - Configurações opcionais (ex: animationSpeed)
* @returns {Function} Função de init com assinatura (interpreter, globalScope)
*/
export const setupExemploAPI = (scene, config) => {
const delay = (config && config.animationSpeed) || 200;
return function (interpreter, globalScope) {
// Ações assíncronas: createAsyncFunction aguarda o callback para avançar o interpreter
ApiHelpers.registerFunction(
interpreter,
globalScope,
"moverDireita",
ApiHelpers.createActionWrapper(scene, "moverDireita", delay),
true // isAsync
);
ApiHelpers.registerFunction(
interpreter,
globalScope,
"moverBaixo",
ApiHelpers.createActionWrapper(scene, "moverBaixo", delay),
true // isAsync
);
// Necessário para o highlight visual dos blocos durante a execução
ApiHelpers.registerFunction(
interpreter,
globalScope,
"highlightBlock",
ApiHelpers.createHighlightWrapper(scene),
false
);
};
};