User Tag List

Results 1 to 8 of 8

Thread: nested loops

  1. #1
    Clicker Fusion 2.5Android Export Module

    Join Date
    Jul 2006
    Location
    Falkirk,Scotland
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    nested loops

    Is it possible to do nested loops like you can in basic.

    i.e in basic

    for y=0 to 5
    for x=0 to 5
    "do something"
    next x
    next y

  2. #2
    No Products Registered

    Join Date
    Jul 2006
    Location
    Umeå, Sweden
    Posts
    1,090
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nested loops

    yes.... it's called fast loops in mmf!

  3. #3
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nested loops

    It takes a bit of getting your head round procedural events in MMF, but fastloops certainly make the process a bit easier. The event list is always read top to bottom before each frame is drawn, with the exception of fastloops which are executed as many times as they need to be before each frame.

    Have a look for them in the Clickwiki, linked on the right.

  4. #4
    Clicker Fusion 2.5Android Export Module

    Join Date
    Jul 2006
    Location
    Falkirk,Scotland
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nested loops

    I know how to use fastloop when you are just using one loop.I was wondering if you could run a loop within a loop.this could be used for filling an array for example.

    e.g loopindex("x"),loopindex("y"),0 could access data at that array position.

    loop "y" would be started first and onloop "y" loop "x" would be started.Would this work?

  5. #5
    No Products Registered

    Join Date
    Aug 2006
    Location
    Westcountry, UK
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nested loops

    aslong as you don't nest a loop in itself then yes you can do this.

    Or you could convert your X,Y to an ID and just run one loop

  6. #6
    Clicker Fusion 2.5Android Export Module

    Join Date
    Jul 2006
    Location
    Falkirk,Scotland
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nested loops

    Could you explain what you mean by giving it an ID.

  7. #7
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2006
    Location
    Near Nantes (Brittany)
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nested loops

    Hello, this is how you should do :

    1-Start loop ("LoopX") number of X in your array

    2-On loop ("LoopX") :
    Start Loop ("LoopY") number of Y in you array

    3-On loop ("LoopY") :
    you put any value in the array at Loopindex("LoopX"),Loopindex("LoopY")

    I didn't check and perhaps I miss something, but it's roughly how you should do.

  8. #8
    No Products Registered

    Join Date
    Aug 2006
    Location
    Westcountry, UK
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nested loops

    Could you explain what you mean by giving it an ID.
    If you are using tile based games then this is very useful. An ID is a unique value of each X,Y

    Here are the conversion equations:

    ID = Y * WIDTH + X

    X = ID mod WIDTH

    Y = floor(ID/WIDTH)

Similar Threads

  1. Nested ForEach loops?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 10th March 2017, 05:05 PM
  2. Nested Foreach loops
    By Pixelthief in forum Fusion 2.5
    Replies: 6
    Last Post: 8th June 2014, 05:52 AM
  3. Nested Loops and cycling properly
    By rubes in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 26th January 2013, 04:48 PM
  4. homing torpedos & nested loops
    By Shabadage in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 25th January 2010, 03:23 PM
  5. Nested loops and get loopindex
    By Shadoku in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 27th September 2007, 04:13 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
  •