mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
feat: Implement "point towards random direction"
We subtract 180 even though the value will be clamped, for clarity. We round so that using the "direction" getter will yield a sensible result. Note that this implements 'point towards random direction', not 'point towards random position' -- they have slightly different behaviours.
This commit is contained in:
parent
3050f496b2
commit
306996e54c
1 changed files with 3 additions and 0 deletions
|
@ -123,6 +123,9 @@ class Scratch3MotionBlocks {
|
|||
if (args.TOWARDS === '_mouse_') {
|
||||
targetX = util.ioQuery('mouse', 'getScratchX');
|
||||
targetY = util.ioQuery('mouse', 'getScratchY');
|
||||
} else if (args.TOWARDS === '_random_') {
|
||||
util.target.setDirection(Math.round(Math.random() * 360) - 180);
|
||||
return;
|
||||
} else {
|
||||
const pointTarget = this.runtime.getSpriteTargetByName(args.TOWARDS);
|
||||
if (!pointTarget) return;
|
||||
|
|
Loading…
Reference in a new issue