Hi,
If you know of a good tutorial on the subject of random, please leave a link to it here.
If you know of any things to help me understand how to accomplish the following goal, please post.
The Goal:
I want a sprite to fly across the screen at random times IF a level is started.
I want it to have three options, flying across the screen high, middle, and low.
I don't want it constantly flying across the screen, but i want the intervals of it showing up to a little random(Sometimes it flies across and again soon, sometimes a longer time period between each flight).
I hope that's descriptive enough,
Regards,
CAA14
Offline
That's quite easy to do, using the "pick random" block and knowing exactly what you want to do. c:
We have three options for altitude: Low, medium and high. So, the "pick random" block must pick between these three options, as numbers.
when I receive [fly v] set [option v] to (pick random [1] to [3]) if <(option) = [1]> //low altitude set x to [-50] end if <(option) = [2]> //medium set x to [0] end if <(option) = [3]> //high set x to [50] endTo make the script wait a random time, it's as simple as using the same "pick random" block as the parameter of a "wait" block, with the values you find appropriate:
when I receive [start level v] forever //or until the level ends broadcast [fly v] wait (pick random [1] to [20]) secs end
Last edited by technoguyx (2013-01-17 20:42:54)
Offline
Hi,
Thanks for responding.
Thank you very much.
I am implementing this code as soon as i finish this post.
regards,
CAA14
Offline
Edit:
I am new to scratch, but do know the core principles of programing.
I needed to know how to use random, and you helped me see how, thanks!
Regards,
CAA14
Offline
Hi,
Works like a charm.
Thanks again, technoguyx!
Regards,
CAA14
Offline
Glad to hear that c: Have you used any other programming language, before Scratch? Just curious
Offline
i am a new scratch , and i want to ask ,how can we make parts of the body of the scratch
Offline
Hi,
To technoguyx:
I am currently learning Java, so kind of.
To olayemi2003:
What exactly do you mean? Please clarify.
Are you asking if you can make several sprites and then piece them together?
Regards,
CAA14
Offline
No,i mean how do we let the part of the body of sprite move like the hand ,leg ,head and other parts of the body
Offline
olayemi2003 wrote:
No,i mean how do we let the part of the body of sprite move like the hand ,leg ,head and other parts of the body
Well if you want to do that, you're either going to need to create multiple costumes, or you'll have to turn the body part in question into a new sprite so that you can manipulate it.
I hope that this answers your question! Also, hello olayemi2003 and welcome to Scratch! I wish you much new found wisdom in the coming days!
Offline
thanks for the answer,
but can you give an example of multiple costumes and where can we get multiple costumes.
thank you again for the answer
Offline
Hi,
olayemi2003,
Costumes are all within a sprite, they are created and edited in the "Costumes" tab, which is located besides the "Scripts" tab which is near the top of the screen.
They are like different poses in one sprite.
I believe, if you wanted to, make several sprites separately and then have them track to each other... I think, don't quote me on that... Like having the "arm" track to the "Body", though I've not tried that yet...
I hope that helped,
Regards,
CAA14
P.S. I'm working on a project right now, but after wards if you'd like i could try to implement that theory about the multiple sprites.
Offline
thank you, i'look first .
Offline