Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 help with 2 loops teacher says u cant have them at same time
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
biggmak




PostPosted: 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
Sponsor
sponsor
Asok




PostPosted: 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




PostPosted: 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 Very Happy

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 Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
biggmak




PostPosted: Fri Mar 21, 2003 10:41 pm   Post subject: (No subject)

thanks, i will prove my stuborn teacher wrong
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: