Initial commit of 001code-html Scratch frontend project.
Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
683
scratch-blocks/blocks_vertical/motion.js
Normal file
683
scratch-blocks/blocks_vertical/motion.js
Normal file
@@ -0,0 +1,683 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2016 Massachusetts Institute of Technology
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Blocks.motion');
|
||||
|
||||
goog.require('Blockly.Blocks');
|
||||
goog.require('Blockly.Colours');
|
||||
goog.require('Blockly.constants');
|
||||
goog.require('Blockly.ScratchBlocks.VerticalExtensions');
|
||||
|
||||
|
||||
Blockly.Blocks['motion_movesteps'] = {
|
||||
/**
|
||||
* Block to move steps.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_MOVESTEPS,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "STEPS"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_testblock'] = {
|
||||
/**
|
||||
* Block to move steps.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_MOVESTEPS,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "STEPS"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_move_f'] = {
|
||||
/**
|
||||
* Block to move steps.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_MOVEFOWRD,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "STEPS"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_move_b'] = {
|
||||
/**
|
||||
* Block to move steps.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_MOVEBACK,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "STEPS"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_turnright'] = {
|
||||
/**
|
||||
* Block to turn right.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_TURNRIGHT,
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_image",
|
||||
"src": Blockly.mainWorkspace.options.pathToMedia + "rotate-right.svg",
|
||||
"width": 24,
|
||||
"height": 24
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "DEGREES"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_turnleft'] = {
|
||||
/**
|
||||
* Block to turn left.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_TURNLEFT,
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_image",
|
||||
"src": Blockly.mainWorkspace.options.pathToMedia + "rotate-left.svg",
|
||||
"width": 24,
|
||||
"height": 24
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "DEGREES"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_jump_move'] = {
|
||||
/**
|
||||
* Block to move steps.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_JUMP_MOVE,
|
||||
"args0": [
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_pointindirection'] = {
|
||||
/**
|
||||
* Block to point in direction.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_POINTINDIRECTION,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "DIRECTION"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_cmd_print'] = {
|
||||
/**
|
||||
* Block to move steps.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_PRINT,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "TEXT"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_pointtowards_menu'] = {
|
||||
/**
|
||||
* Point towards drop-down menu.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "TOWARDS",
|
||||
"options": [
|
||||
[Blockly.Msg.MOTION_POINTTOWARDS_POINTER, '_mouse_'],
|
||||
[Blockly.Msg.MOTION_POINTTOWARDS_RANDOM, '_random_']
|
||||
]
|
||||
}
|
||||
],
|
||||
"colour": Blockly.Colours.motion.secondary,
|
||||
"colourSecondary": Blockly.Colours.motion.secondary,
|
||||
"colourTertiary": Blockly.Colours.motion.tertiary,
|
||||
"colourQuaternary": Blockly.Colours.motion.quaternary,
|
||||
"extensions": ["output_string"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_pointtowards'] = {
|
||||
/**
|
||||
* Block to point in direction.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_POINTTOWARDS,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "TOWARDS"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_goto_menu'] = {
|
||||
/**
|
||||
* Go to drop-down menu.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "TO",
|
||||
"options": [
|
||||
[Blockly.Msg.MOTION_GOTO_POINTER, '_mouse_'],
|
||||
[Blockly.Msg.MOTION_GOTO_RANDOM, '_random_']
|
||||
]
|
||||
}
|
||||
],
|
||||
"colour": Blockly.Colours.motion.secondary,
|
||||
"colourSecondary": Blockly.Colours.motion.secondary,
|
||||
"colourTertiary": Blockly.Colours.motion.tertiary,
|
||||
"colourQuaternary": Blockly.Colours.motion.quaternary,
|
||||
"extensions": ["output_string"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_gotoxy'] = {
|
||||
/**
|
||||
* Block to go to X, Y.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_GOTOXY,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "X"
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "Y"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_goto'] = {
|
||||
/**
|
||||
* Block to go to a menu item.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_GOTO,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "TO"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_glidesecstoxy'] = {
|
||||
/**
|
||||
* Block to glide for a specified time.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_GLIDESECSTOXY,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "SECS"
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "X"
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "Y"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_glideto_menu'] = {
|
||||
/**
|
||||
* Glide to drop-down menu
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "TO",
|
||||
"options": [
|
||||
[Blockly.Msg.MOTION_GLIDETO_POINTER, '_mouse_'],
|
||||
[Blockly.Msg.MOTION_GLIDETO_RANDOM, '_random_']
|
||||
]
|
||||
}
|
||||
],
|
||||
"colour": Blockly.Colours.motion.secondary,
|
||||
"colourSecondary": Blockly.Colours.motion.secondary,
|
||||
"colourTertiary": Blockly.Colours.motion.tertiary,
|
||||
"colourQuaternary": Blockly.Colours.motion.quaternary,
|
||||
"extensions": ["output_string"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_glideto'] = {
|
||||
/**
|
||||
* Block to glide to a menu item
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_GLIDETO,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "SECS"
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "TO"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_changexby'] = {
|
||||
/**
|
||||
* Block to change X.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_CHANGEXBY,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "DX"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_setx'] = {
|
||||
/**
|
||||
* Block to set X.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_SETX,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "X"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_changeyby'] = {
|
||||
/**
|
||||
* Block to change Y.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_CHANGEYBY,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "DY"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_sety'] = {
|
||||
/**
|
||||
* Block to set Y.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_SETY,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "Y"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_ifonedgebounce'] = {
|
||||
/**
|
||||
* Block to bounce on edge.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_IFONEDGEBOUNCE,
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_setrotationstyle'] = {
|
||||
/**
|
||||
* Block to set rotation style.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_SETROTATIONSTYLE,
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "STYLE",
|
||||
"options": [
|
||||
[Blockly.Msg.MOTION_SETROTATIONSTYLE_LEFTRIGHT, 'left-right'],
|
||||
[Blockly.Msg.MOTION_SETROTATIONSTYLE_DONTROTATE, 'don\'t rotate'],
|
||||
[Blockly.Msg.MOTION_SETROTATIONSTYLE_ALLAROUND, 'all around']
|
||||
]
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_xposition'] = {
|
||||
/**
|
||||
* Block to report X.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_XPOSITION,
|
||||
"category": Blockly.Categories.motion,
|
||||
// "checkboxInFlyout": true,
|
||||
"extensions": ["colours_motion", "output_number"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_yposition'] = {
|
||||
/**
|
||||
* Block to report Y.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_YPOSITION,
|
||||
"category": Blockly.Categories.motion,
|
||||
// "checkboxInFlyout": true,
|
||||
"extensions": ["colours_motion", "output_number"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_direction'] = {
|
||||
/**
|
||||
* Block to report direction.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_DIRECTION,
|
||||
"category": Blockly.Categories.motion,
|
||||
// "checkboxInFlyout": true,
|
||||
"extensions": ["colours_motion", "output_number"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_scroll_right'] = {
|
||||
/**
|
||||
* Block to scroll the stage right. Does not actually do anything. This is
|
||||
* an obsolete block that is implemented for compatibility with Scratch 2.0
|
||||
* projects.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_SCROLLRIGHT,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "DISTANCE"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_scroll_up'] = {
|
||||
/**
|
||||
* Block to scroll the stage up. Does not actually do anything. This is an
|
||||
* obsolete block that is implemented for compatibility with Scratch 2.0
|
||||
* projects.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_SCROLLUP,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "DISTANCE"
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_align_scene'] = {
|
||||
/**
|
||||
* Block to change the stage's scrolling alignment. Does not actually do
|
||||
* anything. This is an obsolete block that is implemented for compatibility
|
||||
* with Scratch 2.0 projects.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_ALIGNSCENE,
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "ALIGNMENT",
|
||||
"options": [
|
||||
[Blockly.Msg.MOTION_ALIGNSCENE_BOTTOMLEFT, 'bottom-left'],
|
||||
[Blockly.Msg.MOTION_ALIGNSCENE_BOTTOMRIGHT, 'bottom-right'],
|
||||
[Blockly.Msg.MOTION_ALIGNSCENE_MIDDLE, 'middle'],
|
||||
[Blockly.Msg.MOTION_ALIGNSCENE_TOPLEFT, 'top-left'],
|
||||
[Blockly.Msg.MOTION_ALIGNSCENE_TOPRIGHT, 'top-right']
|
||||
]
|
||||
}
|
||||
],
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "shape_statement"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_xscroll'] = {
|
||||
/**
|
||||
* Block to report the stage's scroll position's X value. Does not actually
|
||||
* do anything. This is an obsolete block that is implemented for
|
||||
* compatibility with Scratch 2.0 projects.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_XSCROLL,
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "output_number"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['motion_yscroll'] = {
|
||||
/**
|
||||
* Block to report the stage's scroll position's Y value. Does not actually
|
||||
* do anything. This is an obsolete block that is implemented for
|
||||
* compatibility with Scratch 2.0 projects.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MOTION_YSCROLL,
|
||||
"category": Blockly.Categories.motion,
|
||||
"extensions": ["colours_motion", "output_number"]
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user