
-----------------------------------
biggmak
Fri Mar 21, 2003 9:25 pm

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.

-----------------------------------
Asok
Fri Mar 21, 2003 9:37 pm


-----------------------------------
You CAN have a loop inside of a loop, just with different exit conditions.

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
Fri Mar 21, 2003 9:39 pm


-----------------------------------
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 :D

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  :wink:

-----------------------------------
biggmak
Fri Mar 21, 2003 10:41 pm


-----------------------------------
thanks, i will prove my stuborn teacher wrong
