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!
when gf clicked hide show go to [x:(0) y:(170)] point in direction [(180)] set [whichWay] to <pick random (-90) to (90)> repeat until <y position> = (-175) if <(y position)> > (-175) move (5) steps
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!
when gf clicked hide show go to [x:(0) y:(170)] point in direction [(180)] set [whichWay] to <pick random (-90) to (90)> repeat until <y position> = (-175) if <(y position)> > (-175) move (5) steps if <touching colour> = red point in direction [whichway] move (10) steps point in direction (180) if <y position> < -(90) play note (64) for (0.5) beatsETC
Offline
FreaK001 wrote:
I have attached a copy of my entire script, which does not want to go my way!
Here:
when gf clicked hide show go to x: (0) y: (170) point in direction (180 v) set [whichWay v] to (pick random (-90) to (90)) repeat until <(y position) = (-175)> if <(y position) > [-175]> move (5) steps end endAnd I agree, the scratchblocks syntax is quite prone to errors.
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:
when gf clicked show go to x:(0) y:(175) point in direction (180) repeat until <y position < (-174)> if <(y position) < (-175)> set y to (-175) end if <touching color [red]?> set [WhichWay v] to ((1) + ((pick random (0) to (1)) * (-2))) change x by ((WhichWay) * (10)) play note ((60) + ((WhichWay) * (30))) for (0.5) beats end change y by (-5)Additionally, if you have any additional problems, uploading your project would allow us to actually see and mess with the scripts ourselves. Thanks.
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