Sujet : Re: logically weird loop
De : profesor.fir (at) *nospam* gmail.com (fir)
Groupes : comp.lang.cDate : 22. Nov 2024, 18:48:07
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <5ffbd36e7c96003b8600afde056c3f06baee5531@i2pn2.org>
References : 1 2 3
User-Agent : Mozilla/5.0 (Windows NT 10.0; WOW64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
Lawrence D'Oliveiro pisze:
On Wed, 20 Nov 2024 17:34:34 +0100, Janis Papanagnou wrote:
[*] A friend of mine just recently implemented the code frame for a
roguelike and followed the suggestion of an event based object-oriented
implementation; it worked well, he told me.
The next step would be to use coroutines so the logic of a longer-running
task, which has to wait for other events at multiple points, can be
written in a single linear stream without having to be fragmented into
multiple callbacks.
i dont know to much on coroutines (what i knew i forgot as even my memory this year is terribly bad) or simule bot from some other
reasoning i know thet "call queue" is veru good thing
possibly it may be better or at least equal in thiat coroutines or
what was in simula
in basic call queue it gioes klike this afai
for(int i=0; i<all; i++)
add_queue foo(i);
foo() are storred in queue so then can be run i pseudo parralel
mode at some point
add_queue stores function adress and argument on stack like queue
here in rogualike it would use this time variable also
DoAction(int i)
{
if(character[i].action_end > current_time) return;
// do nothing until time comes
// time has come do something
character[i],action_end += 300;
add_queue DoAction(i); //put yourself on queue
}
StartUp()
{
for(int i=0; i<all; i++) add_queue DoAction(i);
}
// in some code
run_queue // queue may add soem alelemnts but also executed things are taken out of queue
i guess it should be something like that