User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Advanced techniques in MMF2

  1. #1
    Clicker Multimedia Fusion 2
    SEELE's Avatar
    Join Date
    Jul 2007
    Location
    Terra australis incognito
    Posts
    1,916
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Advanced techniques in MMF2

    [size:14pt][color:#003400] Advanced techniques in Multimedia fusion 2 [/color]
    [/size]

    [color:#002400] Frame rate independency

    In a professional game you cannot always assume your game is going
    to be played on the ideal setup, so it is important to understand and
    separate frame rate from game speed.

    There are several ways to do this; in MMF i find the most effective
    way is using fast loops.

    As the game is played and the frame rate
    inevitably fluctuates, one thing that stays the same is the 'Timer'.

    The 'Timer' or 'Timer count in 1/1000 since start of frame' is
    located in 'The Timer' object and returns in thousandths of a
    second the time since your game has begin (independent of the
    frame rate).

    Knowing the 'Actual' time and the target frame rate it is possible
    to 'force' the game to run at a desired speed.




    Consider a game is running at 10 FPS however on each 'frame tick'
    (or every time a frame is tested and drawn) it runs 5 fast loops,
    effectively 50 fast loops will executed every second.

    Now consider if every 'frame dependent' condition within that
    game is tested each time that fast loop is executed rather then
    each time the frame is redrawn, the game would effectively be
    running at 50fps while still displaying at 10fps.

    A simple way (in mmf) to run a game at a specific speed
    irrespective of frame rate would be.

    {assume ticks is initially 0
    and core speed is the target frame rate}
    Execute a fast loop-
    "Floor((timer-ticks)/(1000.0/Core speed))" times.
    &
    Add Floor((timer-ticks)/(1000.0/Core speed))*
    (1000.0/Core speed) to ticks.

    In this example no matter what the frame rate a fast loop is run
    'core speed' number of times every second, and simply replacing
    events like while key is down with events like on loop and key is
    down you can make your game effectively run the same on any
    setup.




    Using MOD

    Often large sections of code can be replaced simply by correctly
    using the MOD function.

    MOD or 'modular arithmetic' is easily used in MMF by simply
    entering the word MOD between two values, it takes the first
    and wraps it around the second for example '5 MOD 3' = 2

    This is because 5 goes in to 3 once with a remainder of 2 Just
    as '8 MOD 3' is 2.


    MOD can be used for a multitude of application for example
    Changing dimensions...

    1D (x) to 2D (x,y):

    X=X MOD RANGE
    Y=(X - (X MOD RANGE))/range

    This is common practice but is not common knowledge
    For example when you convert minutes in to hours and
    minutes you are actually converting from 1d (m) to 2d (m,h)

    Minutes=minutes MOD 60
    Hours=(minutes-(minutes MOD 60))/60

    A more game oriented implementation might be drawing tiles
    when drawing tiles you commonly draw a row or column (x)
    then draw following rows or columns in effort to cover the
    play field...

    This could be done with

    +on draw
    -Start loop x (width times)

    +on loop x
    -start loop y (height times)

    +on loop y
    -draw at loopindex("x") by loopindex("y")


    However using MOD this can be reduced to

    +on draw
    -Start loop x (width * height times)

    +on loop x
    -draw at loopindex("x")mod width by (loopindex("x")-
    (loopindex("x")mod width))/ width

    [/color]

  2. #2
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,734
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    Thanks Seele, a great article.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  3. #3
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Darkhog's Avatar
    Join Date
    Jan 2009
    Location
    /dev/null
    Posts
    417
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    According to "Frame rate independency" section - in game runtime options (game properties, red-arrow icon, for persons who don't know where it is) under Frame Rate is a nice checkbox "Machine independent speed". I wonder what it is for? :whistle:. So if you check this box the game will be going always at the same speed and frame rate.

  4. #4
    Clicker Multimedia Fusion 2
    SEELE's Avatar
    Join Date
    Jul 2007
    Location
    Terra australis incognito
    Posts
    1,916
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    That is useful to a point, but you cannot force it to run a game at say 100fps if the computer can only display it at 40.


    Also in multilayer; any spike which actually pauses the app will cause loss of sync even with machine independent speed, but with this technique the game will 'catchup' correctly by any amount in 1 frame.

  5. #5
    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: Advanced techniques in MMF2

    Quote Originally Posted by Darkhog
    According to "Frame rate independency" section - in game runtime options (game properties, red-arrow icon, for persons who don't know where it is) under Frame Rate is a nice checkbox "Machine independent speed". I wonder what it is for? :whistle:. So if you check this box the game will be going always at the same speed and frame rate.
    This just gives the code priority over updating the graphics. It might look choppy, but it won't lag.

  6. #6
    Clicker Multimedia Fusion 2
    SEELE's Avatar
    Join Date
    Jul 2007
    Location
    Terra australis incognito
    Posts
    1,916
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    Once the app cannot achieve the desired frame rate sync is completely lost if machine indipendent speed is used or not.

    This example has two frames, the first uses machine indipendent speed and the second uses the above technique.


    http://www.mediafire.com/download.php?u2gj4nyfrhj


    The results are quite! substantial.

    My results are

    (at target frame rate: 20)
    No independent speed: 26% loss
    Independent speed: 0% loss
    Above method: 0% loss

    (at target frame rate: 60)
    No independent speed: 75% loss
    Independent speed: 38% loss
    Above method: 0% loss

    (at target frame rate: 300)
    No independent speed: 96% loss
    Independent speed: 88% loss
    Above method: 0% loss

    (at target frame rate: 10000)
    No independent speed: N/A
    Independent speed: N/A
    Above method: 0% loss

  7. #7
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    Hmm interesting. Im too tire to try to figure it all out right now, but your example demostrates it all. My game is going to be quite resource heavy, so this has been very helpful

  8. #8
    Clicker Fusion 2.5 Developer

    Join Date
    Oct 2006
    Location
    Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    The game speed seems interesting. I don't have MMF2 at hand as I'm at school and your example isn't apparently anymore on mediafire. I suggest you uploaded it in the file archive.

    My current project's game engine seems to be too heavy at the moment (even with HWA) and I would like to try that technique to at least get the game speed correct.

    So practically I'll have to put that same loop for every event that's not red? Did I understand right?

  9. #9
    Clicker Multimedia Fusion 2
    SEELE's Avatar
    Join Date
    Jul 2007
    Location
    Terra australis incognito
    Posts
    1,916
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    Any event which needs to run at a even speed and any event which effects those events.

  10. #10
    No Products Registered

    Join Date
    Jun 2006
    Posts
    1,630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advanced techniques in MMF2

    Excellent article SEELE! Just curious, this technique wouldn't be needed for HWA games, correct?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. 3D techniques in MMF2
    By SEELE in forum Articles
    Replies: 29
    Last Post: 12th September 2013, 01:27 AM
  2. Advanced Equations in MMF2
    By XStar in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 18th June 2012, 01:45 PM
  3. Replies: 0
    Last Post: 4th February 2010, 12:08 AM
  4. Advanced moving platform techniques?
    By N64Mario in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 1st June 2009, 11: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
  •