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:
jokebookservice1 2018-11-11 01:51:37 +00:00
parent 3050f496b2
commit 306996e54c
No known key found for this signature in database
GPG key ID: A872407E9C478467

View file

@ -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;