User Tag List

Results 1 to 10 of 10

Thread: Fast loop multiple enemy engine?

  1. #1
    No Products Registered

    Join Date
    Dec 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fast loop multiple enemy engine?

    Me again, back with another inevitable problem

    The custom movement engine I have been working on works great if there is only 1 instance of it. However when there is more than 1 it does not work correctly.

    This boggles my mind because pretty much every event has some kind of alterable value to go with it which should automatically make them move differently. Oh and I'm currently just testing 2 objects.

    When 1 instance hits a wall it makes the other slow down and when 1 instance is in the ground and the other is in the air the one in the air descends very slow.

    The only thing I can think of that is causing this is when the loop needs to stop. Instead of stopping the loop for only one object(which doesn't make sense) it just stops the horiz or gravity loop.

    This I imagine is like trying to make a multiple instance enemy engine using groups that you turn on and off. There is no way to turn off a group and have it affect only one instance. Am I right?

    Anyway I was wondering if it is still possible to use fast loops for enemies. I spent a week working on this custom movement engine so it would be able to work in multiple instances and now it's all falling to crap.

    As always I have an example and it's fully commented

    http://mfa.aquadasoft.com/upload/1271654122-Floop_Enemy_test_mdsx_Clickteam_forum.mfa

  2. #2
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Århus
    Posts
    3,456
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Fast loop multiple enemy engine?

    I made a little example here for you that might be of help:
    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=185565

  3. #3
    No Products Registered

    Join Date
    Dec 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    While I have looked at the example I'm not quite sure I understand how it works. I even did a test and removed the condition "ID of actives = ID index "move" and it responded the same. Can you explain it more and/or can anyone else elaborate and dumb it down for me?

    Please help I'm kinda screwed if I don't figure this out

  4. #4
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    The basic concept you need to grasp is that MMF does not check your conditions against every copy of an object, except in certain cases. With what you are trying to do, you will need to force MMF to check your conditions against every copy.

    The use of a variable to hold an ID number is the most straightforward and common way. You are basically using the "spread value" action to assign a unique number (spread value of 0 starts the numbering at 0) to each copy's ID variable. Then you run a fastloop as many times as you have copies of the object (because you need to compare your condition against every copy). You use the condition "ID(object)=LoopIndex("LoopName")" to force your condition check every loop to a unique copy.

    There are actually a lot of places on this site and on the Daily Click where you can get a much more in depth explanation of all of this. But realize you are entering into a much more advanced area of MMF. Good Luck.

    Mobichan

  5. #5
    No Products Registered

    Join Date
    Dec 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    Are you saying all I have to do is have a separate loop that counts the objects with another loop and then have that match up with the spread value and then just use that as a condition in order to differentiate between the instances of the objects?

    Anyway after looking at this example

    - Always
    --- Start Loop 'My Loop' 'nObjects(Enemy)' times

    That literally means start a loop for every Enemy.
    Then, in the loop conditions, do this:

    - On Loop 'My Loop'
    + ID of Enemy = Loopindex(My Loop)
    --- Do whatever actions you had in mind


    I sort of get it but what I'm having trouble with is the fact that I have to use fast loops for the movement and I presume you can't use 2 fastloops in one event. So I am not exactly sure how to go about this.

    Heres what I actually understand so far. I hope this helps others help me.



    Oh and Mobichan can you link to the places on this site that go into more detail about this? I've tried looking through Daily Click but I'm not really sure what keyword I should be searching. It was luck that I even found that example I have above.

  6. #6
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    Well, you've gotten that far, I have faith in you
    On your 'Do whatever actions' is when you start your other loops that you would for each individual character. Just make sure to add on ID of Enemy = Loopindex

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    It sounds like you have the right idea. You are using the ID comparison to pair up the Loop Index and the enemy ID so that MMF selects only that specific object. Once you have that selection acheived, you can apply any conditions and actions you want. You can also start other fastloops from that point (within the first fastloop) but that is getting into advanced MMF coding. In regards to movement, you can do something like:

    +On Loop "MyLoop"
    +"ID" = LoopIndex("MyLoop")
    +Enemy Flag 1 is ON
    -Set Enemy X Position to (Current X Position = 1)

    Using Flags or variables or strings you can have each enemy carry around its own instructions that make it move independant of the other enemies. In this case, whenever Flag 1 is ON, the enemy will move to the right by one pixel every loop.

    If you want to understand more about this stuff, do a search for "fastloops" or "object selection." You also should read the fastloop tutorial in the Tutorials section (to the right).

    Mobichan

  8. #8
    No Products Registered

    Join Date
    Dec 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    Here's my latest attempt.




    Also I read something interesting in another thread.

    Everything was working well until I felt the need for using multiple instances of the same "Rock" object.

    After much research I found out about the spread value function to give each instance of my Rock a specific ID and then running a fast loop named "IDloop" and comparing the ID of my rock object with the index of "IDloop".

    My problem is that I need to have a loop run within another loop and I don't understand how TGF 2 manages that... I can't get my gravity loop to run individualy for each rock.

    Any tips? Thanks.


    Just start the 2nd loop from the "on loop" of the first. Like this:

    Always
    -Start loop "outer loop"
    On loop "outer loop"
    -start loop "inner loop"
    On loop "inner loop"
    -do stuff with both inner and outer loop indexes

    Don't put two "on loop" conditions on the same event.


    I strongly believed that was going to work but it didn't.

    I tried it like this

    Always
    +Start loop "count" NObjects times

    On loop "count"
    +Start loop "Horiz" ABS(Horiz) times

    Then

    All my other loops with "Horiz" should work as individuals? Apparently not.



    At this rate I beg someone to take my example I posted and just get Horizontals collision code working. Just so I can see the way that "works"

  9. #9
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    Here ya go:
    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=185928&#Post185 928

    You need to use nested loops to accomplish what you are trying to do. I commented it, so hopefully you can understand what I did.

    Mobichan

  10. #10
    No Products Registered

    Join Date
    Dec 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Fast loop multiple enemy engine?

    Awesome man thank you so much! I was getting pretty close too

Similar Threads

  1. Instead of Fast Loop
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 17
    Last Post: 5th November 2010, 04:08 AM
  2. fast loop and loop index
    By willow in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 18th May 2010, 01:43 AM
  3. Fast loop within fast loop - platform game
    By Safe in forum The Games Factory 2 - Technical Support
    Replies: 1
    Last Post: 16th April 2010, 07:38 AM
  4. fast loop
    By jhonson in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 17th November 2008, 09:18 PM
  5. Fast Loop - How do you use it?!
    By jonjoyceuk in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 31st May 2008, 02:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •