User Tag List

Results 1 to 5 of 5

Thread: Round function ...how to?

  1. #1
    Clicker Multimedia Fusion 2 Developer
    Blue66's Avatar
    Join Date
    Jan 2008
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Round function ...how to?

    Hi guys!

    I'm trying to calculate damage that will be divided between health and shield of the player. This damage always has to be a round integer, because the counters will mess up decimals.

    However, if I use the round(damage/2) value, it still divides odd numbers into decimals.

    Please help me on this one. Also, is there somewhere a help page that shows all different stuff of how to handle integers with all those abs() and rounds() and whatnot?

    Thanks a lot

  2. #2
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,537
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Round function ...how to?

    there are a few equations;

    int(10. = 10
    floor(10. = 10
    ceil(10. = {10 for x = 0, 11 for x > 0}
    round (10. = {10 for X < 5, 11 for X >= 5}

    if the rounding function isn't making your counter a decimal, its probably a different problem, however. Make sure to try "int()", first. But also- when a counter is given a decimal number, it will use that decimal and stay a decimal counter even if you feed it only integers later. So you need to configure it in the level editor to not do decimals. You can probably do that with "number of digits after the decimal set to 0"

    but uh, just make sure that you're not feeding floats into your counter in some other event in your program. As long as everything only gives it integers, it should stay an integer.

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Posts
    1,300
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    Re: Round function ...how to?

    Just to clarify:

    Int() rounds positive numbers down, and rounds negative numbers up.

    Floor() always rounds numbers down.

    Ceil() always rounds numbers up.

    Round() rounds numbers to the nearest whole number (ie. up if the fraction is >=.5 or down if the fraction is <.5)

    Abs() just makes a value positive - a float will remain a float.

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,537
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Round function ...how to?

    oh yeah, negatives, my bad :p

  5. #5
    Clicker Multimedia Fusion 2 Developer
    Blue66's Avatar
    Join Date
    Jan 2008
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Round function ...how to?

    Just a quick thank you
    I had another multiplier in the damage calculation process which changed it into a floating number I guess. Thanks for explaining all this, it is very helpful

Similar Threads

  1. Function Eggtimer problem // Power Function for MMF2 Android?
    By ogrgkyle in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 24th May 2013, 03:17 AM
  2. Wrap round scrolling? (Think Flicky)
    By PlaceboDeath in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 24th September 2009, 06:00 AM
  3. How does MMF2 round floats?
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 13th August 2009, 06:11 PM
  4. creating a round meter fill up
    By GameDesigner in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 1st February 2008, 12:46 AM
  5. Round Value - Question
    By Jellyhead365 in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 5th January 2008, 04:19 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
  •