Discuss Scratch

blockpictures
Scratcher
4 posts

How to make the pen down only when in specific x and y positions?

It's in this project → https://scratch.mit.edu/projects/1166885380

Basically the question is in the title.

This is how the project is supposed to work:
The pen is always up unless in specific x and/or y position(s). In this project, it's just the x position. The pen does go down when it's in the specific x positions, but it doesn't work quite right.
purplebunny63
Scratcher
500+ posts

How to make the pen down only when in specific x and y positions?

Ummmm… I don’t see any problem with the project.. it works perfectly
Scratch-Minion
Scratcher
1000+ posts

How to make the pen down only when in specific x and y positions?

This code should fix the problem:

forever
pen up
go to [mouse pointer v]
if <<(x position) = [-1]> or <<(x position) = [0]> or <(x position) = [1]>>> then
pen down
end
end


In your code, the pen would still be down after x = -1 or 0 or 1 when you go to mouse pointer the next time round the loop.
This causes the drawing where you don't want it.
blockpictures
Scratcher
4 posts

How to make the pen down only when in specific x and y positions?

Thanks for the help! It now works the way it's supposed to

Powered by DjangoBB