i have a ball that moves down the screen. the background has little red blocks. i want to make it so if it comes near a block it deflects 10 steps to the right or left at random. i can get the ball to go inside the block with the touching colour block but i want it to deflect so it doesn't go inside the block
Offline
Apparently I need to make a which way block
Offline
to make it dodge, all you have to do is make it detect when it is above a red object. I do this by making it go down twice as far, checking if it' touching red, and if it is, randomly moving left or right 10 pixels. Then I compensate the "go down twice" by making it go up.
I have no idea what you mean by "which way" block, there is no such thing, except maybe a custom block in scratch2.0 or a hacked block.
Offline
The which way has to be made in variables. I can marked the block by going to variables and centering new variable which way but I don't know how to use it.
Offline
This is what I've been told. There is a pyramid of red pegs on a background. I can get the ball to hit the peg and make a noise. I can get it go randomly go left or right but I don't understand the which way button (I can make it not sure how to use it)
The ball is no longer stopped by the peg, but is instead deflected 10 steps sideways, either left or right with an equal probability, chosen randomly depending on the result of the pick_random[]to[] block, before resuming its movement vertically downwards. Once again, y_position of Ball should not exceed -175.
The result of the pick_random[]to[] block should be stored in a new variable called whichWay which you must create.
Offline
i've nearly done it. i can get the ball to move down the screen and if it goes onto a red peg it will move left or right at random. but i need it so the ball doesn't go into the peg, it deflects it before it has a chance to go inside
Offline
If this question is about a homework assignment for a class - please make sure that asking for help on the Scratch forums doesn't violate any agreements you have with the teaching institution.
Offline