New Trig Class 

I’ve added a simple Trig class to RedLib. Provides easy access to common trig calculations for use in AS3.

  • Calculate Distance between two objects.
  • Calculate angle of an object reletive to another. Useful for pointing a MovieClip at another MovieClip.
  • Convert radians to degrees and degrees to radians.
  • Calculate X and Y coordinates given a distance and radius from an Object.
  • More to be added.

Source available in Google code here.

Update: Looks like some dude, Sekati, has a Trig class almost identical to this one. Check it out on google code. The rest of his library is pretty snazzy, too. On a side note, even though you may end up using an existing library, it’s always to good to try it yourself first. You learn more that way.

Math and Flash 

For a while now I’ve been thinking about the barriers preventing me from doing cooler, more awesome visuals and interactions. I’ve come to the conclusion that what is missing is rudimentary trigonomic and geometric principles in my development approaches. So, I am going to do  something about that.

My first step is to conjure up all those things I learned (or should have learned) in high school/early college that I thought I would never use again in my life. I started with these two:

  1. The Pythagorean Theorem
  2. The Law of Cosines

Using these you can easily find distances between two DisplayObjects and the degrees to rotate a DisplayObject to point at another DisplayObejct. Basically you are creating imaginary triangles and using math/code to get the properties of that triangle.

Here is what I came up with. The triangle (movable by keyboard) will always point at the reticle/crosshair (which follows the cursor). Click to shoot. I now have the beginings of a Geometry Wars style game. Next step is collision detection and then fractals.

pointer.jpg