Skip to content

Commit

Permalink
Merge branch 'hoc2023-prettier-src' into hoc2023-initial
Browse files Browse the repository at this point in the history
  • Loading branch information
breville committed Sep 17, 2023
2 parents 68fdef7 + 832dd46 commit 8a5d74d
Show file tree
Hide file tree
Showing 40 changed files with 2,809 additions and 2,142 deletions.
104 changes: 52 additions & 52 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,59 @@
// or overridden for a particular subset of the project. See
// other .eslintrc.js files for those rules.
module.exports = {
"globals": {
"Phaser": true,
"PIXI": true
globals: {
Phaser: true,
PIXI: true,
},
"plugins": [
],
"extends": [
"eslint:recommended",
],
"env": {
"browser": true,
"node": true,
"es6": true
plugins: [],
extends: ['eslint:recommended'],
env: {
browser: true,
node: true,
es6: true,
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017,
"ecmaFeatures": {
"jsx": true,
"modules": true,
"ecmaVersion": 6,
"experimentalObjectRestSpread": true
}
parserOptions: {
sourceType: 'module',
ecmaVersion: 2017,
ecmaFeatures: {
jsx: true,
modules: true,
ecmaVersion: 6,
experimentalObjectRestSpread: true,
},
},
rules: {
'array-bracket-spacing': ['error', 'never'],
'brace-style': ['error', '1tbs', {allowSingleLine: true}],
'comma-dangle': 'off',
curly: 'error',
'dot-location': ['error', 'property'],
'eol-last': 'error',
eqeqeq: 'error',
'jsx-quotes': 'error', // autofixable
'keyword-spacing': 'error',
indent: ['error', 2, {SwitchCase: 1}],
'no-array-constructor': 'error',
'no-console': 'off',
'no-duplicate-imports': 'error',
'no-empty': 'off',
'no-eval': 'error',
'no-extra-boolean-cast': 'off',
'no-implicit-globals': 'error',
'no-new-object': 'error',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-unused-vars': 'error',
'no-with': 'error',
'object-curly-spacing': 'off',
semi: 'error',
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never',
},
],
strict: 'error',
},
"rules": {
"array-bracket-spacing": ["error", "never"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"comma-dangle": "off",
"curly": "error",
"dot-location": ["error", "property"],
"eol-last": "error",
"eqeqeq": "error",
"jsx-quotes": "error", // autofixable
"keyword-spacing": "error",
"indent": ["error", 2, {"SwitchCase": 1}],
"no-array-constructor": "error",
"no-console": "off",
"no-duplicate-imports": "error",
"no-empty": "off",
"no-eval": "error",
"no-extra-boolean-cast": "off",
"no-implicit-globals": "error",
"no-new-object": "error",
"no-trailing-spaces": "error",
"no-undef": "error",
"no-unused-vars": "error",
"no-with": "error",
"object-curly-spacing": "off",
"semi": "error",
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never"
}],
"strict": "error",
}
};
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
singleQuote: true,
bracketSpacing: false,
arrowParens: "avoid",
arrowParens: 'avoid',
};
36 changes: 20 additions & 16 deletions demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import injectInterpreted from './test/helpers/injectInterpreted';
const textareaCode = document.querySelector('#code');
const buttonRun = document.querySelector('#run');

const nativeAPI = window.nativeAPI = new DanceParty({
const nativeAPI = (window.nativeAPI = new DanceParty({
onPuzzleComplete: () => {},
playSound: (url, callback, onEnded) => setTimeout(() => {
callback && callback();
}, 0),
playSound: (url, callback, onEnded) =>
setTimeout(() => {
callback && callback();
}, 0),
onInit: () => {
document.querySelector('#run').style.display = 'inline';
runCode();
},
container: 'dance',
});
}));

// Note: We don't just declare
// async function runCode() {
Expand All @@ -27,22 +28,25 @@ const nativeAPI = window.nativeAPI = new DanceParty({
const runCode = async function () {
await nativeAPI.ensureSpritesAreLoaded();

const {
runUserSetup,
runUserEvents,
getCueList,
} = injectInterpreted(nativeAPI, interpreted, textareaCode.value);
const {runUserSetup, runUserEvents, getCueList} = injectInterpreted(
nativeAPI,
interpreted,
textareaCode.value
);

// Setup event tracking.
nativeAPI.addCues(getCueList());
nativeAPI.onHandleEvents = currentFrameEvents => runUserEvents(currentFrameEvents);
nativeAPI.onHandleEvents = currentFrameEvents =>
runUserEvents(currentFrameEvents);

runUserSetup();

nativeAPI.play(jazzy_beats);
}
};

textareaCode.value = textareaCode.value || `var cat = makeNewDanceSprite("CAT", null, {x: 200, y: 200});
textareaCode.value =
textareaCode.value ||
`var cat = makeNewDanceSprite("CAT", null, {x: 200, y: 200});
setBackgroundEffectWithPalette("disco_ball", "rand");
atTimestamp(2, "measures", function () {
Expand All @@ -51,11 +55,11 @@ atTimestamp(2, "measures", function () {
`;

document.querySelector('#run').addEventListener('click', () => {
if (buttonRun.innerText === "Reset") {
buttonRun.innerText = "Run!";
if (buttonRun.innerText === 'Reset') {
buttonRun.innerText = 'Run!';
nativeAPI.reset();
} else {
buttonRun.innerText = "Reset";
buttonRun.innerText = 'Reset';
runCode();
}
});
3 changes: 1 addition & 2 deletions levels/effectsLevels.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = {
changeBackgroundAtTimestamp: {
solutions:
`
solutions: `
var lead_dancer;
whenSetup(function () {
Expand Down
104 changes: 52 additions & 52 deletions levels/spriteDance.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
module.exports = {
collisionEveryNMeasure: {
solutions: [
`
var lead_dancer;
whenSetup(function () {
makeNewDanceSprite("CAT", "lead_dancer", {x: 200, y: 200});
});
everySeconds(2, "measures", function () {
changeMoveLR("lead_dancer", 3, -1);
});
everySeconds(4, "measures", function () {
changeMoveLR("lead_dancer", 1, -1);
setProp("lead_dancer", "scale", 50);
});
`
var lead_dancer;
whenSetup(function () {
makeNewDanceSprite("CAT", "lead_dancer", {x: 200, y: 200});
});
everySeconds(2, "measures", function () {
changeMoveLR("lead_dancer", 3, -1);
});
everySeconds(4, "measures", function () {
changeMoveLR("lead_dancer", 1, -1);
setProp("lead_dancer", "scale", 50);
});
`,
`
var lead_dancer;
whenSetup(function () {
makeNewDanceSprite("CAT", "lead_dancer", {x: 200, y: 200});
});
everySeconds(4, "measures", function () {
changeMoveLR("lead_dancer", 1, -1);
});
everySeconds(2, "measures", function () {
changeMoveLR("lead_dancer", 3, -1);
});
`
var lead_dancer;
whenSetup(function () {
makeNewDanceSprite("CAT", "lead_dancer", {x: 200, y: 200});
});
everySeconds(4, "measures", function () {
changeMoveLR("lead_dancer", 1, -1);
});
everySeconds(2, "measures", function () {
changeMoveLR("lead_dancer", 3, -1);
});
`,
],
validationCode: `
if (nativeAPI.getTime("measures") === 5) {
let cats = nativeAPI.getGroupByName_('CAT');
for(let i = 0; i < cats.length; i++){
if(cats[i].current_move !== 1){
nativeAPI.fail("Cat sprite not dancing 1.");
}
}
}
if (nativeAPI.getTime("measures") > 8 && nativeAPI.getTime("measures") < 9) {
let cats = nativeAPI.getGroupByName_('CAT');
for(let i = 0; i < cats.length; i++){
if(cats[i].current_move !== 3){
nativeAPI.fail("Cat sprite not dancing 3.");
}
}
}
if (nativeAPI.getTime("measures") > 1 && nativeAPI.getTime("measures") < 2) {
let cats = nativeAPI.getGroupByName_('CAT');
for(let i = 0; i < cats.length; i++){
if(nativeAPI.getProp(cats[i], "scale") === 50) {
nativeAPI.fail("Cat sprite event happened too early.");
}
}
}
if (nativeAPI.getTime("measures") > 9) {
nativeAPI.pass();
}
validationCode: `
if (nativeAPI.getTime("measures") === 5) {
let cats = nativeAPI.getGroupByName_('CAT');
for(let i = 0; i < cats.length; i++){
if(cats[i].current_move !== 1){
nativeAPI.fail("Cat sprite not dancing 1.");
}
}
}
if (nativeAPI.getTime("measures") > 8 && nativeAPI.getTime("measures") < 9) {
let cats = nativeAPI.getGroupByName_('CAT');
for(let i = 0; i < cats.length; i++){
if(cats[i].current_move !== 3){
nativeAPI.fail("Cat sprite not dancing 3.");
}
}
}
if (nativeAPI.getTime("measures") > 1 && nativeAPI.getTime("measures") < 2) {
let cats = nativeAPI.getGroupByName_('CAT');
for(let i = 0; i < cats.length; i++){
if(nativeAPI.getProp(cats[i], "scale") === 50) {
nativeAPI.fail("Cat sprite event happened too early.");
}
}
}
if (nativeAPI.getTime("measures") > 9) {
nativeAPI.pass();
}
`,
},
};
};
Loading

0 comments on commit 8a5d74d

Please sign in to comment.