viewof OvercomeObstacle = checkbox({
label:
"<b>OvercomeObstacle.</b> This bthread blocks a specific motion when it signals the obstacle.",
value: function* () {
while (true) {
if (touches(this.x, this.y)) {
yield { wait: "frame", block: "moveDown" };
} else if (this.y < 0 && !touches(this.x, this.y)) {
yield { wait: "frame", block: "moveUp" };
} else {
yield { wait: "frame", block: ["moveDown", "moveUp"] };
}
}
},
defaultValue: true
})