Computer Science Canada Mutiple loops running |
| Author: | caldrium [ Wed Jan 18, 2006 4:05 pm ] |
| Post subject: | Mutiple loops running |
i am making a game for school and i dunno how to make multiple loops run at once, or if you can... i am runnign 2 loops that need to be done right now var fish, fishy, level, size : int var buttons : array char of boolean var maxX, maxY : int := 200 level := 1 procedure fishSpawn loop randint (fish, level, 50) if (fish = 50) then randint (fishy, 50, maxy) randint (size, 10, 30) Draw.FillOval (maxx, fishy, size, size, 2) delay (2000) end if end loop end fishSpawn %fishSpawn loop View.Update Draw.FillOval (maxX, maxY, 20, 20, 5) Input.KeyDown (buttons) if buttons (KEY_UP_ARROW) then maxY := maxY + 2 elsif buttons (KEY_DOWN_ARROW) then maxY := maxY - 2 elsif buttons (KEY_LEFT_ARROW) then maxX := maxX - 2 elsif buttons (KEY_RIGHT_ARROW) then maxX := maxX + 2 end if colorback (100) delay (20) cls end loop i have %'d the fishSpawn cause both cant run at once.. how would i be able to still move AND have the fish spawn at the same time? your help would be greatly appreciated.(btw there circles for now until i make the fishes lol) |
|
| Author: | Albrecd [ Wed Jan 18, 2006 5:15 pm ] |
| Post subject: | |
You could put one of the loops in a (squeemish look away) process (they can be useful if you use them correctly [against popular belief]). All you have to do is declare a process with one of the loops in it and fork it right before the other loop. |
|
| Author: | Cervantes [ Wed Jan 18, 2006 5:31 pm ] | ||
| Post subject: | |||
Albrecd wrote: You could put one of the loops in a (squeemish look away) process (they can be useful if you use them correctly [against popular belief]).
Popular belief is that processes will not be used well by those who are first learning them. Tony's tutorials clearly showed how processes can be calmed. Processes can be good, but for the overwhelming majority of we get about them, they are not the way to go. Questions like this one. caldrium: you don't need your fishSpawn procedure in a separate loop. Put it in the same loop, and things should work fine.
|
|||