Computer Science Canada Rand.Int Tutorial (With Boxes) |
Author: | upthescale [ Sun May 14, 2006 2:46 pm ] | ||||||||||||
Post subject: | Rand.Int Tutorial (With Boxes) | ||||||||||||
Ok, i decided to make a ranint tutorial...I looked the the turing walkthourgh and didn't see it so ill makeo ne, but ill take it more advanced...what i mean by advanced is not number randint, but having boxes appear ranomly on the screen First, create the variable
Still with me? hopefully because that shouldn;t be to hard. Now you know when you create a variable you alway have to give it a value in this case we would use a Rant.Int statement. Instead of going
we can use the rand int way. If boxx is = to 200, and boxy = 300, no matter what, when you run the screen it will always in appear in the same spot, at x 200, y 300 What if you want the box to randomly go on the screen? Hmm, not that hard, i will begin the randint statement
That's basically how to use a randint statement..Now if your turing run window is small, then alot of the times the box will not appear because it is set from 1 to 800. So if your run window is 1 -600, then you might not see the box sometimes, fori t goes all the way to 800, so always check to make sure the box will stay in..I do this by going
Notice how the two numbers are the same? this is the same as going
That was wayto check to make sure the box will never go off the screen Here is a little program:
So there's a box that will randomly be placed on the screen..you can make it move by going x+=1 or x-=1. To make this fun, take the randint statement, and put it inside the loop! then the box will constantly go all over the place! I hope this tutorial helped Robbie |
Author: | Cervantes [ Sun May 14, 2006 4:09 pm ] | ||||||||
Post subject: | |||||||||
Arrr...
|
Author: | TheOneTrueGod [ Sun May 14, 2006 4:50 pm ] |
Post subject: | |
You forgot spelling / grammer checks Cervantes. Edited for spelling / grammer |
Author: | Delos [ Sun May 14, 2006 6:16 pm ] |
Post subject: | |
TheOneTrueGod wrote: You forgot spelling / grammer checks Cervantes.
Edited for spelling / grammer Not even worth his while. That was so past abysmal that having spent the time to point out his lexical shortcomings would have been like profusely pounding one's cranium against a concrete-reinforced, elevated enclosure qua obstacle... But not to worry too much. I've heard that in V3, tuts will have to be mod approved before they can be posted. Melikes this idea! |