help with 2 loops teacher says u cant have them at same time
Author |
Message |
biggmak
|
Posted: Fri Mar 21, 2003 9:25 pm Post subject: help with 2 loops teacher says u cant have them at same time |
|
|
I was wondering if you could have two loops runing at the same time, my teacher says that it is not possible, but i think that u guys can eat her. One is for the bad guys to move around by themselves and one for me to control the main character. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Asok
|
Posted: Fri Mar 21, 2003 9:37 pm Post subject: (No subject) |
|
|
You CAN have a loop inside of a loop, just with different exit conditions.
code: | var i,j : int := 0
loop
put "loop1"
loop
i := i + 1
put "loop2"
exit when i > 3
end loop
j := j + 1
exit when j > 5
end loop |
As you can see it is possible to have multiple loops, you just need to manage them closely.
However, Turing reads code sequentially (most of the time) and you cannot actually be reading 2 lines of code at the same time. |
|
|
|
|
|
Tony
|
Posted: Fri Mar 21, 2003 9:39 pm Post subject: (No subject) |
|
|
no kidding... how do you think all those video games are done?
not only can you do that... we got a tutorial on that too
http://www.compsci.ca/bbs/viewtopic.php?t=407 explains procedures, functions and processes (you need last)
ofcourse another way of doing it is embeding both operations in a single loop... but we wanna show off, so use processes |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
biggmak
|
Posted: Fri Mar 21, 2003 10:41 pm Post subject: (No subject) |
|
|
thanks, i will prove my stuborn teacher wrong |
|
|
|
|
|
|
|