Computer Science Canada Random Procedures |
| Author: | Uber Tankz [ Thu Jun 01, 2006 10:20 pm ] | ||
| Post subject: | Random Procedures | ||
How can i make these procedures come out randomly?
|
|||
| Author: | Clayton [ Thu Jun 01, 2006 10:24 pm ] | ||
| Post subject: | |||
make an array of procedures then call one element of the array randomly ex.
something like that will suit ur needs i think |
|||
| Author: | Uber Tankz [ Thu Jun 01, 2006 10:29 pm ] |
| Post subject: | Thanks a lot |
dude thanks, thats all i needed rigth there, thanks a lot [/b] |
|
| Author: | Clayton [ Thu Jun 01, 2006 11:00 pm ] |
| Post subject: | |
no problem its what im here for |
|
| Author: | Delos [ Fri Jun 02, 2006 11:31 am ] | ||||
| Post subject: | Re: Random Procedures | ||||
Uber Tankz wrote:
Notice how all of your procedures are exactly the same, except for a few values. In cases like these, you ought to save yourself some repitition and use parameters. Simple example:
You can achieve the same effect with your procedures. Simply compress them into one, then use Rand.Int() to select some of the necassary parameters. I would also suggest compressing their contents into a record (type). Check out the [Turing Walkthrough] for more info. |
|||||
| Author: | zylum [ Fri Jun 02, 2006 1:27 pm ] |
| Post subject: | |
+1 theyre exactly the same except for the rotation angle.. so you could do proc rotateArrow (angle:int) %blah %blah arrow := Pic.Rotate (arrow, angle, -1, -1) %blah blah end rotateArrow rotateArrow(Rand.Int(0,3)*90) |
|