Computer Science Canada loading screen effect |
Author: | whoareyou [ Tue May 24, 2011 6:19 pm ] | ||
Post subject: | loading screen effect | ||
I am trying to collect information about the players' names for my game while trying to have a "loading" effect going across the bottom. The problem is that, to my knowledge, I can only do one thing at a time. So what's happening with the code I have right now is that it's collecting the players' names then doing the loading stuff, but I want it to do the loading effect while I'm getting the names as well. IS that possible? btw, this code isn't finished yet. also, CoverUp is my own method so the loading thing refreshes without clearing the console
|
Author: | Tony [ Tue May 24, 2011 10:43 pm ] | ||
Post subject: | Re: loading screen effect | ||
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.
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. |