mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-28 00:42:44 -05:00
31 lines
845 B
JavaScript
31 lines
845 B
JavaScript
function Scratch3MotionBlocks(runtime) {
|
|
/**
|
|
* The runtime instantiating this block package.
|
|
* @type {Runtime}
|
|
*/
|
|
this.runtime = runtime;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the block primitives implemented by this package.
|
|
* @return {Object.<string, Function>} Mapping of opcode to Function.
|
|
*/
|
|
Scratch3MotionBlocks.prototype.getPrimitives = function() {
|
|
return {
|
|
'motion_gotoxy': this.goToXY,
|
|
'motion_turnright': this.turnRight
|
|
};
|
|
};
|
|
|
|
Scratch3MotionBlocks.prototype.goToXY = function (args, util) {
|
|
util.target.setXY(args.X, args.Y);
|
|
};
|
|
|
|
Scratch3MotionBlocks.prototype.turnRight = function (args, util) {
|
|
if (args.DEGREES !== args.DEGREES) {
|
|
throw "Bad degrees" + args.DEGREES;
|
|
}
|
|
util.target.setDirection(args.DEGREES + util.target.direction);
|
|
};
|
|
|
|
module.exports = Scratch3MotionBlocks;
|