Pages: 1
Hey all,
I am new to the scratch environment, however kind of getting to know it and just needed a bit of clarity really so I know what I am doing wrong!
I have a ball, which needs to move vertically down the screen (I have done this), the next part of the exercise, a red box is introduced onto the stage. I have to make this ball deflect off the box, either to 10 steps to the left or right (using the PICK RANDOM [] TO []) The y_position of the ball should not exceed -175. I have done this to the best of my ability and am getting frustrated right now.. The result of the PICK RANDOM [] TO [] is to be made into a variable.
Next step; Depending on whichever way the ball is deflected (left or right), a sound is to be played depending on which way the ball goes. I have attached a copy of my entire script, which does not want to go my way!
whenclicked
hideshowgo tox:(0) y:(170)point in direction(180)setwhichWaytopick random-90to90repeat untily position=-175if>y position-175move5steps
Offline
Hey all,
I am new to the scratch environment, however kind of getting to know it and just needed a bit of clarity really so I know what I am doing wrong!
I have a ball, which needs to move vertically down the screen (I have done this), the next part of the exercise, a red box is introduced onto the stage. I have to make this ball deflect off the box, either to 10 steps to the left or right (using the PICK RANDOM [] TO []) The y_position of the ball should not exceed -175. I have done this to the best of my ability and am getting frustrated right now.. The result of the PICK RANDOM [] TO [] is to be made into a variable.
Next step; Depending on whichever way the ball is deflected (left or right), a sound is to be played depending on which way the ball goes. I have attached a copy of my entire script, which does not want to go my way!
ETCwhenclicked
hideshowgo tox:(0) y:(170)point in direction(180)setwhichWaytopick random-90to90repeat untily position=-175if>y position-175move5stepsiftouching colour= redpoint in directionwhichwaymove10stepspoint in direction180ify positionplay note64for0.5beats
Offline
FreaK001 wrote:
I have attached a copy of my entire script, which does not want to go my way!
Here:
And I agree, the scratchblocks syntax is quite prone to errors.whenclicked
hideshowgo to x:0y:170point in direction180 ▼setwhichWay ▼topick random-90to90repeat untily position=-175ify position>-175move5steps
Offline
Oh ok, and I see you're making a new thread
(Yes, being a new scratcher is too restrictive)
Offline
FreaK001 wrote:
Didn't mean to create a new thread, tried to salvage whatever scratchblocks code I had to went back on the browser and hey presto.. a new thread!
Oh. Browsers can be weird.
Offline
What's happening when you run this script?
Offline
The ball falls down the screen, hits the red box and deflects left or right which is required, it also does play a sound (as asked) but on occasion it bounces up and down on the box before it reaches the edge and plays the wrong sound?! It's real confusing because the script does work, but doesn't at other times! The only thing I can put this down to is the Pick random [] to [] block..
Offline
Try this:
Additionally, if you have any additional problems, uploading your project would allow us to actually see and mess with the scripts ourselves. Thanks.whenclicked
showgo to x:0y:175point in direction180repeat untilify position<-175set y to-175iftouching colorred?setWhichWay ▼to1+pick random*0to1-2change x byWhichWay*10play notefor60+WhichWay*300.5beatschange y by-5
Last edited by OverPowered (2013-04-14 20:22:06)
Offline
Hey OverPowered,
Thanks for your suggestion man, I appreciate it! I will try this now and see if it works! If I have any other problems then I shall upload my project!
Thank you very much
Offline
Any luck?
Offline
If this question is about a homework assignment for a class - please make sure that asking for help in the forums doesn't violate any agreements you have with the teaching institution.
Offline
Pages: 1