123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- /**
- * Turtles!
- */
- //Blockly.HSV_SATURATION = 0.523;
- //Blockly.HSV_VALUE = 0.847;
- var Turtle_HUE = 237;
- Blockly.Blocks['turtle_create'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("create new turtle");
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- this.setOutput(false);
- this.setInputsInline(true);
- this.setColour(Turtle_HUE);
- this.setTooltip('');
- this.setHelpUrl('');
- }
- };
- Blockly.Blocks['turtle_color'] = {
- init: function() {
- this.appendValueInput("COLOR")
- .setCheck(null)
- .appendField("make turtle color");
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- this.setOutput(false);
- this.setInputsInline(true);
- this.setColour(Turtle_HUE);
- this.setTooltip('');
- this.setHelpUrl('');
- }
- };
- Blockly.Blocks['turtle_forward'] = {
- init: function() {
- this.appendValueInput("DISTANCE")
- .setCheck(null)
- .appendField("make turtle move forward by");
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- this.setInputsInline(true);
- this.setOutput(false);
- this.setColour(Turtle_HUE);
- this.setTooltip('');
- this.setHelpUrl('');
- }
- };
- Blockly.Blocks['turtle_backward'] = {
- init: function() {
- this.appendValueInput("DISTANCE")
- .setCheck(null)
- .appendField("make turtle move backward by");
- this.setPreviousStatement(true);
- this.setInputsInline(true);
- this.setNextStatement(true);
- this.setOutput(false);
- this.setColour(Turtle_HUE);
- this.setTooltip('');
- this.setHelpUrl('');
- }
- };
- Blockly.Blocks['turtle_left'] = {
- init: function() {
- this.appendValueInput("ANGLE")
- .setCheck(null)
- .appendField("make turtle turn left by");
- this.appendDummyInput("")
- .appendField("degree");
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- this.setInputsInline(true);
- this.setOutput(false);
- this.setColour(Turtle_HUE);
- this.setTooltip('');
- this.setHelpUrl('');
- }
- };
- Blockly.Blocks['turtle_right'] = {
- init: function() {
- this.appendValueInput("ANGLE")
- .setCheck(null)
- .appendField("make turtle turn right by");
- this.appendDummyInput("")
- .appendField("degree");
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- this.setInputsInline(true);
- this.setOutput(false);
- this.setColour(Turtle_HUE);
- this.setTooltip('');
- this.setHelpUrl('');
- }
- };
- Blockly.Blocks['turtle_shape'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("make turtle shape")
- .appendField(new Blockly.FieldDropdown([["turtle","turtle"], ["circle","circle"], ["classic","classic"], ["square","square"], ["triangle","triangle"]]), "Shape");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['turtle_pen'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("make turtle pen")
- .appendField(new Blockly.FieldDropdown([["up","up"], ["down","down"]]), "Pen");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['turtle_circle'] = {
- init: function() {
- this.appendValueInput("RADIUS")
- .setCheck("Number")
- .appendField("make turtle circle with radius:");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['turtle_goto'] = {
- init: function() {
- this.appendValueInput("X")
- .setCheck("Number")
- .appendField("make turtle goto location X:");
- this.appendValueInput("Y")
- .setCheck("Number")
- .appendField(",Y:");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['turtle_pos'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("pos");
- this.setOutput(true, 'Turtle_Position');
- this.setColour(Turtle_HUE);
- this.setTooltip('Turtle position');
- this.setHelpUrl('');
- }
- };
- /*PythonToBlocks.KNOWN_ATTR_FUNCTIONS['pos'] = function(func, args, keywords, starargs, kwargs, node) {
- if (args.length != 0) {
- throw new Error("Incorrect number of arguments to turtle.pos!");
- }
- return [block("turtle_pos", {}, {}, {
- }, {"inline": "true"})];
- }*/
- Blockly.Blocks['turtle_stamp'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("make turtle stamp");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['turtle_begin_fill'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("make turtle begin fill");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['turtle_end_fill'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("make turtle end fill");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['turtle_speed'] = {
- init: function() {
- this.appendValueInput("SPEED")
- .setCheck("Number")
- .appendField("make turtle speed");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Turtle_HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
|