User Tag List

Results 1 to 3 of 3

Thread: Using loops as functions, or other alternatives?

  1. #1
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using loops as functions, or other alternatives?

    I am wondering about a performance issue when it comes to fast loops.

    My idea is that I want to use fast loops as functions (and for other things as well).

    Consider the following. I have a platform game, where when the player box is moved, all collision detectors (5-10 of them) is moved with it. As there are quite a lot of events that move the player, I need to move all these objects separately for each of those events.

    My idea is that I could use a fastloop named "Move detectors" that is run one time each time the player is moved. This means I only have to write the "code" for moving the detectors once. This works sort of a function, but I wonder if it leads to performance issues in any way compared to doing it the other way around.

    Another use I thought of was putting the entire game engine in one loop, and to put one event on the top: "If GameWorld.paused is 0" (the game is not paused), then run the "Game engine" loop once.

    Ideally, I would like something like functions in C++ or other languages, where you can put a group of expressions and statements inside a block, something like this:

    void RunGame()
    { //block starts here

    MovePlayer();
    MoveMonsters();

    }//block ends here

    ...and so on. This would make the code much, much more modular, and it's probably one of the things I have been missing most about MMF2, especially in larger projects

    Please give me advice on whether my idea with fastloops is a viable one (performance wise), or if there any other solutions to avoid the "great wall of text" code that's usually the result when you (or at least I) write more complicated games.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure about performance vs fastloops, but what you're describing sounds a lot like Groups: Just right click as you would to create a new condition and there should be an option to create a new Group. Groups can be named and indent their conditions making it easier to read, you can also open/close them for legibility and they can be nested.

    You just need to disable the Group at the end to use it like the fastloop in your post, eg Always: Disable Group (Game engine)
    Alternatively you could have:
    "If GameWorld.paused is 0" (the game is not paused) then enable Group (Game engine)
    "If GameWorld.paused is 1" (the game is paused) then disable Group (Game engine)

    Hope this helps!

  3. #3
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the reply, and sorry for my late response!

    The advice about groups was really good. I never really used them before, but they are very convenient. Right now I am working on a platform game engine (just worked out those moving platforms!), and this time around I have split the events into many different groups, making it a lot easier to track down bugs and problems.

Similar Threads

  1. Alternatives to Edit box?
    By MJK in forum Android Export Module Version 2.0
    Replies: 1
    Last Post: 21st January 2013, 11:35 AM
  2. Xcode - Alternatives
    By Danny in forum iOS Export Module Version 2.0
    Replies: 51
    Last Post: 1st August 2012, 03:48 AM
  3. Mochibot\alternatives?
    By SoftWarewolf in forum SWF/Flash Export Module Version 2.0
    Replies: 4
    Last Post: 17th February 2011, 06:58 PM
  4. Lua Functions inside loops
    By NG2 in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 15th July 2009, 04:59 AM
  5. little confused abouts loops inside loops!
    By Gibbon in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 30th January 2007, 06:37 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
  •