@m2c2kit/cli 0.1.10 → 0.1.11
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/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
CLI_VERSION=0.1.
|
|
1
|
+
CLI_VERSION=0.1.11
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
height: 100vh;
|
|
21
21
|
width: 100vw;
|
|
22
22
|
">
|
|
23
|
-
<canvas style="height: 100vh; width: 100vw"></canvas>
|
|
23
|
+
<canvas style="height: 100vh; width: 100vw" id="m2c2-canvas"></canvas>
|
|
24
24
|
<!-- If you don't want the game to start immediately, remove session.start()
|
|
25
25
|
from the code and call session.start() somehow else, such as with
|
|
26
26
|
the button shown below or a programmatic call -->
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
},
|
|
9
9
|
"private": true,
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@m2c2kit/core": "0.1.
|
|
12
|
-
"@m2c2kit/addons": "0.1.
|
|
11
|
+
"@m2c2kit/core": "0.1.9",
|
|
12
|
+
"@m2c2kit/addons": "0.1.9"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"rollup": "2.
|
|
16
|
-
"@rollup/plugin-typescript": "8.3.
|
|
15
|
+
"rollup": "2.70.0",
|
|
16
|
+
"@rollup/plugin-typescript": "8.3.1",
|
|
17
17
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
18
|
-
"@rollup/plugin-commonjs": "21.0.
|
|
18
|
+
"@rollup/plugin-commonjs": "21.0.2",
|
|
19
19
|
"rollup-plugin-shim": "1.0.0",
|
|
20
20
|
"rollup-plugin-copy": "3.4.0",
|
|
21
21
|
"rollup-plugin-delete": "2.0.0",
|
|
@@ -3,10 +3,8 @@ import {
|
|
|
3
3
|
Action,
|
|
4
4
|
Scene,
|
|
5
5
|
Shape,
|
|
6
|
-
Point,
|
|
7
6
|
Label,
|
|
8
7
|
WebColors,
|
|
9
|
-
Rect,
|
|
10
8
|
LabelHorizontalAlignmentMode,
|
|
11
9
|
GameParameters,
|
|
12
10
|
GameOptions,
|
|
@@ -16,6 +14,7 @@ import {
|
|
|
16
14
|
ActivityDataEvent,
|
|
17
15
|
ActivityLifecycleEvent,
|
|
18
16
|
Sprite,
|
|
17
|
+
Timer,
|
|
19
18
|
} from "@m2c2kit/core";
|
|
20
19
|
import { Button, Instructions } from "@m2c2kit/addons";
|
|
21
20
|
|
|
@@ -44,6 +43,7 @@ class {{className}} extends Game {
|
|
|
44
43
|
const demoTrialSchema: TrialSchema = {
|
|
45
44
|
colorChosen: { type: "string", description: "the color that was picked" },
|
|
46
45
|
correct: { type: "boolean", description: "was the answer correct?" },
|
|
46
|
+
responseTime: { type: "number", description: "response time (ms) to choose shape" }
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const options: GameOptions = {
|
|
@@ -52,7 +52,7 @@ class {{className}} extends Game {
|
|
|
52
52
|
uri: "https://your-repo-or-webpage-here",
|
|
53
53
|
shortDescription: "A brief couple sentence description.",
|
|
54
54
|
longDescription: "An extended, many-sentence description.",
|
|
55
|
-
showFps:
|
|
55
|
+
showFps: false,
|
|
56
56
|
trialSchema: demoTrialSchema,
|
|
57
57
|
parameters: defaultParameters,
|
|
58
58
|
// You can set this color so we can see the boundaries of the game during development,
|
|
@@ -88,6 +88,9 @@ class {{className}} extends Game {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
super(options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
init(): void {
|
|
91
94
|
// just for convenience, alias the variable game to "this"
|
|
92
95
|
// (even though eslint doesn't like it)
|
|
93
96
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
@@ -134,19 +137,19 @@ class {{className}} extends Game {
|
|
|
134
137
|
const getReadyMessage = new Label({
|
|
135
138
|
text: "Get Ready",
|
|
136
139
|
fontSize: 24,
|
|
137
|
-
position:
|
|
140
|
+
position: { x: 200, y: 400 },
|
|
138
141
|
});
|
|
139
142
|
getReadyScene.addChild(getReadyMessage);
|
|
140
143
|
|
|
141
144
|
// example of how to use an image. The image must be previously loaded
|
|
142
145
|
const starSprite = new Sprite({
|
|
143
146
|
imageName: "star",
|
|
144
|
-
position:
|
|
147
|
+
position: { x: 200, y: 500 },
|
|
145
148
|
});
|
|
146
149
|
getReadyScene.addChild(starSprite);
|
|
147
150
|
|
|
148
|
-
// getReadyScene.
|
|
149
|
-
getReadyScene.
|
|
151
|
+
// getReadyScene.onSetup() has a callback that is executed each time this scene is shown
|
|
152
|
+
getReadyScene.onSetup(() => {
|
|
150
153
|
getReadyScene.run(
|
|
151
154
|
Action.Sequence([
|
|
152
155
|
// Get the wait duration from the default game parameters, defined above
|
|
@@ -160,32 +163,32 @@ class {{className}} extends Game {
|
|
|
160
163
|
);
|
|
161
164
|
});
|
|
162
165
|
|
|
163
|
-
// these entities before the
|
|
166
|
+
// these entities before the onSetup() can be defined outside of a onSetup()
|
|
164
167
|
// because they exist through multiple trials
|
|
165
168
|
// Their position and how they respond to interactions may differ across trials,
|
|
166
|
-
// and that logic will be written within a
|
|
169
|
+
// and that logic will be written within a onSetup()
|
|
167
170
|
const chooseRectangleScene = new Scene({
|
|
168
171
|
backgroundColor: WebColors.LightGray,
|
|
169
172
|
});
|
|
170
173
|
game.addScene(chooseRectangleScene);
|
|
171
174
|
const redRect = new Shape({
|
|
172
|
-
rect:
|
|
175
|
+
rect: { width: 150, height: 100 },
|
|
173
176
|
fillColor: WebColors.Red,
|
|
174
177
|
});
|
|
175
178
|
chooseRectangleScene.addChild(redRect);
|
|
176
179
|
const blueRect = new Shape({
|
|
177
|
-
rect:
|
|
180
|
+
rect: { width: 150, height: 100 },
|
|
178
181
|
fillColor: WebColors.Blue,
|
|
179
182
|
});
|
|
180
183
|
chooseRectangleScene.addChild(blueRect);
|
|
181
184
|
const correctMessage = new Label({
|
|
182
185
|
text: "CORRECT!",
|
|
183
|
-
position:
|
|
186
|
+
position: { x: 200, y: 500 },
|
|
184
187
|
});
|
|
185
188
|
|
|
186
189
|
const chooseMessage = new Label({
|
|
187
190
|
text: "Choose the red rectangle",
|
|
188
|
-
position:
|
|
191
|
+
position: { x: 200, y: 200 },
|
|
189
192
|
});
|
|
190
193
|
chooseRectangleScene.addChild(chooseMessage);
|
|
191
194
|
|
|
@@ -193,32 +196,34 @@ class {{className}} extends Game {
|
|
|
193
196
|
chooseRectangleScene.addChild(correctMessage);
|
|
194
197
|
const wrongMessage = new Label({
|
|
195
198
|
text: "WRONG!",
|
|
196
|
-
position:
|
|
199
|
+
position: {x: 200, y: 500 },
|
|
197
200
|
});
|
|
198
201
|
|
|
199
202
|
wrongMessage.hidden = true;
|
|
200
203
|
chooseRectangleScene.addChild(wrongMessage);
|
|
201
204
|
|
|
202
|
-
// chooseRectangleScene.
|
|
203
|
-
// time this scene is shown. Within
|
|
205
|
+
// chooseRectangleScene.onSetup() is passed a callback that is executed each
|
|
206
|
+
// time this scene is shown. Within onSetup(), We will randomly decide on
|
|
204
207
|
// what side the red rectangle is shown
|
|
205
|
-
chooseRectangleScene.
|
|
208
|
+
chooseRectangleScene.onSetup(() => {
|
|
209
|
+
let responseTime = NaN;
|
|
206
210
|
let redOnLeft = true;
|
|
207
211
|
if (Math.random() > 0.5) {
|
|
208
212
|
redOnLeft = false;
|
|
209
213
|
}
|
|
210
214
|
|
|
211
215
|
if (redOnLeft) {
|
|
212
|
-
redRect.position =
|
|
213
|
-
blueRect.position =
|
|
216
|
+
redRect.position = { x: 100, y: 300 };
|
|
217
|
+
blueRect.position = { x: 300, y: 300 };
|
|
214
218
|
} else {
|
|
215
|
-
redRect.position =
|
|
216
|
-
blueRect.position =
|
|
219
|
+
redRect.position = { x: 300, y: 300 };
|
|
220
|
+
blueRect.position = { x: 100, y: 300 };;
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
// helper function to record the user's choice and
|
|
220
224
|
// decide if we are done
|
|
221
225
|
function recordUserInput(choseRedRect: boolean) {
|
|
226
|
+
game.addTrialData("responseTime", responseTime);
|
|
222
227
|
game.addTrialData("correct", choseRedRect);
|
|
223
228
|
if (choseRedRect) {
|
|
224
229
|
game.addTrialData("colorChosen", "red");
|
|
@@ -240,6 +245,7 @@ class {{className}} extends Game {
|
|
|
240
245
|
Action.Sequence([
|
|
241
246
|
Action.Custom({
|
|
242
247
|
callback: () => {
|
|
248
|
+
responseTime = Timer.elapsed("rt");
|
|
243
249
|
// once a choice is made, don't allow additional taps
|
|
244
250
|
redRect.isUserInteractionEnabled = false;
|
|
245
251
|
blueRect.isUserInteractionEnabled = false;
|
|
@@ -273,6 +279,7 @@ class {{className}} extends Game {
|
|
|
273
279
|
Action.Sequence([
|
|
274
280
|
Action.Custom({
|
|
275
281
|
callback: () => {
|
|
282
|
+
responseTime = Timer.elapsed("rt");
|
|
276
283
|
redRect.isUserInteractionEnabled = false;
|
|
277
284
|
blueRect.isUserInteractionEnabled = false;
|
|
278
285
|
},
|
|
@@ -296,17 +303,22 @@ class {{className}} extends Game {
|
|
|
296
303
|
});
|
|
297
304
|
});
|
|
298
305
|
|
|
306
|
+
chooseRectangleScene.onAppear(() => {
|
|
307
|
+
Timer.removeAll();
|
|
308
|
+
Timer.start("rt");
|
|
309
|
+
});
|
|
310
|
+
|
|
299
311
|
const endScene = new Scene();
|
|
300
312
|
game.addScene(endScene);
|
|
301
313
|
const doneLabel = new Label({
|
|
302
|
-
text: `This will be reassigned in the
|
|
303
|
-
position:
|
|
314
|
+
text: `This will be reassigned in the onSetup() callback. If you see this, something went wrong!`,
|
|
315
|
+
position: { x: 200, y: 300},
|
|
304
316
|
});
|
|
305
317
|
endScene.addChild(doneLabel);
|
|
306
318
|
|
|
307
319
|
const startOverButton = new Button({
|
|
308
320
|
text: "Start over",
|
|
309
|
-
position:
|
|
321
|
+
position: { x: 200, y: 600 },
|
|
310
322
|
});
|
|
311
323
|
startOverButton.isUserInteractionEnabled = true;
|
|
312
324
|
startOverButton.onTapDown(() => {
|
|
@@ -317,7 +329,7 @@ class {{className}} extends Game {
|
|
|
317
329
|
|
|
318
330
|
const exitButton = new Button({
|
|
319
331
|
text: "Exit",
|
|
320
|
-
position:
|
|
332
|
+
position: { x: 200, y: 675 },
|
|
321
333
|
});
|
|
322
334
|
exitButton.isUserInteractionEnabled = true;
|
|
323
335
|
exitButton.onTapDown(() => {
|
|
@@ -329,7 +341,7 @@ class {{className}} extends Game {
|
|
|
329
341
|
});
|
|
330
342
|
endScene.addChild(exitButton);
|
|
331
343
|
|
|
332
|
-
endScene.
|
|
344
|
+
endScene.onSetup(() => {
|
|
333
345
|
doneLabel.text = `You did ${game.trialIndex} trials. You're done!`;
|
|
334
346
|
});
|
|
335
347
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2c2kit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "m2c2kit command line interface",
|
|
5
5
|
"module": "dist/cli.js",
|
|
6
6
|
"files": [
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"axios": "0.24.0",
|
|
27
|
-
"chalk": "5.0.
|
|
27
|
+
"chalk": "5.0.1",
|
|
28
28
|
"conf": "10.1.1",
|
|
29
29
|
"form-data": "4.0.0",
|
|
30
30
|
"handlebars": "4.7.7",
|
|
31
|
-
"ora": "6.0
|
|
31
|
+
"ora": "6.1.0",
|
|
32
32
|
"prompts": "2.4.2",
|
|
33
33
|
"yargs": "17.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "17.0.
|
|
36
|
+
"@types/node": "17.0.21",
|
|
37
37
|
"@types/prompts": "2.0.14",
|
|
38
|
-
"@types/yargs": "17.0.
|
|
38
|
+
"@types/yargs": "17.0.9",
|
|
39
39
|
"copyfiles": "2.4.1",
|
|
40
40
|
"rimraf": "3.0.2",
|
|
41
41
|
"tslib": "2.3.1",
|
|
42
|
-
"typescript": "4.
|
|
42
|
+
"typescript": "4.6.2"
|
|
43
43
|
}
|
|
44
44
|
}
|