1 simple wait question

Posted By: DLively

1 simple wait question - 04/28/15 17:30

To the point.

I place my waits after the first curly bracker in a while loop.
There is controversy on this topic and I'd like to know from the developers brain why a wait should be at the end of any while loop (be it in an action or function)

thank you laugh
Posted By: Quad

Re: 1 simple wait question - 04/28/15 17:36

God damn it.

From the other thread:
Originally Posted By: Quad
where you put your "wait" actually depends on what you are doing.


Right place to put wait depends on what you are doing and how you are doing it. You could be putting it in the middle of the loop and doing the right thing.
Posted By: DLively

Re: 1 simple wait question - 04/28/15 17:39

why is it wrong to put it at the top then????
Posted By: Quad

Re: 1 simple wait question - 04/28/15 18:33

it is not.
Posted By: 3run

Re: 1 simple wait question - 04/28/15 18:40

All hail to the winner! grin Dingdingdingding

Edit: Ok, sorry. I don't really want to act like a jackass. I probably was wrong, so sorry.
Posted By: DLively

Re: 1 simple wait question - 04/28/15 18:54

Ironically, wrong was not the correct word.

Originally Posted By: 3run
Placing 'wait' in most of your code/situation (which I've been noticing for a quiet a while) at the beginning of the loop is incorrect


Originally Posted By: DLively
why is it wrong to put it at the top then????


Originally Posted By: Quad
it is not.


Originally Posted By: 3run
All hail to the winner! grin Dingdingdingding



I just don't understand Why 3runs complaining that my wait is at the top of my while loop..

@3run: why did you make a big deal out of it -- You tell me its wrong but don't tell me why? Everyone else says you're wrong...

laugh
Posted By: 3run

Re: 1 simple wait question - 04/28/15 18:57

Originally Posted By: DLively
You tell me its wrong but don't tell me why? Everyone else says you're wrong... laugh
I can only quote something from your previous thread tongue
Originally Posted By: DLively
(even if they may be inccorect [thats learning baby])


Cheers!
Posted By: Anonymous

Re: 1 simple wait question - 04/28/15 19:01

This is a non-point. You starting with a wait(1) COULD cause issue. You don't care or want a list of the issue. Do what ever you feel like if it works. Right or wrong, simple or elegant. This is such a non-point. It should have been dropped by now, not posted here.
Posted By: DLively

Re: 1 simple wait question - 04/28/15 19:11

Originally Posted By: 3run
Originally Posted By: DLively
You tell me its wrong but don't tell me why? Everyone else says you're wrong... laugh
I can only quote something from your previous thread tongue
Originally Posted By: DLively
(even if they may be inccorect [thats learning baby])


Cheers!


Fair enough. Im glad we are back on the same page as before all this shit.. ( I hope we can both be mature about this laugh )

@Malice: there comes a point in development were everything means something -- Especially If it will cause an issue later on (Big enough that I need to worry about) I'd like to be aware of it now, and not have any surprises -- even as simple as a wait. laugh

I finished one game using the latter method with no bad results, so that's why I'm curious about it..
I leave the ultimate answer to this question in the capable hands of the developers grin



#WowGladThatsOver.

Cheers.
Posted By: FBL

Re: 1 simple wait question - 04/28/15 20:47

The point why you USUALLY don't put a wait(1) on top is, that normally you want to have the very first run of the loop completed immediately (e.g. directly after entity creation) so any changes you do affect (the entity) direectly.

If you put a wait(1) on top of the loop, you will have one frame delay on first run, which can cause a short "jitter" when modifying position, scale, alpha of the entity in the loop. As long as the loop has not run at least once, you'll see the old/default values, which may be entirely different.

That's all to it.
When not doing entity stuff, wait(1) on top might be just what you want. There isn't really a right or wrong.
Posted By: WretchedSid

Re: 1 simple wait question - 04/28/15 20:51

Wait is an implicit return from your function right then and there, so if for example the callee expects to see the side effects from its call, you need to defer the wait until after the side effects took place. Put in a different way that could mean that you have an action that moves an entity, but that will only ever happen after the first frame the action is called when putting the wait first.

Another example, just to show that waits don't necessarily are right at either end of the while, you might have a loop that in the first frame takes some data and pre-processes it, then comes a wait, and then it acts upon the data, followed by another wait and then it all starts again. So each frame it either pre-processes data or it acts based on the data.

Simply put, where it rights really does depend on what you do.
Edit: Looks like firo was faster
Posted By: 3run

Re: 1 simple wait question - 04/28/15 21:03

To make things clear, what I meant was something like this:
Code:
void hero(){
   while(my){ wait(1);
      my.skill1 = 10 * (key_w - key_s) * time_step;
      my.skill2 = 10 * (key_a - key_d) * time_step;
      my.skill3 = 0;
      c_move(my, nullvector, my.skill1, GLIDE);
   }
}

I still don't think that this is CORRECT way to write function to move entity. I wanted to aware DLively from teaching newbies to code things like this and etc.
Originally Posted By: 3run
Originally Posted By: DLively
I put my wait at the beginning for organizational purposes. It doesn't make any (real) difference in the way it runs.
Sure it does not, but it's not really a good way to organize your code, and I hope that you don't use such approach in your tutorials.

Cheers!
Cause from my own experience (and I do really have some! even if my knowledge base sucks) I know that this will lead to some troubles. I wouldn't recommend anyone to do so unless they are aware of what are they exactly doing and what are they teaching other to do! Sorry DLively, but you are still just learning (same as I do f.e.), so I don't really think that it is really safe for you or other newbies to play around with 'wait' unless you really want to use it for a purpose (placing it somewhere to get specific results!). But yeah, who am I to tell anything like this grin

Anyway, this discussion is really over for me, I don't want to bring this back. Just wanted to make my point clear!

Best regards
Posted By: DLively

Re: 1 simple wait question - 04/28/15 21:21

@SID @ FIRO: Okay grin Things are starting make more sense over here now.

Thank you everyone for all your help with this issue. laugh
I didn't want to be creating wrong code for myself, and (On top of that) share it too shocked

Cheers!
#AwesomeCommunity
© 2024 lite-C Forums