hi guys, Happy new year to you all.
Im having some difficulties compiling a script and i was wondering if i could get some help?
basically, starting at 0, 170 i have a ball that i want to defend to no more than -175.
Hlaf way down i have a peg and when the ball gets as far as the beg i want the ball to randomly pick whether to go left or right (10steps either way). Everythings ok until i get this far. At first i was getting the sprite to randomly move but not to how i need it.
i need the sprite to hit the peg and either side step left 10steps or right 10steps. After sidestepping the script will continue allow the ball to descend until i add another peg.
Hopefully that makes sense, apologise if it doesn't, im pretty new to scratch however im looking to learn as much as possible so i can pass on to my 13yr.
Look forward to getting some replies
Offline
Nobody? :-(
Offline
heres what my script looks like so far:
http://farm9.staticflickr.com/8493/8357088279_93a9d8ae7e_c.jpg
Offline
What are those program starts and ends blocks? And it looks like you're actually using a program called Sense, which appears to be based on an old version of Scratch. In any case, i would recommend adding this:
if <(pick random (1) to (2)) = (1)> change x by (10) else change x by (-10) end
Offline
Hi there, thankyou for your help. Yes, im using sense for some coursework and the start/End blocks are just for good practice..So ive been told, as the script advances it makes it clearer to see where things start and stop...Hopefully will gain a few brownie points none the less.
I will give your script a try. i sat for so many hours yesterday and had so many different variations. One pretty similar to your but just not quite there.
I'll report back sure.
Thanks again
Offline
Right, Im happy with that as it is now throwing the ball either left or right randomly. Thank you.
What i did forget to mention however is that i need to store the results in what way it goes in a variable.
ive created a variable, whichWay but no results go into it.
Offline
What are you doing? Replacing the old code i gave you with this should work:
set [which way v] to (pick random (1) to (2)) if <(which way) = (1)> change x by (10) else change x by (-10) end
Offline
right, i think that is it sorted now, when it goes left it shows 2 and right 1
Thankyou for your time
Offline
You're welcome. Good luck with your course.
Offline
Thankyou
Thankfully (for me) this will be the only course with programming. Im looking to major in server tech and networking however i still ned to understand should i want to do SQL. I haven't even looked at what that involves however.
Thanks again
Offline
I like SQL. I'm not quite sure how to do loops, conditionals, and related stuff with it, but i can select and update just fine, which is mostly what i need it for.
I think you also need some programming in order to do server tech and networking, but not much. I do server programming in PHP, for one thing. I use other languages for other purposes as well.
Offline
Yea it funny really. Ive already done my cisco ccent and will be doing my ccna after server studies and in regards to the lingo, i have no problem. I think at times i tell myself programming is hard than it probably is, not that its easy but i just dont have a passion for engineering in that respect.
nice to talk to you, are you on twitter at all? I like to use twitter for tech updates etc
Offline
Sicmonster, are you there my friend. Need one last bit of help and thats my 5 days of constant work finished....Until the next assignment in 4 or 5 weeks. lol
Offline
Yes? BTW, you can post it to anyone, in case the person who answered originally is not available.
Last edited by scimonster (2013-01-09 15:41:46)
Offline
I now need to modify the program so that i moves in random directions when faced against many red peg in the shape of a triangle. All in all i need to repeat approx 100 times, each time stamping the ball as it gets to the bottom but im having problems getting the ball to move further than the 1st peg
Offline
i know mate, i did just that but i wanted yourself as you were kind enough to help me the last night
Offline
What's your new script?
Also, it might be better to move steps instead of gliding - maybe that way you won't have to code for every single possibility.
Offline
scimonster wrote:
What's your new script?
Also, it might be better to move steps instead of gliding - maybe that way you won't have to code for every single possibility.
I'll post it for you know, I was thinking that about the gliding and thats where i got confused. the code wud be endless but what way do i incorporate the step blocks? i think by doing what it the way i have its not really hitting the peg, more stopping at the co-ordinates which isnt right :-(
script to follow:
Offline
Here is what i have so far but like you say, the glide code is probably now wrong but i can amend previous questions i think:
http://farm9.staticflickr.com/8464/8364756425_272a42b2ec_b.jpg
Offline
So i would suggest something like this: Start out at the top square, using go to x/y. Decide whether to go right or left. Then, you can glide either to (x+10)@(y-20) for right, and (x-10)@(y-20) for left. I'm not sure if it's an even 10px; you can try a few numbers to see how far apart they are.
I didn't realize that those blocks i commented on were comments - i thought the comment block was always gray.
Offline
Just thinking there, if i dont use glide, how can it give the falling sensation? If i use the move block, it just puts it straight there rather than crawling down the screen.
Does that make sense?
Offline
Lorddalron wrote:
Just thinking there, if i dont use glide, how can it give the falling sensation? If i use the move block, it just puts it straight there rather than crawling down the screen.
Does that make sense?
Yes, it does, though actually you could use a go to block to make a smooth movement, though most people prefer to use a separate script like this:
when gf clicked forever change y by (-1)//change to desired speed
when gf clicked forever go to x: (x position) y: ((y position) - (1))//Change 1 to desired speed.
Offline
Hi Erne, thanks for welcoming wishes.
Im afraid youve got me stumped now..ive tied your code but the ball isnt going down the screen. Im ready for the rope. This is probably a 10min job that has had me going mad for two days
Offline
Lorddalron wrote:
Hi Erne, thanks for welcoming wishes.
Im afraid youve got me stumped now..ive tied your code but the ball isnt going down the screen. Im ready for the rope. This is probably a 10min job that has had me going mad for two days
Hmmm... I'm wondering why this isn't working, though don't touch the rope; we'll get this up and running soon. So, could you provide an image of the code you're using? I think that the problem might be there because of how you put in my suggestion.
Oh, and your welcome.
Offline
Put it like this, i need to have this done at some stage tonight :-) Otherwise im going to register on a hanging rope website cos i dont think i could make one of those either. lol. You know, than fancy one like in the movies..lol Only joking
Take a look at this for now, the same image i posted to monster.
What i need to happen is for the ball to go from the top (0, 170) to the bottom (-175 at least).
on its way, the ball comes to the red pegs. As it comes to the peg, the random_pick block is introduced to make the decision of going left and right. i did have this achieved in an earlier stage but now the final part has introduced multiple pegs which i just cant figure out.
To finish off, the test needs to be repeated 120 times for the sake of probability. Each time the ball gets the the bottom, via the random route, it gets stamped at the bottom and the balls pile up
Does that make sense?
I really appreciate your time by the way...
Offline