 1. 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.  Reply With Quote

2. Thanks, gonna change the ''calculator'' thingy now   Reply With Quote

3. 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.  Reply With Quote

4. 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. TL R, 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   Reply With Quote

5. Good stuff Jacob. This will find a place in the Tech Manual.

Thanks,

Marv  Reply With Quote

6. No problem   Reply With Quote

7. You should make that an article, actually. Quite useful indeed!  Reply With Quote Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•