feat(boards): python3下turtle添加 stamp 方法

This commit is contained in:
王立帮
2025-09-30 11:46:18 +08:00
parent 3aa8d53c11
commit 757f0f29ac
8 changed files with 43 additions and 3 deletions

View File

@@ -171,7 +171,6 @@ export const turtle_setxy = {
};
export const turtle_pos_shape = {
init: function () {
this.setColour(TURTLE_HUE);
var pos_shape =
@@ -200,6 +199,18 @@ export const turtle_pos_shape = {
}
};
export const turtle_stamp = {
init: function () {
this.setColour(TURTLE_HUE);
this.appendValueInput('TUR')
.setCheck('Turtle')
this.appendDummyInput()
.appendField(Blockly.Msg.TURTLE_STAMP);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};
export const turtle_clear = {
init: function () {
@@ -211,8 +222,6 @@ export const turtle_clear = {
this.setColour(TURTLE_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(clear_reset), 'DIR')
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);

View File

@@ -75,6 +75,13 @@ export const turtle_pos_shape = function (_, generator) {
return [code, generator.ORDER_ATOMIC];
}
export const turtle_stamp = function (_, generator) {
generator.definitions_.import_turtle = "import turtle";
var varName = generator.valueToCode(this, 'TUR', generator.ORDER_ASSIGNMENT) || '0';
var code = varName + '.stamp()\n';
return code;
}
export const turtle_clear = function (_, generator) {
generator.definitions_.import_turtle = "import turtle";
var varName = generator.valueToCode(this, 'TUR', generator.ORDER_ASSIGNMENT) || '0';

View File

@@ -1814,6 +1814,13 @@
</shadow>
</value>
</block>
<block type="turtle_stamp">
<value name="TUR">
<shadow type="variables_get">
<field name="VAR">tina</field>
</shadow>
</value>
</block>
<block type="turtle_clear">
<value name="TUR">
<shadow type="variables_get">

View File

@@ -1777,6 +1777,13 @@
</shadow>
</value>
</block>
<block type="turtle_stamp">
<value name="TUR">
<shadow type="variables_get">
<field name="VAR">tina</field>
</shadow>
</value>
</block>
<block type="turtle_clear">
<value name="TUR">
<shadow type="variables_get">

View File

@@ -1445,6 +1445,13 @@
</shadow>
</value>
</block>
<block type="turtle_stamp">
<value name="TUR">
<shadow type="variables_get">
<field name="VAR">tina</field>
</shadow>
</value>
</block>
<block type="turtle_clear">
<value name="TUR">
<shadow type="variables_get">

View File

@@ -1776,6 +1776,7 @@ En.TURTLE_POS_SHAPE = "Get the turtle currently";
En.TURTLE_POS = "Get the current position of the turtle";
En.TURTLE_SHAPE = "shape";
En.TURTLE_HEADING = "Heading";
En.TURTLE_STAMP = "Stamp";
En.MIXLY_TOOLTIP_TURTEL_POS = 'Get the turtle\'s current position and return a tuple containing the current position x and y coordinates';
En.MIXLY_TOOLTIP_TURTEL_SHAPE = 'Get the turtle\'s current shape and return a string';
En.MIXLY_TOOLTIP_TURTEL_GET_SPEED = "get the turtles current speed and return an integer;";

View File

@@ -1789,6 +1789,7 @@ ZhHans.TURTLE_POS_SHAPE = "获取海龟当前";
ZhHans.TURTLE_POS = "位置";
ZhHans.TURTLE_SHAPE = "形状";
ZhHans.TURTLE_HEADING = "朝向";
ZhHans.TURTLE_STAMP = "留下印记";
ZhHans.MIXLY_TOOLTIP_TURTEL_POS = '获取海龟当前位置返回一个包含当前位置x坐标和y坐标的元组';
ZhHans.MIXLY_TOOLTIP_TURTEL_SHAPE = '获取海龟当前形状,返回一个字符串';
ZhHans.MIXLY_TOOLTIP_TURTEL_GET_SPEED = '获取海龟当前速度,返回一个整数';

View File

@@ -1789,6 +1789,7 @@ ZhHant.TURTLE_POS_SHAPE = "獲取海龜當前";
ZhHant.TURTLE_POS = "位置";
ZhHant.TURTLE_SHAPE = "形狀";
ZhHant.TURTLE_HEADING = "朝向";
ZhHant.TURTLE_STAMP = "留下印記";
ZhHant.MIXLY_TOOLTIP_TURTEL_POS = '獲取海龜當前位置返回一個包含當前位置x座標和y座標的元組';
ZhHant.MIXLY_TOOLTIP_TURTEL_SHAPE = '獲取海龜當前形狀,返回一個字符串';
ZhHant.MIXLY_TOOLTIP_TURTEL_GET_SPEED = '獲取海龜當前速度,返回一個整數';