kopia lustrzana https://github.com/backface/turtlestitch
added "random" option for "go to", "point towards" and "point in direction" primitives
rodzic
04d3a37b67
commit
c3dcde5bf8
25
blocks.js
25
blocks.js
|
@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.blocks = '2018-February-15';
|
modules.blocks = '2018-March-09';
|
||||||
|
|
||||||
var SyntaxElementMorph;
|
var SyntaxElementMorph;
|
||||||
var BlockMorph;
|
var BlockMorph;
|
||||||
|
@ -938,7 +938,8 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
'(90) right' : 90,
|
'(90) right' : 90,
|
||||||
'(-90) left' : -90,
|
'(-90) left' : -90,
|
||||||
'(0) up' : '0',
|
'(0) up' : '0',
|
||||||
'(180) down' : 180
|
'(180) down' : 180,
|
||||||
|
'random' : ['random']
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
part.setContents(90);
|
part.setContents(90);
|
||||||
|
@ -1095,6 +1096,14 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case '%trg': // target selection
|
||||||
|
part = new InputSlotMorph(
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
'targetsMenu',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
break;
|
||||||
case '%cln': // clones
|
case '%cln': // clones
|
||||||
part = new InputSlotMorph(
|
part = new InputSlotMorph(
|
||||||
null,
|
null,
|
||||||
|
@ -2095,6 +2104,7 @@ SyntaxElementMorph.prototype.endLayout = function () {
|
||||||
%spr - chameleon colored rectangular drop-down for object-names
|
%spr - chameleon colored rectangular drop-down for object-names
|
||||||
%col - chameleon colored rectangular drop-down for collidables
|
%col - chameleon colored rectangular drop-down for collidables
|
||||||
%dst - chameleon colored rectangular drop-down for distances
|
%dst - chameleon colored rectangular drop-down for distances
|
||||||
|
%trg - chameleon colored rectangular drop-down for target destinations
|
||||||
%cst - chameleon colored rectangular drop-down for costume-names
|
%cst - chameleon colored rectangular drop-down for costume-names
|
||||||
%eff - chameleon colored rectangular drop-down for graphic effects
|
%eff - chameleon colored rectangular drop-down for graphic effects
|
||||||
%snd - chameleon colored rectangular drop-down for sound names
|
%snd - chameleon colored rectangular drop-down for sound names
|
||||||
|
@ -8432,6 +8442,17 @@ InputSlotMorph.prototype.distancesMenu = function () {
|
||||||
return dict;
|
return dict;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InputSlotMorph.prototype.targetsMenu = function () {
|
||||||
|
var dict = {
|
||||||
|
'random position' : ['random position']
|
||||||
|
},
|
||||||
|
dst = this.distancesMenu();
|
||||||
|
Object.keys(dst).forEach(function (dstName) {
|
||||||
|
dict[dstName] = dst[dstName];
|
||||||
|
});
|
||||||
|
return dict;
|
||||||
|
};
|
||||||
|
|
||||||
InputSlotMorph.prototype.clonablesMenu = function () {
|
InputSlotMorph.prototype.clonablesMenu = function () {
|
||||||
var dict = {},
|
var dict = {},
|
||||||
rcvr = this.parentThatIsA(BlockMorph).scriptTarget(),
|
rcvr = this.parentThatIsA(BlockMorph).scriptTarget(),
|
||||||
|
|
|
@ -4015,3 +4015,7 @@ Translation Updates:
|
||||||
------
|
------
|
||||||
* Objects: fixed #2053
|
* Objects: fixed #2053
|
||||||
* GUI: fixed #2052
|
* GUI: fixed #2052
|
||||||
|
|
||||||
|
180309
|
||||||
|
------
|
||||||
|
* Blocks, Objects, Threads: added "random" option for "go to", "point towards" and "point in direction" primitives
|
||||||
|
|
|
@ -83,7 +83,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
||||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
|
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
|
||||||
AlignmentMorph, Process*/
|
AlignmentMorph, Process*/
|
||||||
|
|
||||||
modules.objects = '2018-March-08';
|
modules.objects = '2018-March-09';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -209,7 +209,7 @@ SpriteMorph.prototype.initBlocks = function () {
|
||||||
only: SpriteMorph,
|
only: SpriteMorph,
|
||||||
type: 'command',
|
type: 'command',
|
||||||
category: 'motion',
|
category: 'motion',
|
||||||
spec: 'point towards %dst'
|
spec: 'point towards %trg'
|
||||||
},
|
},
|
||||||
gotoXY: {
|
gotoXY: {
|
||||||
only: SpriteMorph,
|
only: SpriteMorph,
|
||||||
|
@ -222,7 +222,7 @@ SpriteMorph.prototype.initBlocks = function () {
|
||||||
only: SpriteMorph,
|
only: SpriteMorph,
|
||||||
type: 'command',
|
type: 'command',
|
||||||
category: 'motion',
|
category: 'motion',
|
||||||
spec: 'go to %dst'
|
spec: 'go to %trg'
|
||||||
},
|
},
|
||||||
doGlide: {
|
doGlide: {
|
||||||
only: SpriteMorph,
|
only: SpriteMorph,
|
||||||
|
|
26
threads.js
26
threads.js
|
@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
|
||||||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
||||||
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
||||||
|
|
||||||
modules.threads = '2018-March-05';
|
modules.threads = '2018-March-09';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
@ -3002,6 +3002,17 @@ Process.prototype.getObjectsNamed = function (name, thisObj, stageObj) {
|
||||||
return those;
|
return those;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Process.prototype.setHeading = function (direction) {
|
||||||
|
var thisObj = this.blockReceiver();
|
||||||
|
|
||||||
|
if (thisObj) {
|
||||||
|
if (this.inputOption(direction) === 'random') {
|
||||||
|
direction = this.reportRandom(1, 36000) / 100;
|
||||||
|
}
|
||||||
|
thisObj.setHeading(direction);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Process.prototype.doFaceTowards = function (name) {
|
Process.prototype.doFaceTowards = function (name) {
|
||||||
var thisObj = this.blockReceiver(),
|
var thisObj = this.blockReceiver(),
|
||||||
thatObj;
|
thatObj;
|
||||||
|
@ -3009,6 +3020,8 @@ Process.prototype.doFaceTowards = function (name) {
|
||||||
if (thisObj) {
|
if (thisObj) {
|
||||||
if (this.inputOption(name) === 'mouse-pointer') {
|
if (this.inputOption(name) === 'mouse-pointer') {
|
||||||
thisObj.faceToXY(this.reportMouseX(), this.reportMouseY());
|
thisObj.faceToXY(this.reportMouseX(), this.reportMouseY());
|
||||||
|
} if (this.inputOption(name) === 'random position') {
|
||||||
|
thisObj.setHeading(this.reportRandom(1, 36000) / 100);
|
||||||
} else {
|
} else {
|
||||||
if (name instanceof List) {
|
if (name instanceof List) {
|
||||||
thisObj.faceToXY(
|
thisObj.faceToXY(
|
||||||
|
@ -3030,11 +3043,20 @@ Process.prototype.doFaceTowards = function (name) {
|
||||||
|
|
||||||
Process.prototype.doGotoObject = function (name) {
|
Process.prototype.doGotoObject = function (name) {
|
||||||
var thisObj = this.blockReceiver(),
|
var thisObj = this.blockReceiver(),
|
||||||
thatObj;
|
thatObj,
|
||||||
|
stage;
|
||||||
|
|
||||||
if (thisObj) {
|
if (thisObj) {
|
||||||
if (this.inputOption(name) === 'mouse-pointer') {
|
if (this.inputOption(name) === 'mouse-pointer') {
|
||||||
thisObj.gotoXY(this.reportMouseX(), this.reportMouseY());
|
thisObj.gotoXY(this.reportMouseX(), this.reportMouseY());
|
||||||
|
} else if (this.inputOption(name) === 'random position') {
|
||||||
|
stage = thisObj.parentThatIsA(StageMorph);
|
||||||
|
if (stage) {
|
||||||
|
thisObj.setCenter(new Point(
|
||||||
|
this.reportRandom(stage.left(), stage.right()),
|
||||||
|
this.reportRandom(stage.top(), stage.bottom())
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (name instanceof List) {
|
if (name instanceof List) {
|
||||||
thisObj.gotoXY(
|
thisObj.gotoXY(
|
||||||
|
|
Ładowanie…
Reference in New Issue