In article <Xns99DF2FBA6647Fantontxtgmailcom@[EMAIL PROTECTED]
>,
Anton <anton.txt@[EMAIL PROTECTED]
> wrote:
> Miss Elaine Eos
>
> > Try to eliminate polling in favor of interrupts. If you need to
> > create an animation effect, have a timer do interrupts for that. Do
> > not poll for user input, make the appropriate events trigger
> > interrupts. Architect everything such that it responds appropriately
> > to the interrupts it receives. Do what you can to eliminate all
> > variations of this loop:
> >
> > 10 Is there anything to do?
> > 20 No? go to 10
> Hmmm. But what's the problem with this loop? What about the following
loop:
>
> repeat
> if there_is_smth_to_do then
> do it //perform a tick of the in-game time if needed.
> wait_for_event //doesn't wait if there're already events in queue
> handle_event(s) //if there're any.
> until (quit)
While, technically, at a very low level, wait_for_event contains such a
loop, it is an exception to what I said, as most modern OSs do this with
a form of thread-blocking such that it uses minimal CPU.
Yes, your loop is fine. wait_for_event() is a case of an interrupt, in
what I was saying, above.
> But it seems that each of your objects draws itself directly to the
> screen... So, you don't redraw the whole screen every time?
Btw, in MVC architecture (which I think is a good foundation), you
wouldn't have the model draw itself, that would be the job of the view.
This allows for there to be different views of the same model, something
about which you may not care now, but which makes for a well organized
system, regardless.
> > As miss elaine eos pointed out, don't worry to much about optimizing
> > yet (todays computers are pretty fast) you might want to spend
> > optimization on the graphics.
> It is graphics that's the key of my optimization dilemma: using a
> complex and probably painstaking algorithm to accurately redraw only
> things that need redrawing or refre****ng the whole screen every time.
Are you intentionally avoiding architectures that will do this for you
which were written and evolved over decades by people who are very-very
good at it? If it were me, I'd use one of those (for example: Open-GL)
and call it a day.
--
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which
sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.


|