Skip to content

Commit 7d27170

Browse files
committed
gdx_forのブロックに対応する命令を作りました。
1 parent c692334 commit 7d27170

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

src/lib/ruby-generator/gdx_for.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,76 @@
44
* @return {RubyGenerator} same as param.
55
*/
66
export default function (Generator) {
7+
Generator.gdxfor_menu_gestureOptions = function (block) {
8+
const gesture = Generator.quote_(Generator.getFieldValue(block, 'gestureOptions') || 'shaken');
9+
return [gesture, Generator.ORDER_ATOMIC];
10+
};
11+
12+
Generator.gdxfor_whenGesture = function(block){
13+
block.isStatement = true;
14+
const gesture = Generator.valueToCode(block, 'GESTURE', Generator.ORDER_NONE) || null;
15+
return `${Generator.spriteName()}.when(:gdx_for_gesture, ${gesture}) do\n`;
16+
};
17+
18+
Generator.gdxfor_menu_pushPullOptions = function (block) {
19+
const push_pull = Generator.quote_(Generator.getFieldValue(block, 'pushPullOptions') || 'pushed');
20+
return [push_pull, Generator.ORDER_ATOMIC];
21+
};
22+
23+
Generator.gdxfor_whenForcePushedOrPulled = function(block){
24+
block.isStatement = true;
25+
const push_pull = Generator.valueToCode(block, 'PUSH_PULL', Generator.ORDER_NONE) || null;
26+
return `${Generator.spriteName()}.when(:gdx_for_push_pull, ${push_pull}) do\n`;
27+
};
728

829
Generator.gdxfor_getForce = function(){
930
return [`gdx_for_force`, Generator.ORDER_ATOMIC];
1031
};
1132

33+
Generator.gdxfor_menu_tiltAnyOptions = function (block) {
34+
const tilt_any = Generator.quote_(Generator.getFieldValue(block, 'tiltAnyOptions') || 'any');
35+
return [tilt_any, Generator.ORDER_ATOMIC];
36+
};
37+
38+
Generator.gdxfor_whenTilted = function(block){
39+
block.isStatement = true;
40+
const tilt = Generator.valueToCode(block, 'TILT', Generator.ORDER_NONE) || null;
41+
return `${Generator.spriteName()}.when(:gdx_for_titld, ${tilt}) do\n`;
42+
};
43+
44+
45+
Generator.gdxfor_isTilted = function(block){
46+
const tilt = Generator.valueToCode(block, 'TILT', Generator.ORDER_NONE) || null;
47+
return [`gdx_for_tiled ${tilt}?`, Generator.ORDER_ATOMIC];
48+
};
49+
50+
Generator.gdxfor_menu_tiltOptions = function (block) {
51+
const tilt = Generator.quote_(Generator.getFieldValue(block, 'tiltOptions') || 'front');
52+
return [tilt, Generator.ORDER_ATOMIC];
53+
};
54+
55+
Generator.gdxfor_getTilt = function(block) {
56+
const tilt = Generator.valueToCode(block, 'TILT', Generator.ORDER_NONE) || null;
57+
return [`gdx_for_tile_angle ${tilt}?`, Generator.ORDER_ATOMIC];
58+
};
59+
60+
Generator.gdxfor_menu_axisOptions = function (block) {
61+
const push_pull = Generator.quote_(Generator.getFieldValue(block, 'axisOptions') || 'z');
62+
return [push_pull, Generator.ORDER_ATOMIC];
63+
};
64+
65+
Generator.gdxfor_getSpinSpeed = function(block) {
66+
const direction = Generator.valueToCode(block, 'DIRECTION', Generator.ORDER_NONE) || null;
67+
return [`gdx_for_spein_speed ${direction}?`, Generator.ORDER_ATOMIC];
68+
};
69+
70+
Generator.gdxfor_getAcceleration = function(block) {
71+
const direction = Generator.valueToCode(block, 'DIRECTION', Generator.ORDER_NONE) || null;
72+
return [`gdx_for_acceleration ${direction}?`, Generator.ORDER_ATOMIC];
73+
};
74+
75+
Generator.gdxfor_isFreeFalling = function() {
76+
return [`gdx_for_falling?`, Generator.ORDER_ATOMIC];
77+
};
1278
return Generator;
1379
}

0 commit comments

Comments
 (0)