User Tag List

Results 1 to 7 of 7

Thread: The ''calculator''

  1. #1
    No Products Registered

    Join Date
    Oct 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The ''calculator''

    Hello.
    Could someone tell me (or give me a website link) some of the calculation methods? The ''calculator'' is what i call the place where you like compare to a global value, the place where you insert that number.
    I just need some more ways to play with it.
    Like how you make random positions inside the play area, and such.

  2. #2
    No Products Registered

    Join Date
    Oct 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, gonna change the ''calculator'' thingy now

  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)
    You can find the method names in the help file (F1), or by exploring the objects (particularly the built-in ones) through the "Retrieve data from an object" button - each extension adds its own possible expressions.

  4. #4
    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)
    Yeah, everything is in the Retrieve Data from an Object.

    Cool formulae:

    Random() takes one value, and generates a random value out of that many possible values. If you use random(4) it will return either 0, 1, 2, or 3 (four total values). To get a random value within a range, you use random(max-min)+min. Max-Min will give you the range, and adding min will make it start from that point. If you want to return a standard dice roll, for example, you would use random(6)+1, since the minimum value you want is 1. This will return 1, 2, 3, 4, 5, or 6. If you want a value between 240 and 370, you would use random(370-240)+240. Since 370-240 = 130, this is the same as random(130)+240. Random(130) would return 0, 1, 2, 3, and so on to 129, which is why the +240 is necessary.

    To find the distance between two points, you usually need some trigonometry. Unless you are dealing with one dimension, specifically. For 1 dimension, it is just Max-Min, which makes perfect sense. If you want distance in two dimensions, however, you often use Pythagorean Theorem, that is, c= sqr(a pow 2 + b pow 2). C is your two dimensional distance, and a and b are your one dimensional distances. Sqr((X2-X1) pow 2 + (Y2-Y1) pow 2) will give you the distance between two points.

    To find the angle between two points is more complicated. Until you memorise the formula. Angle is set up much the same as distance. you are looking at a right triangle, with your horizontal and vertical legs corresponding to the X and Y distances, but instead of looking for the third side you are looking for the angle. Others can explain in more depth why this works, but to find the Angle between Two Points you use ATan2(Y1-Y2,X2-X1).

    To move forward based on an angle, the formula is X = X+speed*cos(angle), Y=Y-speed*sin(angle), where speed is the number of pixels per frame and angle is the angle at which you are moving.

    To approach one point from another I used to combine the above three aforementioned formulae. I would move forward, using the angle between two points as my angle and the distance between two points affecting my speed. This works fine. you would get: X = X+(Sqr((X2-X1) pow 2 + (Y2-Y1) pow 2))/10.0*cos(ATan2(Y1-Y2,X2-X1)), and a similar equation for Y. And then I realised, I'm just building these complex formulae without simplifying them. And so I did. And then I realised I was making it way overcomplicated. I was including Y dimensions in my X and X in my Y. TLR, you don't need to do that. When you move, you move in a line. The formula for a line is X1+t*(X2-X1), where t is the percentage of completion. If t=0, you are at the start of the line. if t=1, you are at the end. t=0.5 is exactly halfway. I figured I could use this formula to my advantage, but I didn't want to have to calculate t every time. Since t=1 is a complete line, the reciprocal of it would give me the fraction of the number of steps I had to take to get there. Working the formula around gives me ((n-1)*X1+X2)/n, where n is how much of the distance it is going to jump each time. If I wanted to always jump a tenth of the remaining distance, I would use X=(9*X1+X2)/10.0. This is not linear movement, however. It starts off fast, and decelerates to the goal, which looks quite nice.

    Protip: MMF2 uses integer division by default. 10/20 will return 0, since it doesn't count decimal places. Specifically, it just truncates them. 0.99 would become 0. In any division statement that you want decimals, just add 0.0 to it. 10/20.0 will give you 0.5. If you have an alterable value that you need to divide by, you can just multiply it by 1.0 or add 0.0 first. Not always the most fun to do, but it works. You can use this 'feature' to make for easy grid systems. X/32*32 will snap it to a grid of 32 pixels. X/32.0*32 won't move it at all. You can use this to your advantage

  5. #5
    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,729
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Good stuff Jacob. This will find a place in the Tech Manual.

    Thanks,

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

  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)
    No problem

  7. #7
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module
    RickyRombo's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere between here and there
    Posts
    3,167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should make that an article, actually. Quite useful indeed!

Similar Threads

  1. Direction calculator
    By dascribe in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 6th December 2011, 06:40 AM
  2. Product Calculator
    By mr_mercury06uk in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 19th April 2010, 09:23 PM
  3. angle calculator
    By rogiedodgie32 in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 7th February 2010, 02:57 AM
  4. how to create a calculator in mmf 2 dev?
    By SergioAndre in forum File Archive
    Replies: 17
    Last Post: 10th June 2009, 12:16 AM
  5. Angle Calculator
    By willy in forum Extension Development
    Replies: 2
    Last Post: 13th August 2006, 06:02 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
  •