Loop and Stacks
Displaying 1-6 of 6 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Zip

Quick one - do do{}until loops exist in V3 - if not, what's the easiest way to emulate one with an until{} loop?

I'm writing some stack code at the moment to handle 'events' in a real-time kind of way. Basically, rather than checking a whole bunch of different conditionals every game loop, it only checks the next scheduled event in the stack, with the user commands being 'pushed' into the right time position in the stack.
So question numbe two, what's the best way to run some code based on data within one of these stacked events?

Ta,

Zip

Posted on 2004-04-14 22:42:48

Zip

For the first question, the code is:

until (push_time > push_when || event[push_prev].next [lessthan] 0)
{
push_time += event[push_next].when;
push_prev = push_next;
push_next = event[push_next].next;
}

Basically, trying to get the events before (push_prev) and after (push_next) the one we are trying to enter in time sequence (push_time). Current code gives one gap too late, do{}untill would fix this.

Zip

Posted on 2004-04-14 22:56:25

Overkill

basically just change 'until' to 'while'. I think you'd have to make every condition the opposite though...

Try:

while (push_time <= push_when || event[push_prev].next >= 0)
{
push_time += event[push_next].when;
push_prev = push_next;
push_next = event[push_next].next;
}
//...


As far as I know, you can't have 'do{}while()' though.

Posted on 2004-04-15 01:10:20 (last edited on 2004-04-15 01:12:32)

Zip

Ta overkill, having been trying such things and not getting very far - need code before the loop to emulate do{}while, and everthing is rapidly becoming messy.

My fuzzy memory of computing lectures has let me down once again, not a 'stack' at all. What I'm trying to do seems much harder as the pushed element can go anywhere in the list, not just at the top. At the moment the code is working for the first element, but dying when it needs to work out where to put the next one. Bed, then re-think.

Zip

Posted on 2004-04-15 01:36:05

RageCage

wtf is 'until'? I've never seen taht before and certainly not in verge

Posted on 2004-04-15 04:41:11

Troupe

Please edit your post doofus. =D

Posted on 2004-04-15 14:45:30


Displaying 1-6 of 6 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.