M src/game.js => src/game.js +1 -1
@@ 148,7 148,7 @@ export function addBox(data, gameData, gs) {
clicked: false,
label: '',
};
- const boxData = data.literalValue ? { value: data.literalValue } : boxDef.data;
+ const boxData = typeof data.literalValue !== 'undefined' ? { value: data.literalValue } : boxDef.data;
const box = {
...defaults,
...data,
M src/lang.js => src/lang.js +8 -0
@@ 102,6 102,14 @@ export function interpret (expression, initial = null) {
const b = r.stack[1];
return { push: [a.add(b)], pop: 2 }
}
+ else if (code === 'vecx') {
+ const vec = r.stack[0];
+ return { push: [vec.x], pop: 2 }
+ }
+ else if (code === 'vecy') {
+ const vec = r.stack[0];
+ return { push: [vec.y], pop: 2 }
+ }
else if (code === 'add') {
const a = r.stack[0];
const b = r.stack[1];
M src/main.js => src/main.js +42 -0
@@ 256,6 256,48 @@ flr #last swp at
`)
}
});
+ loadCodeBox({
+ name: 'vec',
+ data: {
+ x: 0,
+ y: 0,
+ },
+ outputs: ['v'],
+ inputs: {
+ x: parse(`val dup #x kep #y get vec #v out`),
+ y: parse(`val dup #y kep`),
+ }
+ });
+ loadCodeBox({
+ name: 'vecx',
+ outputs: ['v'],
+ inputs: {
+ v: parse(`val vecx #v out`),
+ }
+ });
+ loadCodeBox({
+ name: 'vecy',
+ outputs: ['v'],
+ inputs: {
+ v: parse(`val vecy #v out`),
+ }
+ });
+ loadCodeBox({
+ name: 'delay',
+ data: {
+ tail: [],
+ number: 10,
+ },
+ outputs: ['v'],
+ inputs: {
+ v: parse(`
+val #tail que
+#tail len #number get equ #pop jcn
+def pop:
+ #tail pop #v out
+`),
+ }
+ });
initUI();
app.view.tabIndex = 0