初始化提交
3
boards/default_src/python_skulpt_mixtoy/.npmignore
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
build
|
||||
origin
|
||||
742
boards/default_src/python_skulpt_mixtoy/blocks/game.js
Normal file
@@ -0,0 +1,742 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import * as Mixly from 'mixly';
|
||||
import * as path from 'path';
|
||||
|
||||
// export const game_init = {
|
||||
// init: function() {
|
||||
// this.appendDummyInput()
|
||||
// .appendField(Blockly.Msg.MIXLY_GAME_INIT);
|
||||
// this.setPreviousStatement(true);
|
||||
// this.setNextStatement(true);
|
||||
// this.setColour(290);
|
||||
// this.setTooltip('');
|
||||
// }
|
||||
// };
|
||||
//初始化地图为第X关
|
||||
export const initSettedMap = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_INIT_AS)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_ONE, '0'], [Blockly.Msg.MIXLY_GAME_TWO, '1'], [Blockly.Msg.MIXLY_GAME_THREE, '2'], [Blockly.Msg.MIXLY_GAME_FOUR, '3'], [Blockly.Msg.MIXLY_GAME_FIVE, '4'], [Blockly.Msg.MIXLY_GAME_SIX, '5']]), "level");
|
||||
this.setInputsInline(true);
|
||||
this.setNextStatement(true);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const game_init = {
|
||||
init: function () {
|
||||
this.setNextStatement(true);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.appendStatementInput('DO0')
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_INIT);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const move_direction_steps = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_TOWARD)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_RIGHT, '1'], [Blockly.Msg.MIXLY_GAME_DOWN, '2'], [Blockly.Msg.MIXLY_GAME_LEFT, '3'], [Blockly.Msg.MIXLY_GAME_UP, '0']]), "direction");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_MOVE);
|
||||
this.appendValueInput("times")
|
||||
.setCheck(Number)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_STEP);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
// export const move_direction = {
|
||||
// init: function() {
|
||||
// this.appendDummyInput()
|
||||
// .appendField("向")
|
||||
// .appendField(new Blockly.FieldDropdown([["东",'1'],["南",'2'],["西",'3'],["北",'0']]), "direction");
|
||||
// this.appendDummyInput()
|
||||
// .appendField("移动");
|
||||
// this.setInputsInline(true);
|
||||
// this.setPreviousStatement(true);
|
||||
// this.setNextStatement(true);
|
||||
// this.setColour(290);
|
||||
// this.setTooltip('');
|
||||
// }
|
||||
// };
|
||||
// export const move_forward = {
|
||||
// init: function() {
|
||||
// this.appendDummyInput()
|
||||
// .appendField("向前移动");
|
||||
// this.setPreviousStatement(true);
|
||||
// this.setNextStatement(true);
|
||||
// this.setColour(290);
|
||||
// this.setTooltip('');
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
// export const move_backward = {
|
||||
// init: function() {
|
||||
// this.appendDummyInput()
|
||||
// .appendField(Blockly.Msg.MIXLY_GAME_MOVE_BACKWARD);
|
||||
// this.setPreviousStatement(true, null);
|
||||
// this.setNextStatement(true, null);
|
||||
// this.setColour(290);
|
||||
// this.setTooltip('');
|
||||
// this.setHelpUrl('');
|
||||
// }
|
||||
// };
|
||||
export const move_related_to_spirite = {
|
||||
init: function () {
|
||||
var Directions = [
|
||||
[Blockly.Msg.MIXLY_GAME_FORWARD, 'f'],
|
||||
[Blockly.Msg.MIXLY_GAME_BACKWARD, 'b']
|
||||
];
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_RE_SPIRITE)
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_TOWARD)
|
||||
.appendField(new Blockly.FieldDropdown(Directions), 'Direction')
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_MOVE);
|
||||
this.appendValueInput("times")
|
||||
.setCheck(Number)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_STEP);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const Turn = {
|
||||
init: function () {
|
||||
var Directions = [
|
||||
[Blockly.Msg.MIXLY_GAME_TURN_LEFT, 'left'],
|
||||
[Blockly.Msg.MIXLY_GAME_TURN_RIGHT, 'right']
|
||||
];
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_RE_SPIRITE)
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_TOWARD)
|
||||
.appendField(new Blockly.FieldDropdown(Directions), 'Direction')
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_TURN);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const isDone = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ISDONE);
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const isPath = {
|
||||
init: function () {
|
||||
var Directions = [
|
||||
[Blockly.Msg.MIXLY_GAME_UP, "0"],
|
||||
[Blockly.Msg.MIXLY_GAME_DOWN, "2"],
|
||||
[Blockly.Msg.MIXLY_GAME_RIGHT, "1"],
|
||||
[Blockly.Msg.MIXLY_GAME_LEFT, "3"]
|
||||
];
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown(Directions), 'Direction')
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ISPATH);
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const is_Related_Path = {
|
||||
init: function () {
|
||||
var Directions = [[Blockly.Msg.MIXLY_GAME_FORWARD, "f"], [Blockly.Msg.MIXLY_GAME_BACKWARD, "b"], [Blockly.Msg.MIXLY_GAME_LEFT, "l"], [Blockly.Msg.MIXLY_GAME_RIGHT, "r"]];
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_RE_SPIRITE)
|
||||
.appendField(new Blockly.FieldDropdown(Directions), 'Direction')
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ISPATH);
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
//设置地图背景
|
||||
export const set_map_bg = {
|
||||
init: function () {
|
||||
this.appendValueInput("background")
|
||||
.setCheck(null)
|
||||
.appendField(Blockly.Msg.LISTS_SET_INDEX_SET + Blockly.Msg.MIXLY_GAME_BACKGROUND);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
}
|
||||
|
||||
//最新块
|
||||
export const set_map = {
|
||||
init: function () {
|
||||
// this.appendDummyInput()
|
||||
// .appendField("设置地图:长");
|
||||
this.appendValueInput("x")
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_SETMAP + Blockly.Msg.MIXLY_GAME_LENGTH_IS);
|
||||
this.appendValueInput("y")
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_WIDTH_IS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_STARTPOS_IS + "(");
|
||||
this.appendValueInput("startPos_x")
|
||||
.setCheck(Number)
|
||||
this.appendDummyInput()
|
||||
.appendField(",");
|
||||
this.appendValueInput("startPos_y")
|
||||
.setCheck(Number)
|
||||
this.appendDummyInput()
|
||||
.appendField(")");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ENDPOS_IS + "(");
|
||||
this.appendValueInput("endPos_x")
|
||||
.setCheck(Number)
|
||||
this.appendDummyInput()
|
||||
.appendField(",");
|
||||
this.appendValueInput("endPos_y")
|
||||
.setCheck(Number)
|
||||
this.appendDummyInput()
|
||||
.appendField(")");
|
||||
// this.appendDummyInput()
|
||||
// .appendField(",背景")
|
||||
// .appendField(new Blockly.FieldDropdown([["背景1","3"],["背景2","4"]]), "bg");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const game_get_local_img = {
|
||||
init: function () {
|
||||
this.imgArr = this.getLocalImg();
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown(this.getLocalImg()), "type");
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
},
|
||||
onchange: function () {
|
||||
let typeValue = this.getFieldValue("type");
|
||||
//let newImgArr = this.getLocalImg();
|
||||
let newImgArr = this.imgArr;
|
||||
if (this.haveNewSrc(this.imgArr, newImgArr)) {
|
||||
this.imgArr = newImgArr;
|
||||
var typeField = this.getField("type");
|
||||
typeField.menuGenerator_ = this.imgArr;
|
||||
if (this.checkSrc(typeValue, this.imgArr)) {
|
||||
this.setFieldValue(typeValue, "type");
|
||||
} else {
|
||||
this.setFieldValue(this.imgArr[0][1], "type");
|
||||
}
|
||||
}
|
||||
},
|
||||
haveNewSrc: function (oldArr, newArr) {
|
||||
if (oldArr.length !== newArr.length) return true;
|
||||
for (var i = 0; i < oldArr.length; i++) {
|
||||
if (oldArr[i][0].src !== newArr[i][0].src) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
checkSrc: function (newSrc, srcArr) {
|
||||
for (var i = 0; i < srcArr.length; i++) {
|
||||
if (srcArr[i][0].src == newSrc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getLocalImg: function () {
|
||||
let imgArr = [];
|
||||
try {
|
||||
// let imgDirPath = MixlyEnv.clientPath + "/mixpyBuild/maps/";///改图片路径
|
||||
// if (nodeFs.existsSync(imgDirPath)) {
|
||||
// let imgDirArr = nodeFs.readdirSync(imgDirPath);
|
||||
// for (let i = 0; i < imgDirArr.length; i++) {
|
||||
// let imgPathToLowerCase = imgDirArr[i].toLowerCase();
|
||||
// if (imgPathToLowerCase.indexOf(".png") != -1
|
||||
// || imgPathToLowerCase.indexOf(".jpg") != -1
|
||||
// || imgPathToLowerCase.indexOf(".ico") != -1) {
|
||||
// let dropdownItem = {};
|
||||
// dropdownItem.src = MixlyEnv.clientPath + "/mixpyBuild/maps/" + imgDirArr[i];
|
||||
// let dimensions = imagesize("mixpyBuild/maps/" + imgDirArr[i]);
|
||||
// dropdownItem.width = 40;
|
||||
// dropdownItem.height = dimensions.height*40/dimensions.width;
|
||||
// dropdownItem.alt = "*";
|
||||
// let dropdownArr = [];
|
||||
// dropdownArr.push(dropdownItem);
|
||||
// let dropdownData = imgDirArr[i].substring(0, imgDirArr[i].lastIndexOf("."));
|
||||
// dropdownData = '\'' + dropdownData + '\'';
|
||||
// dropdownArr.push(dropdownData);
|
||||
// imgArr.push(dropdownArr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
var imgDirArr = ["bg_default.png", "bg_astro.png", "bg_panda.jpg"]
|
||||
for (var i = 0; i < imgDirArr.length; i++) {
|
||||
var dropdownItem = {};
|
||||
dropdownItem.src = path.join(Mixly.Env.boardDirPath, "media/mixpyBuild/maps", imgDirArr[i]);
|
||||
dropdownItem.width = 40;
|
||||
dropdownItem.height = 45;
|
||||
if (imgDirArr[i] == "") {
|
||||
dropdownItem.alt = "无";
|
||||
} else {
|
||||
dropdownItem.alt = "*";
|
||||
}
|
||||
var dropdownArr = [];
|
||||
dropdownArr.push(dropdownItem);
|
||||
var dropdownData = imgDirArr[i].substring(0, imgDirArr[i].lastIndexOf("."));
|
||||
dropdownData = '\'' + dropdownData + '\'';
|
||||
dropdownArr.push(dropdownData);
|
||||
imgArr.push(dropdownArr);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
imgArr = [["'无可用地图'", "'无可用地图'"]];
|
||||
}
|
||||
if (imgArr.length > 0) {
|
||||
return imgArr;
|
||||
}
|
||||
return [["'无可用地图'", "'无可用地图'"]]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const set_pathtype = {
|
||||
init: function () {
|
||||
this.appendValueInput("pathtype")
|
||||
.setCheck(null)
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_SETPATHTYPE);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const game_get_path_img = {
|
||||
init: function () {
|
||||
this.imgArr = this.getLocalImg();
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown(this.getLocalImg()), "type");
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
},
|
||||
onchange: function () {
|
||||
let typeValue = this.getFieldValue("type");
|
||||
//let newImgArr = this.getLocalImg();
|
||||
let newImgArr = this.imgArr;
|
||||
if (this.haveNewSrc(this.imgArr, newImgArr)) {
|
||||
this.imgArr = newImgArr;
|
||||
var typeField = this.getField("type");
|
||||
typeField.menuGenerator_ = this.imgArr;
|
||||
if (this.checkSrc(typeValue, this.imgArr)) {
|
||||
this.setFieldValue(typeValue, "type");
|
||||
} else {
|
||||
this.setFieldValue(this.imgArr[0][1], "type");
|
||||
}
|
||||
}
|
||||
},
|
||||
haveNewSrc: function (oldArr, newArr) {
|
||||
if (oldArr.length !== newArr.length) return true;
|
||||
for (var i = 0; i < oldArr.length; i++) {
|
||||
if (oldArr[i][0].src !== newArr[i][0].src) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
checkSrc: function (newSrc, srcArr) {
|
||||
for (var i = 0; i < srcArr.length; i++) {
|
||||
if (srcArr[i][0].src == newSrc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getLocalImg: function () {
|
||||
let imgArr = [];
|
||||
try {
|
||||
// let imgDirPath = MixlyEnv.clientPath + "/mixpyBuild/path/";///改图片路径
|
||||
// if (nodeFs.existsSync(imgDirPath)) {
|
||||
// let imgDirArr = nodeFs.readdirSync(imgDirPath);
|
||||
// for (let i = 0; i < imgDirArr.length; i++) {
|
||||
// let imgPathToLowerCase = imgDirArr[i].toLowerCase();
|
||||
// if (imgPathToLowerCase.indexOf(".png") != -1
|
||||
// || imgPathToLowerCase.indexOf(".jpg") != -1
|
||||
// || imgPathToLowerCase.indexOf(".ico") != -1) {
|
||||
// let dropdownItem = {};
|
||||
// dropdownItem.src = MixlyEnv.clientPath + "/mixpyBuild/path/" + imgDirArr[i];
|
||||
// let dimensions = imagesize("mixpyBuild/path/" + imgDirArr[i]);
|
||||
// dropdownItem.width = 40;
|
||||
// dropdownItem.height = dimensions.height*40/dimensions.width;
|
||||
// dropdownItem.alt = "*";
|
||||
// let dropdownArr = [];
|
||||
// dropdownArr.push(dropdownItem);
|
||||
// let dropdownData = imgDirArr[i].substring(0, imgDirArr[i].lastIndexOf("."));
|
||||
// dropdownData = '\'' + dropdownData + '\'';
|
||||
// dropdownArr.push(dropdownData);
|
||||
// imgArr.push(dropdownArr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
var imgDirArr = ["default.png", "bamboo.png", "pipeline.png"]
|
||||
for (var i = 0; i < imgDirArr.length; i++) {
|
||||
var dropdownItem = {};
|
||||
dropdownItem.src = path.join(Mixly.Env.boardDirPath, "media/mixpyBuild/path", imgDirArr[i]);
|
||||
dropdownItem.width = 40;
|
||||
dropdownItem.height = 45;
|
||||
dropdownItem.alt = "*";
|
||||
var dropdownArr = [];
|
||||
dropdownArr.push(dropdownItem);
|
||||
var dropdownData = imgDirArr[i].substring(0, imgDirArr[i].lastIndexOf("."));
|
||||
dropdownData = '\'' + dropdownData + '\'';
|
||||
dropdownArr.push(dropdownData);
|
||||
imgArr.push(dropdownArr);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
imgArr = [["'无可用路径'", "'无可用路径'"]];
|
||||
}
|
||||
if (imgArr.length > 0) {
|
||||
return imgArr;
|
||||
}
|
||||
return [["'无可用路径'", "'无可用路径'"]];
|
||||
}
|
||||
};
|
||||
|
||||
export const place_item = {
|
||||
init: function () {
|
||||
this.setColour(290);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendValueInput("posx")
|
||||
.setCheck(null)
|
||||
.appendField(Blockly.Msg.TEXT_APPEND_TO + "(");
|
||||
this.appendDummyInput()
|
||||
.appendField(',');
|
||||
this.appendValueInput("posy")
|
||||
.setCheck(null)
|
||||
.appendField("");
|
||||
this.appendDummyInput()
|
||||
.appendField(')' + Blockly.Msg.MIXLY_GAME_LAY)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_WALL, "'wall'"], [Blockly.Msg.MIXLY_GAME_BARRIER, "'barrier'"], [Blockly.Msg.MIXLY_GAME_COIN, "'coin'"], [Blockly.Msg.MIXLY_GAME_REDMARKER, "'redmarker'"], [Blockly.Msg.MIXLY_GAME_YELLOWMARKER, "'yellowmarker'"], [Blockly.Msg.MIXLY_GAME_BLUEMARKER, "'bluemarker'"], [Blockly.Msg.MIXLY_GAME_GREENMARKER, "'greenmarker'"]]), "item");
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const game_get_character_img = {
|
||||
init: function () {
|
||||
this.imgArr = this.getLocalImg();
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown(this.getLocalImg()), "type");
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
},
|
||||
onchange: function () {
|
||||
let typeValue = this.getFieldValue("type");
|
||||
//let newImgArr = this.getLocalImg();
|
||||
let newImgArr = this.imgArr;
|
||||
if (this.haveNewSrc(this.imgArr, newImgArr)) {
|
||||
this.imgArr = newImgArr;
|
||||
var typeField = this.getField("type");
|
||||
typeField.menuGenerator_ = this.imgArr;
|
||||
if (this.checkSrc(typeValue, this.imgArr)) {
|
||||
this.setFieldValue(typeValue, "type");
|
||||
} else {
|
||||
this.setFieldValue(this.imgArr[0][1], "type");
|
||||
}
|
||||
}
|
||||
},
|
||||
haveNewSrc: function (oldArr, newArr) {
|
||||
if (oldArr.length !== newArr.length) return true;
|
||||
for (var i = 0; i < oldArr.length; i++) {
|
||||
if (oldArr[i][0].src !== newArr[i][0].src) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
checkSrc: function (newSrc, srcArr) {
|
||||
for (var i = 0; i < srcArr.length; i++) {
|
||||
if (srcArr[i][0].src == newSrc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getLocalImg: function () {
|
||||
let imgArr = [];
|
||||
try {
|
||||
var imgDirArr = ["pegman.png", "astro.png", "panda.png", "robot.png", 'car.png']
|
||||
for (var i = 0; i < imgDirArr.length; i++) {
|
||||
var dropdownItem = {};
|
||||
dropdownItem.src = path.join(Mixly.Env.boardDirPath, "media/mixpyBuild/characters", imgDirArr[i]);
|
||||
dropdownItem.width = 40;
|
||||
dropdownItem.height = 45;
|
||||
dropdownItem.alt = "*";
|
||||
var dropdownArr = [];
|
||||
dropdownArr.push(dropdownItem);
|
||||
var dropdownData = imgDirArr[i].substring(0, imgDirArr[i].lastIndexOf("."));
|
||||
dropdownData = '\'' + dropdownData + '\'';
|
||||
dropdownArr.push(dropdownData);
|
||||
imgArr.push(dropdownArr);
|
||||
}
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
imgArr = [["'无可用角色'", "'无可用角色'"]];
|
||||
}
|
||||
if (imgArr.length > 0) {
|
||||
return imgArr;
|
||||
}
|
||||
return [["'无可用角色'", "'无可用角色'"]];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const initialize = {
|
||||
init: function () {
|
||||
this.setColour(290);
|
||||
this.appendValueInput("character")
|
||||
.setCheck(null)
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_INIT_CHARA)
|
||||
this.appendDummyInput().appendField(Blockly.Msg.MIXLY_GAME_FACE + Blockly.Msg.MIXLY_GAME_RIGHT);
|
||||
// this.appendDummyInput()
|
||||
// // .appendField('初始化角色为')
|
||||
// // .appendField(new Blockly.FieldDropdown([["默认⼩⼈","0"],["熊猫","1"],["宇航员","2"],["机器⼈","3"]]), "character")
|
||||
// .appendField(Blockly.Msg.MIXLY_GAME_FACE)
|
||||
// .appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_NORTH,"0"],[Blockly.Msg.MIXLY_GAME_SOUTH,"2"],[Blockly.Msg.MIXLY_GAME_WEST,"3"],[Blockly.Msg.MIXLY_GAME_EAST,"1"]]), "direction");
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const get_actor_point = {
|
||||
init: function () {
|
||||
this.setColour(290);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_GETPOINT);
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const isBarrier = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_UP, "0"], [Blockly.Msg.MIXLY_GAME_DOWN, "2"], [Blockly.Msg.MIXLY_GAME_LEFT, "3"], [Blockly.Msg.MIXLY_GAME_RIGHT, "1"]]), "direction");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ISBARRIER);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const is_Related_Barrier = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_RE_SPIRITE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_FORWARD, "f"], [Blockly.Msg.MIXLY_GAME_BACKWARD, "b"], [Blockly.Msg.MIXLY_GAME_LEFT, "l"], [Blockly.Msg.MIXLY_GAME_RIGHT, "r"]]), "direction");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ISBARRIER);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const randomOil = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_RANDOMCAROIL);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const isOilFull = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_NEEDOIL);
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const isLightGreen = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ISGREEN);
|
||||
this.setOutput(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const addOil = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_ADDOIL);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const isCirculationRight = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_CHECKCIRCURIGHT);
|
||||
this.setPreviousStatement(true);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const checkMarker = {
|
||||
init: function () {
|
||||
this.setColour(290);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_CHECK_WHETHER_PASS);
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_REDMARKER, "'redmarker'"], [Blockly.Msg.MIXLY_GAME_YELLOWMARKER, "'yellowmarker'"], [Blockly.Msg.MIXLY_GAME_BLUEMARKER, "'bluemarker'"], [Blockly.Msg.MIXLY_GAME_GREENMARKER, "'greenmarker'"]]), "marker");
|
||||
this.appendDummyInput()
|
||||
.appendField("?");
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, null);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const getMarkerNum = {
|
||||
init: function () {
|
||||
this.setColour(290);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_GET_MARKER_NUM);
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_REDMARKER, "'redmarker'"], [Blockly.Msg.MIXLY_GAME_YELLOWMARKER, "'yellowmarker'"], [Blockly.Msg.MIXLY_GAME_BLUEMARKER, "'bluemarker'"], [Blockly.Msg.MIXLY_GAME_GREENMARKER, "'greenmarker'"]]), "marker");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_NUMBER_OF_MARKER);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, null);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const randomPlaceBarrier = {
|
||||
init: function () {
|
||||
this.setColour(290);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendValueInput("posx")
|
||||
.setCheck(null)
|
||||
.appendField(Blockly.Msg.TEXT_APPEND_TO + "(");
|
||||
this.appendDummyInput()
|
||||
.appendField(',');
|
||||
this.appendValueInput("posy")
|
||||
.setCheck(null)
|
||||
.appendField("");
|
||||
this.appendDummyInput()
|
||||
.appendField(')' + Blockly.Msg.TEXT_GET_INDEX_RANDOM + Blockly.Msg.MIXLY_GAME_LAY + Blockly.Msg.MIXLY_GAME_BARRIER)
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
//初始化为简单的迷宫地图,第X关
|
||||
export const settedSimpleMap = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GAME_INIT_AS)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_GAME_ONE, '0'], [Blockly.Msg.MIXLY_GAME_TWO, '1'], [Blockly.Msg.MIXLY_GAME_THREE, '2'], [Blockly.Msg.MIXLY_GAME_FOUR, '3'], [Blockly.Msg.MIXLY_GAME_FIVE, '4'], [Blockly.Msg.MIXLY_GAME_SIX, '5'], [Blockly.Msg.MIXLY_GAME_SEVEN, '6'], [Blockly.Msg.MIXLY_GAME_EIGHT, '7'], [Blockly.Msg.MIXLY_GAME_NINE, '8']
|
||||
, [Blockly.Msg.MIXLY_GAME_TEN, '9'], [Blockly.Msg.MIXLY_GAME_ELE, '10'], [Blockly.Msg.MIXLY_GAME_TWEL, '11'], [Blockly.Msg.MIXLY_GAME_THIR, '12'], [Blockly.Msg.MIXLY_GAME_FORT, '13'], [Blockly.Msg.MIXLY_GAME_FIFT, '14'], [Blockly.Msg.MIXLY_GAME_SIXT, '15'], [Blockly.Msg.MIXLY_GAME_SEVENT, '16']]), "level");
|
||||
this.setInputsInline(true);
|
||||
this.setNextStatement(true);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const find_books_by_dichotomy = {
|
||||
init: function () {
|
||||
this.appendValueInput("N")
|
||||
.setCheck(null)
|
||||
.setAlign(Blockly.inputs.Align.LEFT)
|
||||
.appendField("二分法查找书籍")
|
||||
.appendField("N");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
export const find_books_by_sequence = {
|
||||
init: function () {
|
||||
this.appendValueInput("N")
|
||||
.setCheck(null)
|
||||
.setAlign(Blockly.inputs.Align.LEFT)
|
||||
.appendField("顺序法查找书籍")
|
||||
.appendField("N");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(290);
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
1512
boards/default_src/python_skulpt_mixtoy/converters/data.js
Normal file
74
boards/default_src/python_skulpt_mixtoy/converters/inout.js
Normal file
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
pbc.globalFunctionD['input'] = function(py2block, func, args, keywords, starargs, kwargs, node){
|
||||
if (args.length !== 1 && args.length !== 0) {
|
||||
throw new Error("Incorrect number of arguments");
|
||||
}
|
||||
if (args.length == 1){
|
||||
var argblock = py2block.convert(args[0]);
|
||||
return block("inout_type_input", func.lineno, {
|
||||
"DIR":"str"
|
||||
}, {
|
||||
'VAR':argblock
|
||||
}, {
|
||||
"inline": "true"
|
||||
});}
|
||||
if (args.length == 0){
|
||||
|
||||
return block("inout_type_input", func.lineno, {
|
||||
"DIR":"str"
|
||||
}, {
|
||||
//'VAR':argblock
|
||||
}, {
|
||||
"inline": "true"
|
||||
});}
|
||||
}
|
||||
|
||||
|
||||
//int(input('prompt'))在math.js中实现
|
||||
//float(input('prompt'))在lists.js中实现
|
||||
|
||||
pbc.globalFunctionD['print'] = function(py2block, func, args, keywords, starargs, kwargs, node){
|
||||
if (args.length === 1 && keywords.length === 1
|
||||
&& py2block.identifier(keywords[0].arg) === "end"
|
||||
&& keywords[0].value._astname === "Str"
|
||||
//&& py2block.Str_value(keywords[0].value) === ""
|
||||
) { if(py2block.Str_value(keywords[0].value) === ""){//print('Hello',end ="")
|
||||
var argblock = py2block.convert(args[0]);
|
||||
return [block("inout_print_inline", func.lineno, {}, {
|
||||
'VAR':argblock
|
||||
}, {
|
||||
"inline": "false"
|
||||
})];
|
||||
}
|
||||
else{
|
||||
var argblock = py2block.convert(args[0]);
|
||||
return [block("inout_print_end", func.lineno, {
|
||||
}, {
|
||||
'VAR':argblock,
|
||||
'END':py2block.convert(keywords[0].value)
|
||||
}, {
|
||||
"inline": "true"
|
||||
})];
|
||||
}
|
||||
}else if (args.length === 1 && keywords.length === 0) { //print('Hello')
|
||||
var argblock = py2block.convert(args[0]);
|
||||
return [block("inout_print", func.lineno, {}, {
|
||||
'VAR':argblock
|
||||
}, {
|
||||
"inline": "false"
|
||||
})];
|
||||
}else if (args.length != 1 && keywords.length === 0) { //print()
|
||||
var d = py2block.convertElements("ADD", args);
|
||||
|
||||
return [block("inout_print_many", node.lineno, {
|
||||
}, d, {
|
||||
"inline": "true",
|
||||
}, {
|
||||
"@items":args.length
|
||||
})];
|
||||
|
||||
}else{
|
||||
throw new Error("Incorrect number of arguments");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
function defDict(type) {
|
||||
var dict = {};
|
||||
return {
|
||||
get: function (key) {
|
||||
if (!dict[key]) {
|
||||
dict[key] = type.constructor();
|
||||
}
|
||||
return dict[key];
|
||||
},
|
||||
dict: dict
|
||||
};
|
||||
}
|
||||
|
||||
function Py2blockConfig (){
|
||||
this.initIgnoreS();
|
||||
this.initModuleAttrD();
|
||||
this.initKnownModuleS();
|
||||
this.initObjectTypeD();
|
||||
}
|
||||
|
||||
var pbc = Py2blockConfig.prototype;
|
||||
pbc.MIXPY = "MIXPY";
|
||||
pbc.board = pbc.MIXPY;
|
||||
pbc.objectFunctionD = defDict({});
|
||||
pbc.moduleFunctionD = defDict({});
|
||||
pbc.moduleAttrD = defDict({});
|
||||
pbc.objectAttrD = defDict({});
|
||||
pbc.globalFunctionD = {};
|
||||
pbc.assignD = defDict({});
|
||||
pbc.ifStatementD= defDict({});
|
||||
pbc.whileStatementD= defDict({});
|
||||
pbc.forStatementD= defDict({});
|
||||
pbc.reservedNameD= {};
|
||||
pbc.knownModuleS = new Set();
|
||||
pbc.objectTypeD = {}; //key:变量名,value:变量类型,如{'a':'List'}
|
||||
pbc.ignoreS = new Set();
|
||||
pbc.pinType = null;
|
||||
pbc.inScope = null;
|
||||
pbc.formatModuleKeyL = [];
|
||||
pbc.formatModuleL = [];
|
||||
|
||||
//忽略某些方法、类、赋值
|
||||
pbc.initIgnoreS = function(){
|
||||
var pythonIgnoreL = [
|
||||
];
|
||||
var boardIgnoreL = [];
|
||||
|
||||
var ignoreL = pythonIgnoreL.concat(boardIgnoreL);
|
||||
for (var i = 0; i < ignoreL.length; i++) {
|
||||
this.ignoreS.add(ignoreL[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pbc.initModuleAttrD = function(){
|
||||
}
|
||||
|
||||
pbc.initKnownModuleS = function(){
|
||||
var pythonModuleL = [
|
||||
'math', 'random'
|
||||
];
|
||||
var boardModuleL = [];
|
||||
|
||||
var moduleL = pythonModuleL.concat(boardModuleL);
|
||||
for (var i = 0; i < moduleL.length; i++) {
|
||||
this.knownModuleS.add(moduleL[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pbc.initObjectTypeD = function () {
|
||||
this.objectTypeD = {
|
||||
'tina': 'turtle.Turtle',
|
||||
'f': 'open'
|
||||
}
|
||||
}
|
||||
|
||||
pbc.reset = function(){
|
||||
this.initObjectTypeD();
|
||||
}
|
||||
|
||||
var py2block_config = new Py2blockConfig();
|
||||
|
||||
45
boards/default_src/python_skulpt_mixtoy/converters/system.js
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
pbc.globalFunctionD['exit'] = function (py2block, func, args, keywords, starargs, kwargs, node) {
|
||||
if (args.length != 0) {
|
||||
throw new Error("Incorrect number of arguments");
|
||||
}
|
||||
return [block("controls_end_program", func.lineno, {}, {}, {
|
||||
"inline": "true"
|
||||
})];
|
||||
}
|
||||
|
||||
|
||||
|
||||
pbc.moduleFunctionD.get('time')['time'] = function(py2block, func, args, keywords, starargs, kwargs, node) {
|
||||
if (args.length != 0) {
|
||||
throw new Error("Incorrect number of arguments");
|
||||
}
|
||||
return block("controls_millis", func.lineno, {}, {}, {
|
||||
"inline": "true"
|
||||
});
|
||||
}
|
||||
|
||||
pbc.moduleFunctionD.get('time')['localtime'] = function(py2block, func, args, keywords, starargs, kwargs, node) {
|
||||
if (args.length != 0) {
|
||||
throw new Error("Incorrect number of arguments");
|
||||
}
|
||||
return block("time_localtime", func.lineno, {
|
||||
"op":'all'
|
||||
}, {}, {
|
||||
"inline": "true"
|
||||
});
|
||||
}
|
||||
|
||||
pbc.moduleFunctionD.get('time')['sleep'] = function(py2block, func, args, keywords, starargs, kwargs, node) {
|
||||
if (args.length != 1) {
|
||||
throw new Error("Incorrect number of arguments");
|
||||
}
|
||||
var argblock = py2block.convert(args[0]);
|
||||
return [block("time_sleep", func.lineno, {}, {
|
||||
|
||||
"DELAY_TIME":argblock
|
||||
}, {
|
||||
"inline": "true"
|
||||
})];
|
||||
}
|
||||
1127
boards/default_src/python_skulpt_mixtoy/converters/turtle.js
Normal file
@@ -0,0 +1,111 @@
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(1) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/inout.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(1) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/inout2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(2) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/ctrl.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(2) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/ctrl2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(3) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/math.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(3) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/math2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(4) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/logic.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(4) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/logic2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(5) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/text.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(5) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/text2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(6) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/list3.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(6) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/list4.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(7) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/tuple.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(7) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/tuple2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(8) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/dict.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(8) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/dict2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
|
||||
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(9) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/set.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(9) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/set2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(10) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/var.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(10) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/var2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(11) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/func.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(11) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/func2.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(12) > div:nth-child(2) > div:nth-child(1) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/game5.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(12) > div:nth-child(2) > div:nth-child(1) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/game6.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(12) > div:nth-child(2) > div:nth-child(2) > div.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/game5.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(12) > div:nth-child(2) > div:nth-child(2) > div.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
|
||||
background:url('../../../../common/media/mark/game6.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
9
boards/default_src/python_skulpt_mixtoy/export.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as MicropythonESP32Pins from './blocks/esp32_profile';
|
||||
import * as MicropythonESP32PinsBlocks from './blocks/pins';
|
||||
import * as MicropythonESP32PinsGenerators from './generators/pins';
|
||||
|
||||
export {
|
||||
MicropythonESP32Pins,
|
||||
MicropythonESP32PinsBlocks,
|
||||
MicropythonESP32PinsGenerators
|
||||
};
|
||||
292
boards/default_src/python_skulpt_mixtoy/generators/game.js
Normal file
@@ -0,0 +1,292 @@
|
||||
export const game_init = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = generator.statementToCode(block, "DO0") + 'blocklygame.initMap(\'block_id=' + block.id + '\');\n'
|
||||
|
||||
var code_piece = [];
|
||||
code_piece = code.split("\n");
|
||||
for (var i = 0; i < code_piece.length; i++) {
|
||||
if ((code_piece[i].indexOf(" ") >= 0)) {
|
||||
code_piece[i] = code_piece[i].replace(" ", "");
|
||||
}
|
||||
}
|
||||
code = ""
|
||||
for (var i = 0; i < code_piece.length; i++) {
|
||||
code += code_piece[i] + '\n'
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
// export const move_direction = function(block) {
|
||||
// generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
// var Direction = this.getFieldValue('direction');
|
||||
// return 'actor.moveDirection('+Direction+',\'block_id=' + block.id + '\');\n';
|
||||
// }
|
||||
|
||||
export const move_direction_steps = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var times = generator.valueToCode(this, 'times', generator.ORDER_ATOMIC);
|
||||
var Direction = this.getFieldValue('direction');
|
||||
var d = 'actor.moveDirection(' + Direction + ',\'block_id=' + block.id + '\');\n',
|
||||
d = generator.addLoopTrap(d, block.id) || generator.PASS;
|
||||
return 'for _my_variable in range(' + times + '):\n\t' + d;
|
||||
}
|
||||
|
||||
export const move_related_to_spirite = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var times = generator.valueToCode(this, 'times', generator.ORDER_ATOMIC);
|
||||
var Direction = this.getFieldValue('Direction');
|
||||
if (Direction == 'f') {
|
||||
Direction = 0;
|
||||
} else {
|
||||
Direction = 2
|
||||
}
|
||||
var d = 'dire=(actor.direction+' + Direction + ")%4\n\t" + 'actor.moveDirection(dire,\'block_id=' + block.id + '\');\n',
|
||||
d = generator.addLoopTrap(d, block.id) || generator.PASS;
|
||||
return 'for _my_variable in range(' + times + '):\n\t' + d;
|
||||
}
|
||||
|
||||
export const initSettedMap = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var level = this.getFieldValue('level');
|
||||
return 'blocklygame.settedMap(' + level + ',\'block_id=' + block.id + '\');\n' + 'actor=blocklygame.Actor(\'car\',2);\n';
|
||||
}
|
||||
// export const move_forward = function(block) {
|
||||
// generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
// return 'actor.moveForward(\'block_id=' + block.id + '\');\n';
|
||||
// }
|
||||
|
||||
// export const move_backward = function(block) {
|
||||
// generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
// var code = 'actor.moveBackward(\'block_id=' + block.id + '\');\n';
|
||||
// return code;
|
||||
// }
|
||||
|
||||
export const Turn = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var dropdown_Direction = this.getFieldValue('Direction');
|
||||
var code = 'actor.turn(\'' + dropdown_Direction + "','block_id=" + block.id + '\');\n';
|
||||
return code;
|
||||
}
|
||||
|
||||
export const isDone = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = 'actor.isDone(\'block_id=' + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const isPath = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var dropdown_Direction = this.getFieldValue('Direction');
|
||||
var code = 'actor.isPath(' + dropdown_Direction + ",'block_id=" + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const is_Related_Path = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var dropdown_Direction = this.getFieldValue('Direction');
|
||||
switch (dropdown_Direction) {
|
||||
case 'f':
|
||||
dropdown_Direction = 0;
|
||||
break;
|
||||
case "b":
|
||||
dropdown_Direction = 2;
|
||||
break;
|
||||
case "r":
|
||||
dropdown_Direction = 1;
|
||||
break;
|
||||
case "l":
|
||||
dropdown_Direction = 3;
|
||||
break;
|
||||
}
|
||||
var code = 'actor.isPath(' + "(actor.direction+" + dropdown_Direction + ")%4" + ",'block_id=" + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
// 从这里开始是新的块
|
||||
export const get_actor_point = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = 'actor.getPoint(\'block_id=' + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const game_get_local_img = function (_, generator) {
|
||||
var dropdown_type = this.getFieldValue('type');
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = dropdown_type;
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const set_map = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var value_x = generator.valueToCode(this, 'x', generator.ORDER_ATOMIC);
|
||||
var value_y = generator.valueToCode(this, 'y', generator.ORDER_ATOMIC);
|
||||
var startPos_x = generator.valueToCode(this, 'startPos_x', generator.ORDER_ATOMIC);
|
||||
var startPos_y = generator.valueToCode(this, 'startPos_y', generator.ORDER_ATOMIC);
|
||||
var endPos_x = generator.valueToCode(this, 'endPos_x', generator.ORDER_ATOMIC);
|
||||
var endPos_y = generator.valueToCode(this, 'endPos_y', generator.ORDER_ATOMIC);
|
||||
|
||||
return 'blocklygame.setMap(' + value_x + ',' + value_y + ',' + startPos_x + ',' + startPos_y + ',' + endPos_x + ',' + endPos_y + ",'block_id=" + block.id + '\');\n';
|
||||
}
|
||||
|
||||
export const set_map_bg = function (block, generator) {
|
||||
generator.definitions_['import_blocklygame'] = 'import blocklygame';
|
||||
var bg_pic = generator.valueToCode(this, 'background', generator.ORDER_ATOMIC);
|
||||
return 'blocklygame.set_map_bg(' + bg_pic + ",'block_id=" + block.id + '\');\n';
|
||||
}
|
||||
|
||||
export const game_get_character_img = function (_, generator) {
|
||||
var dropdown_type = this.getFieldValue('type');
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = dropdown_type;
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const initialize = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
// var value_character = this.getFieldValue('character');
|
||||
var value_direction = "1"
|
||||
// this.getFieldValue('direction');
|
||||
var value_character = generator.valueToCode(this, 'character', generator.ORDER_ATOMIC);
|
||||
return 'actor=blocklygame.Actor(' + value_character + ',' + value_direction + ",'block_id=" + block.id + '\');\n';
|
||||
}
|
||||
|
||||
export const place_item = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var value_posx = generator.valueToCode(this, 'posx', generator.ORDER_ATOMIC);
|
||||
var value_posy = generator.valueToCode(this, 'posy', generator.ORDER_ATOMIC);
|
||||
var value_item = this.getFieldValue('item');
|
||||
return 'blocklygame.placeItem(' + value_posx + ',' + value_posy + ',' + value_item + ",'block_id=" + block.id + '\');\n';
|
||||
}
|
||||
|
||||
export const game_get_path_img = function (_, generator) {
|
||||
var dropdown_type = this.getFieldValue('type');
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = dropdown_type;
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const set_pathtype = function (block, generator) {
|
||||
generator.definitions_['import_blocklygame'] = 'import blocklygame';
|
||||
var path_type = generator.valueToCode(this, 'pathtype', generator.ORDER_ATOMIC);
|
||||
return 'blocklygame.setPathType(' + path_type + ",'block_id=" + block.id + '\');\n';
|
||||
// return 'actor.getPoint();\n';
|
||||
}
|
||||
|
||||
export const isBarrier = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var dropdown_Direction = this.getFieldValue('direction');
|
||||
var code = 'actor.isBarrier(' + dropdown_Direction + ",'block_id=" + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const is_Related_Barrier = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var dropdown_Direction = this.getFieldValue('direction');
|
||||
switch (dropdown_Direction) {
|
||||
case 'f':
|
||||
dropdown_Direction = 0;
|
||||
break;
|
||||
case "b":
|
||||
dropdown_Direction = 2;
|
||||
break;
|
||||
case "r":
|
||||
dropdown_Direction = 1;
|
||||
break;
|
||||
case "l":
|
||||
dropdown_Direction = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
var code = 'actor.isBarrier(' + "(actor.direction+" + dropdown_Direction + ")%4" + ",'block_id=" + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const randomOil = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
return 'actor.randomOil(\'block_id=' + block.id + '\');\n';
|
||||
}
|
||||
|
||||
export const isOilFull = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = 'actor.isOilFull(\'block_id=' + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const isLightGreen = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = 'actor.isLightGreen(\'block_id=' + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const addOil = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = 'actor.addOil(\'block_id=' + block.id + '\');\n';
|
||||
return code;
|
||||
}
|
||||
|
||||
export const isCirculationRight = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var code = 'actor.isCirculationRight(\'block_id=' + block.id + '\');\n';
|
||||
return code;
|
||||
}
|
||||
|
||||
export const checkMarker = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var marker = this.getFieldValue('marker');
|
||||
var code = 'actor.checkMarker(' + marker + ',\'block_id=' + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const getMarkerNum = function (block, generator) {
|
||||
generator.definitions_['import_blocklygame'] = 'import blocklygame';
|
||||
var marker = this.getFieldValue('marker');
|
||||
var code = 'actor.getMarkerNum(' + marker + ',\'block_id=' + block.id + '\')';
|
||||
return [code, generator.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
export const randomPlaceBarrier = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var value_posx = generator.valueToCode(this, 'posx', generator.ORDER_ATOMIC);
|
||||
var value_posy = generator.valueToCode(this, 'posy', generator.ORDER_ATOMIC);
|
||||
return 'blocklygame.randomPlaceBarrier(' + value_posx + ',' + value_posy + ",'block_id=" + block.id + '\');\n';
|
||||
}
|
||||
|
||||
export const settedSimpleMap = function (block, generator) {
|
||||
generator.definitions_.import_blocklygame = "import blocklygame";
|
||||
var level = this.getFieldValue('level');
|
||||
return 'blocklygame.settedSimpleMap(' + level + ',\'block_id=' + block.id + '\');\n';
|
||||
}
|
||||
|
||||
export const find_books_by_dichotomy = function (_, generator) {
|
||||
var VALUE_INPUT_N = generator.valueToCode(this, "N", generator.ORDER_ATOMIC);
|
||||
generator.setups_["find_books_by_dichotomy"] = `
|
||||
def find_books_by_dichotomy(N):
|
||||
counter = 0
|
||||
left = 0
|
||||
right = N
|
||||
key = N
|
||||
i = (left + right) / 2
|
||||
while i != key:
|
||||
counter = counter + 1
|
||||
if i > key:
|
||||
right = i
|
||||
else:
|
||||
left = i
|
||||
i = ((left + right) + 1) / 2
|
||||
print(counter,end ="")\n`;
|
||||
return `find_books_by_dichotomy(${VALUE_INPUT_N})\n`;
|
||||
}
|
||||
|
||||
export const find_books_by_sequence = function (_, generator) {
|
||||
var VALUE_INPUT_N = generator.valueToCode(this, "N", generator.ORDER_ATOMIC);
|
||||
generator.setups_["find_books_by_sequence"] = `
|
||||
def find_books_by_sequence(N):
|
||||
counter = 1
|
||||
key = N
|
||||
i = 1
|
||||
while i != key:
|
||||
counter = counter + 1
|
||||
i = i + 1
|
||||
print(counter,end ="")\n`;
|
||||
return `find_books_by_sequence(${VALUE_INPUT_N})\n`;
|
||||
}
|
||||
101
boards/default_src/python_skulpt_mixtoy/index.js
Normal file
@@ -0,0 +1,101 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { Profile } from 'mixly';
|
||||
|
||||
import Variables from '@mixly/python/others/variables';
|
||||
import Procedures from '@mixly/python/others/procedures';
|
||||
import { Python } from '@mixly/python/python_generator';
|
||||
|
||||
import * as PythonVariablesBlocks from '@mixly/python/blocks/variables';
|
||||
import * as PythonControlBlocks from '@mixly/python/blocks/control';
|
||||
import * as PythonMathBlocks from '@mixly/python/blocks/math';
|
||||
import * as PythonTextBlocks from '@mixly/python/blocks/text';
|
||||
import * as PythonListsBlocks from '@mixly/python/blocks/lists';
|
||||
import * as PythonDictsBlocks from '@mixly/python/blocks/dicts';
|
||||
import * as PythonLogicBlocks from '@mixly/python/blocks/logic';
|
||||
import * as PythonStorageBlocks from '@mixly/python/blocks/storage';
|
||||
import * as PythonProceduresBlocks from '@mixly/python/blocks/procedures';
|
||||
import * as PythonTupleBlocks from '@mixly/python/blocks/tuple';
|
||||
import * as PythonSetBlocks from '@mixly/python/blocks/set';
|
||||
import * as PythonHtmlBlocks from '@mixly/python/blocks/html';
|
||||
import * as PythonUtilityBlocks from '@mixly/python/blocks/utility';
|
||||
|
||||
import * as SkulptPyDataBlocks from '@mixly/python-skulpt/blocks/data';
|
||||
import * as SkulptPyInoutBlocks from '@mixly/python-skulpt/blocks/inout';
|
||||
import * as SkulptPySystemBlocks from '@mixly/python-skulpt/blocks/system';
|
||||
import * as SkulptPyTurtleBlocks from '@mixly/python-skulpt/blocks/turtle';
|
||||
|
||||
import * as GameBlocks from './blocks/game';
|
||||
|
||||
import * as PythonVariablesGenerators from '@mixly/python/generators/variables';
|
||||
import * as PythonControlGenerators from '@mixly/python/generators/control';
|
||||
import * as PythonMathGenerators from '@mixly/python/generators/math';
|
||||
import * as PythonTextGenerators from '@mixly/python/generators/text';
|
||||
import * as PythonListsGenerators from '@mixly/python/generators/lists';
|
||||
import * as PythonDictsGenerators from '@mixly/python/generators/dicts';
|
||||
import * as PythonLogicGenerators from '@mixly/python/generators/logic';
|
||||
import * as PythonStorageGenerators from '@mixly/python/generators/storage';
|
||||
import * as PythonProceduresGenerators from '@mixly/python/generators/procedures';
|
||||
import * as PythonTupleGenerators from '@mixly/python/generators/tuple';
|
||||
import * as PythonSetGenerators from '@mixly/python/generators/set';
|
||||
import * as PythonHtmlGenerators from '@mixly/python/generators/html';
|
||||
import * as PythonUtilityGenerators from '@mixly/python/generators/utility';
|
||||
|
||||
import * as SkulptPyDataGenerators from '@mixly/python-skulpt/generators/data';
|
||||
import * as SkulptPyInoutGenerators from '@mixly/python-skulpt/generators/inout';
|
||||
import * as SkulptPySystemGenerators from '@mixly/python-skulpt/generators/system';
|
||||
import * as SkulptPyTurtleGenerators from '@mixly/python-skulpt/generators/turtle';
|
||||
|
||||
import * as GameGenerators from './generators/game';
|
||||
|
||||
import './css/color_mixpy_python_skulpt.css';
|
||||
|
||||
Object.assign(Blockly.Variables, Variables);
|
||||
Object.assign(Blockly.Procedures, Procedures);
|
||||
Blockly.Python = Python;
|
||||
Blockly.generator = Python;
|
||||
|
||||
Profile.default = {};
|
||||
|
||||
Object.assign(
|
||||
Blockly.Blocks,
|
||||
PythonVariablesBlocks,
|
||||
PythonControlBlocks,
|
||||
PythonMathBlocks,
|
||||
PythonTextBlocks,
|
||||
PythonListsBlocks,
|
||||
PythonDictsBlocks,
|
||||
PythonLogicBlocks,
|
||||
PythonStorageBlocks,
|
||||
PythonProceduresBlocks,
|
||||
PythonTupleBlocks,
|
||||
PythonSetBlocks,
|
||||
PythonHtmlBlocks,
|
||||
PythonUtilityBlocks,
|
||||
SkulptPyDataBlocks,
|
||||
SkulptPyInoutBlocks,
|
||||
SkulptPySystemBlocks,
|
||||
SkulptPyTurtleBlocks,
|
||||
GameBlocks,
|
||||
);
|
||||
|
||||
Object.assign(
|
||||
Blockly.Python.forBlock,
|
||||
PythonVariablesGenerators,
|
||||
PythonControlGenerators,
|
||||
PythonMathGenerators,
|
||||
PythonTextGenerators,
|
||||
PythonListsGenerators,
|
||||
PythonDictsGenerators,
|
||||
PythonLogicGenerators,
|
||||
PythonStorageGenerators,
|
||||
PythonProceduresGenerators,
|
||||
PythonTupleGenerators,
|
||||
PythonSetGenerators,
|
||||
PythonHtmlGenerators,
|
||||
PythonUtilityGenerators,
|
||||
SkulptPyDataGenerators,
|
||||
SkulptPyInoutGenerators,
|
||||
SkulptPySystemGenerators,
|
||||
SkulptPyTurtleGenerators,
|
||||
GameGenerators
|
||||
);
|
||||
12
boards/default_src/python_skulpt_mixtoy/origin/config.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"language": "Python",
|
||||
"nav": {
|
||||
"webrun": true,
|
||||
"websteprun": true,
|
||||
"webcancel": true,
|
||||
"save": {
|
||||
"py": true
|
||||
}
|
||||
},
|
||||
"saveMixWithCode": false
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="8`5?3f[L.cJuj(rBmO(l" x="-164" y="-204"><field name="level">2</field><next><block type="initialize" id="MHo8pG1x6V2(GNvGx/(9"><value name="character"><shadow type="game_get_character_img" id="64QJ5u/J+aR?|-J=6hog"><field name="type">'pegman'</field></shadow></value><next><block type="move_direction_steps" id="#Il*}GZ-u:8;SFJiX9o]"><field name="direction">1</field><value name="times"><shadow type="math_number" id="Ydn(A:S27H~}cdq^*/sb"><field name="NUM">2</field></shadow></value><next><block type="move_direction_steps" id=":-C.UXj4s9%7s)jNt?gw"><field name="direction">0</field><value name="times"><shadow type="math_number" id=",22ipcZmERnvA2+?8R8,"><field name="NUM">2</field></shadow></value><next><block type="move_direction_steps" id="I=@`%$w6]SmGswUt7utR"><field name="direction">1</field><value name="times"><shadow type="math_number" id="/7tLajyF!Y:LnZ([TMkE"><field name="NUM">2</field></shadow></value><next><block type="move_direction_steps" id="q5;N?)ZuTQ42nl9C%REG"><field name="direction">0</field><value name="times"><shadow type="math_number" id="/@wksJ=|n==[A[28A_SA"><field name="NUM">2</field></shadow></value><next><block type="move_direction_steps" id="wRbTih9w5FicBNF6#xy]"><field name="direction">3</field><value name="times"><shadow type="math_number" id="TAfrQa=uXl=%YUSNU:9M"><field name="NUM">1</field></shadow></value><next><block type="move_direction_steps" id="j^JqA1cNJlk}Dna5k37Q"><field name="direction">0</field><value name="times"><shadow type="math_number" id="^F1UG.qL]xu81b+|]Wxq"><field name="NUM">1</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="^)@}39Z?,V`)4w-S.U[M" x="184" y="143"><field name="level">0</field></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="8`5?3f[L.cJuj(rBmO(l" x="-164" y="-204"><field name="level">0</field><next><block type="initialize" id="MHo8pG1x6V2(GNvGx/(9"><value name="character"><shadow type="game_get_character_img" id="64QJ5u/J+aR?|-J=6hog"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="8`5?3f[L.cJuj(rBmO(l" x="-164" y="-204"><field name="level">1</field><next><block type="initialize" id="MHo8pG1x6V2(GNvGx/(9"><value name="character"><shadow type="game_get_character_img" id="64QJ5u/J+aR?|-J=6hog"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="8`5?3f[L.cJuj(rBmO(l" x="-164" y="-204"><field name="level">2</field><next><block type="initialize" id="MHo8pG1x6V2(GNvGx/(9"><value name="character"><shadow type="game_get_character_img" id="64QJ5u/J+aR?|-J=6hog"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="u3@ltr$xo-Pdd5$?~ti*" x="142" y="-157"><field name="level">10</field><next><block type="initialize" id="qgxFH:Y*`LuGcFH,H]4U"><value name="character"><shadow type="game_get_character_img" id="+u/*-~vJv);D:h5UR$Vk"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="u3@ltr$xo-Pdd5$?~ti*" x="15" y="-414"><field name="level">9</field><next><block type="initialize" id="qgxFH:Y*`LuGcFH,H]4U"><value name="character"><shadow type="game_get_character_img" id="+u/*-~vJv);D:h5UR$Vk"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="s}/I)ojO+hD;T_+lom-c" x="168" y="125"><field name="level">3</field><next><block type="initialize" id="zp^+tz8}o3@]wEz(=s@+"><value name="character"><shadow type="game_get_character_img" id="KTDrJ;$Z_I^v//(HM~;H"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="s}/I)ojO+hD;T_+lom-c" x="426" y="123"><field name="level">4</field><next><block type="initialize" id="zp^+tz8}o3@]wEz(=s@+"><value name="character"><shadow type="game_get_character_img" id="KTDrJ;$Z_I^v//(HM~;H"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="~.FktSh~:wX!gg%GbKCh" x="245" y="119"><field name="level">11</field><next><block type="initialize" id="|u]Ax(AqS.I`Y/5C=hUM"><value name="character"><shadow type="game_get_character_img" id="vHo0tb[7n1%|HwhazRn+"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="~.FktSh~:wX!gg%GbKCh" x="245" y="119"><field name="level">5</field><next><block type="initialize" id="|u]Ax(AqS.I`Y/5C=hUM"><value name="character"><shadow type="game_get_character_img" id="vHo0tb[7n1%|HwhazRn+"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="~.FktSh~:wX!gg%GbKCh" x="245" y="119"><field name="level">1</field><next><block type="initialize" id="|u]Ax(AqS.I`Y/5C=hUM"><value name="character"><shadow type="game_get_character_img" id="vHo0tb[7n1%|HwhazRn+"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml"><block type="settedSimpleMap" id="~.FktSh~:wX!gg%GbKCh" x="245" y="119"><field name="level">1</field><next><block type="initialize" id="|u]Ax(AqS.I`Y/5C=hUM"><value name="character"><shadow type="game_get_character_img" id="vHo0tb[7n1%|HwhazRn+"><field name="type">'pegman'</field></shadow></value></block></next></block></xml>
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"1644591921-1-filename.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1644591921-1-filename.mix"
|
||||
},
|
||||
"1644592048-1-first.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1644592048-1-first.mix"
|
||||
},
|
||||
"1644835576-57-第一关.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1644835576-57-第一关.mix"
|
||||
},
|
||||
"1644835589-57-第二关.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1644835589-57-第二关.mix"
|
||||
},
|
||||
"1644835604-57-第三关.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1644835604-57-第三关.mix"
|
||||
},
|
||||
"1646029690-1-地图11.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1646029690-1-地图11.mix"
|
||||
},
|
||||
"1646030057-1-地图11.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1646030057-1-地图11.mix"
|
||||
},
|
||||
"1646031090-1-1-1.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1646031090-1-1-1.mix"
|
||||
},
|
||||
"1646031217-1-1-1.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1646031217-1-1-1.mix"
|
||||
},
|
||||
"1646031510-1-1-2.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1646031510-1-1-2.mix"
|
||||
},
|
||||
"1646031571-1-1-3.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1646031571-1-1-3.mix"
|
||||
},
|
||||
"1646031798-1-2-1.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1646031798-1-2-1.mix"
|
||||
},
|
||||
"1647180522-60-3-1.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647180522-60-3-1.mix"
|
||||
},
|
||||
"1647180554-60-3-2.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647180554-60-3-2.mix"
|
||||
},
|
||||
"1647180673-60-3-3.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647180673-60-3-3.mix"
|
||||
},
|
||||
"1647181126-60-3-3.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647181126-60-3-3.mix"
|
||||
},
|
||||
"1647181709-60-4-2.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647181709-60-4-2.mix"
|
||||
},
|
||||
"1647181760-60-4-2.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647181760-60-4-2.mix"
|
||||
},
|
||||
"1647182686-60-4-1.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647182686-60-4-1.mix"
|
||||
},
|
||||
"1647182723-60-4-2.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647182723-60-4-2.mix"
|
||||
},
|
||||
"1647182843-60-4-1.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647182843-60-4-1.mix"
|
||||
},
|
||||
"1647183296-1-4-1.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647183296-1-4-1.mix"
|
||||
},
|
||||
"1647183320-1-4-2.mix": {
|
||||
"__file__": true,
|
||||
"__name__": "1647183320-1-4-2.mix"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 206 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 800 B |
|
After Width: | Height: | Size: 14 KiB |
BIN
boards/default_src/python_skulpt_mixtoy/origin/media/webpy.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
boards/default_src/python_skulpt_mixtoy/origin/media/webpy0.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
@@ -0,0 +1,3 @@
|
||||
var mixpyProject = new MixpyProject();
|
||||
var pyengine = new PyEngine({}, mixpyProject);
|
||||
Sk.__future__ = Sk.python3;
|
||||
32
boards/default_src/python_skulpt_mixtoy/package.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@mixly/python-skulpt-mixtoy",
|
||||
"version": "1.0.0",
|
||||
"description": "适用于mixly的python skulpt mixtoy模块",
|
||||
"scripts": {
|
||||
"build:dev": "webpack --config=webpack.dev.js",
|
||||
"build:prod": "webpack --config=webpack.prod.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mixly/python": "1.0.0"
|
||||
},
|
||||
"main": "./export.js",
|
||||
"author": "Mixly Team",
|
||||
"keywords": [
|
||||
"mixly",
|
||||
"mixly-plugin",
|
||||
"python-skulpt-mixtoy"
|
||||
],
|
||||
"homepage": "https://gitee.com/mixly2/mixly2.0_src/tree/develop/boards/default_src/python_skulpt_mixtoy",
|
||||
"bugs": {
|
||||
"url": "https://gitee.com/mixly2/mixly2.0_src/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitee.com/mixly2/mixly2.0_src.git",
|
||||
"directory": "default_src/python_skulpt_mixtoy"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
1295
boards/default_src/python_skulpt_mixtoy/template.xml
Normal file
12
boards/default_src/python_skulpt_mixtoy/webpack.common.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const path = require("path");
|
||||
const common = require("../../../webpack.common");
|
||||
const { merge } = require("webpack-merge");
|
||||
|
||||
module.exports = merge(common, {
|
||||
resolve: {
|
||||
alias: {
|
||||
'@mixly/python': path.resolve(__dirname, '../python'),
|
||||
'@mixly/python-skulpt': path.resolve(__dirname, '../python_skulpt')
|
||||
}
|
||||
}
|
||||
});
|
||||
21
boards/default_src/python_skulpt_mixtoy/webpack.dev.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const path = require("path");
|
||||
const common = require("./webpack.common");
|
||||
const { merge } = require("webpack-merge");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const ESLintPlugin = require('eslint-webpack-plugin');
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: "development",
|
||||
devtool: 'source-map',
|
||||
plugins: [
|
||||
new ESLintPlugin({
|
||||
context: process.cwd(),
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: false,
|
||||
template: path.resolve(process.cwd(), 'template.xml'),
|
||||
filename: 'index.xml',
|
||||
minify: false
|
||||
}),
|
||||
]
|
||||
});
|
||||
27
boards/default_src/python_skulpt_mixtoy/webpack.prod.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const path = require("path");
|
||||
const common = require("./webpack.common");
|
||||
const { merge } = require("webpack-merge");
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
var HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: "production",
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: false,
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: false,
|
||||
template: path.resolve(process.cwd(), 'template.xml'),
|
||||
filename: 'index.xml',
|
||||
minify: {
|
||||
removeAttributeQuotes: true,
|
||||
collapseWhitespace: true,
|
||||
removeComments: true,
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
});
|
||||