@@ -109,7 +109,12 @@ Blockly.JavaScript['coderbot_moveForward'] = function(block) {
109
109
110
110
Blockly . Python [ 'coderbot_moveForward' ] = function ( block ) {
111
111
// Generate Python for moving forward.
112
- return 'get_bot().forward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n' ;
112
+ if ( CODERBOT_PROG_MOVE_MOTION ) {
113
+ return 'get_motion().move(dist=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n' ;
114
+
115
+ } else {
116
+ return 'get_bot().forward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n' ;
117
+ }
113
118
} ;
114
119
115
120
Blockly . Blocks [ 'coderbot_moveBackward' ] = {
@@ -136,7 +141,12 @@ Blockly.JavaScript['coderbot_moveBackward'] = function(block) {
136
141
137
142
Blockly . Python [ 'coderbot_moveBackward' ] = function ( block ) {
138
143
// Generate Python for moving forward.
139
- return 'get_bot().backward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n' ;
144
+ if ( CODERBOT_PROG_MOVE_MOTION ) {
145
+ return 'get_motion().move(dist=' + ( - CODERBOT_MOV_FW_DEF_ELAPSE ) + ')\n' ;
146
+
147
+ } else {
148
+ return 'get_bot().backward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n' ;
149
+ }
140
150
} ;
141
151
142
152
Blockly . Blocks [ 'coderbot_turnLeft' ] = {
@@ -163,7 +173,12 @@ Blockly.JavaScript['coderbot_turnLeft'] = function(block) {
163
173
164
174
Blockly . Python [ 'coderbot_turnLeft' ] = function ( block ) {
165
175
// Generate Python for turning left.
166
- return 'get_bot().left(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n' ;
176
+ if ( CODERBOT_PROG_MOVE_MOTION ) {
177
+ return 'get_motion().turn(angle=' + ( - CODERBOT_MOV_TR_DEF_ELAPSE ) + ')\n' ;
178
+
179
+ } else {
180
+ return 'get_bot().left(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n' ;
181
+ }
167
182
} ;
168
183
169
184
Blockly . Blocks [ 'coderbot_turnRight' ] = {
@@ -190,7 +205,12 @@ Blockly.JavaScript['coderbot_turnRight'] = function(block) {
190
205
191
206
Blockly . Python [ 'coderbot_turnRight' ] = function ( block ) {
192
207
// Generate Python for turning left or right.
193
- return 'get_bot().right(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n' ;
208
+ if ( CODERBOT_PROG_MOVE_MOTION ) {
209
+ return 'get_motion().turn(angle=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n' ;
210
+
211
+ } else {
212
+ return 'get_bot().right(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n' ;
213
+ }
194
214
} ;
195
215
196
216
Blockly . Blocks [ 'coderbot_say' ] = {
0 commit comments