whoareyou @ Tue May 24, 2011 6:19 pm wrote:
The problem is that, to my knowledge, I can only do one thing at a time.
Pretty much (there's concurrency, but it's a complicated topic covered in parts in upper year University courses).
So the typical approach is to switch between two (or more) different tasks really fast. E.g.
code: |
loop
x1 += 1;
Draw.Ball(x1,y1);
x2 += 1;
Draw.Ball(x2,y2);
end loop
|
The code still executes one line at a time. You move one ball, then you move another ball. But since the loop executes fast enough, it seems that both are moving "at the same time". The same approach applies to everything.
Naturally you can't have any blocking calls -- any functions that spend a notable amount of time doing something (this includes sleep and waiting for input). You might have to find (or build) non-blocking alternatives.