Computer Science Canada two procedures at once |
Author: | teh_1337_1 [ Sun Apr 16, 2006 10:23 pm ] | ||
Post subject: | two procedures at once | ||
i was wondering this after i played a game made in turing. how can you have two procedures go off at once? i have this as an example kinda:
how would i make that so you could make 2 circles or as many circles as the user wants without having to wait for the other ones to end? |
Author: | Tony [ Sun Apr 16, 2006 10:45 pm ] |
Post subject: | |
you need an array for the circles, and each time through the loop you just take a look at what circles are not complete yet, and advance a frame. Check the Turing Walkthrough for flexible arrays, records |
Author: | NikG [ Mon Apr 17, 2006 7:59 am ] |
Post subject: | |
You may need to change your makeCircle proc though. Specifically, I would remove that cls from it (since you already have one in your main loop. Also, I would remove the button click code from the proc and put it in your main loop. Post here (or PM me) if you didn't get what I meant. |
Author: | teh_1337_1 [ Mon Apr 17, 2006 10:02 am ] |
Post subject: | |
im still not exactly sure what you mean, could you show me an example or something? |
Author: | NikG [ Mon Apr 17, 2006 2:26 pm ] | ||
Post subject: | |||
Here's a modified version of your code:
Look at the code carefully, and be warned, you are entering more advanced coding now (mutidimensional arrays, passing variables into procedures by reference...) |
Author: | [Gandalf] [ Mon Apr 17, 2006 5:30 pm ] |
Post subject: | |
NikG, note that multidimensional arrays as used in your example code can be avoided by using records. The record would hold the x and y co-ordinates and the radius of your circle so you would only need to create a one dimensional array of your record. Check out the Turing Walkthrough for the tutorial on them. |