Fast Loops - What, When And Why?
Hi everyone,
I have read the section in the MMF2 manual about fast loops, searched for them on the forum and watched the video tutorial about them. I understand how they work but I think I am misunderstanding something about them. I thought that by asking a few questions I might get to grips with them more readily, please see below:
What kind of actions should fast loops be used for? Is there any reason not to put all of the gameplay events in an arcade shooter inside a series of fast loops?
When, if ever, might fast loops be a bad idea?
Why should I use fast loops instead of increasing the frame rate of the application?
Cheers!
Re: Fast Loops - What, When And Why?
Fastloops happen before the frame refreshes, or between frames as I like to think. They are good for intanstly teleporting against a wall, eg for sensors, that would otherwise take several frames to move without going through very very thin walls. There are a couple very good applications of fastloops here:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=175413#Post1754 13
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=171004#Post1710 04
;)
They are also good for instantly loading a list, or just doing something repetitive with a variable between frames. I'm sure lots of other users will contribute to this thread about what fastloops can also be handy and dandy for. :)
Re: Fast Loops - What, When And Why?
They are invaluable for object selection if you need to apply changes to one particular copy of an object. There are ways of doing object selection without them, but many times you may want to select an object and do something relative to its position (for instance, create a bullet when an enemy animation reaches a certain frame).
Nested fastloops are great for running through all enemies every frame and then applying changes to certain enemies that meet certain conditions. The list goes on and on... :)
But keep in mind that some of these uses for fastloops are not that easy to grasp if you are new to MMF.
My 2 cents,
Mobichan
Re: Fast Loops - What, When And Why?
Have you checked out pixeltheif's article http://create-games.com/article.asp?id=1937
It's very informative
Re: Fast Loops - What, When And Why?
When you're just doing basic stuff, you'll do better without them. But when you get to an advanced level, you will depend on them like hell.
Re: Fast Loops - What, When And Why?
Thanks, these links were exactly the kind of thing I was looking for! I have to say, I'm not really understanding a reason to not put entire games in them but that is due to my inexperience.
Re: Fast Loops - What, When And Why?
It's because fast loops happen between frames, so if you had an infinite fast loop with no commands to stop it, the frame would never redraw and you'd have an invisible game. :p
Re: Fast Loops - What, When And Why?
Quote:
Originally Posted by LB
It's because fast loops happen between frames, so if you had an infinite fast loop with no commands to stop it, the frame would never redraw and you'd have an invisible game. :p
plus a locked up machine :D
Re: Fast Loops - What, When And Why?
IIRC, fast loops are the only way to make a set of objects (e.g. homing missiles, turrets) all choose the closest of another set of objects (e.g. enemies).
They're also the only way to solve the problem LB mentions, with small fast objects (i.e. bullets) going straight through thin walls.
There are other things that are only possible with fastloops too.
They're frequently used for forcing MMF to run code for each duplicate of an object individually, but it's often not necessary, and is just slowing down the game of the person who used them. e.g. the many-many test I mentioned first can be done with only one fast loop, but it's normally implemented with two nested loops. EDIT: Bad example, the one-loop version requires my select object extension. Lets go with mobichan's "create a bullet when an enemy animation reaches a certain frame", which actually doesn't need a fastloop at all...
Re: Fast Loops - What, When And Why?
Small Question: Can you make an infinite fastloop? (So the only way to stop it is the "Stop Loop" action)
Re: Fast Loops - What, When And Why?
You can start a loop for -1 times. It will then go on and on. It *will* eventually stop, but you can easily see it as being nearly infinite.
dmcclure:
All 'false events' (ones that aren't triggered) can be seen as a single fastloop that runs 50 times pr second - after each loop it redraws the screen. So in a way the game already does this in a fastloop-style way, but manual fastloops are your option to do some more complex stuff than what already happens automatically for you :)
Re: Fast Loops - What, When And Why?
@Dynasoft: Sorry, that was a bad example. ^_^' I guess I should have clarified that if you want to fire any kind of bullet spread, fastloops are the way to go. Firing a single bullet doesn't need them. I tend to overuse fastloops because I ALWAYS come to a point in making my games where I need them. So working them into my code structure early often helps me. But I digress...
Mobichan