Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How can I move something to x:-240 OR x:240 (either side of the screen)
- ElectricalTears
-
New Scratcher
2 posts
How can I move something to x:-240 OR x:240 (either side of the screen)
I have an object that upon “dying”, goes to a random Y position, but it needs to go to either x:240 or x:-240 (the sides of the screen).
The Y position is no problem, because I can use the ‘pick random’ block.
For some reason the
Maybe it was changed in a recent version? Bug?
The Y position is no problem, because I can use the ‘pick random’ block.
when I receive [death]
go to x: () y: (pick random (-240) to (240))
For some reason the
<<> or <>>black handles boolean in Scratch and not strings like the block on the discussion board suggests, so I can't even put in variables.
Maybe it was changed in a recent version? Bug?
- Babissimo
-
Scratcher
100+ posts
How can I move something to x:-240 OR x:240 (either side of the screen)
When I receive death (that was just your broadcast) set variable to pick random 1 to 2 if variable = 1 go to 240 if variable = 2 go to -240
- ElectricalTears
-
New Scratcher
2 posts
How can I move something to x:-240 OR x:240 (either side of the screen)
Got it 
Thanks.

Thanks.
when I receive [Death v]
set [edge v] to (pick random (1) to (2))
if <(edge) = [1]> then
go to x: (-240) y: (pick random (-240) to (240))
else
go to x: (240) y: (pick random (-240) to (240))
end
- scubajerry
-
Scratcher
1000+ posts
How can I move something to x:-240 OR x:240 (either side of the screen)
when I receive [Death v]
go to x: (((pick random (0) to (1)) * (480)) - [240]) y: (pick random (-180) to (180))
- ExpertFollower
-
Scratcher
9 posts
How can I move something to x:-240 OR x:240 (either side of the screen)
when I receive [death v]
set y to (pick random (-240) to (240))
set [edge v] to (pick random (1) to (2))
if <(edge) = [1]> then
set x to (-240)
else
set x to (240)
end
I hope that helped!

Last edited by ExpertFollower (June 13, 2014 23:37:17)
- Discussion Forums
- » Help with Scripts
-
» How can I move something to x:-240 OR x:240 (either side of the screen)