Actionscript 3 Math Classes for Game Developers
As I have been teaching myself game programming, one of the harder parts has been the math involved. It can be quite complex depending on what you are trying to do. While building various parts for my game engine I’ve needed several math functions. I’ve read through a couple of game and math books and have also created quite a few extras just based on what I had learned. I have created a pretty good library of useful functions and so after showing a friend of mine and him remarking that it was quite helpful I decided I would go ahead and release the code for everyone else to use!
I currently don’t really have any demos or anything showing how to use the code, however go ahead and take a browse through the functions and there may be some stuff you will use eventually. It’s pretty self explanatory anyways and it is all documented. I will definitely be referring to a lot of the code from these classes in some upcoming posts as well so if you are waiting for a more detailed explanation of when and how to use some of it don’t worry it’s on the way!
You can download everything as a package or just get the classes you need in the repository from my google project page here: http://code.google.com/p/cheezeworld/
As of writing this I currently have:
Vector - Perfect alternative to using the built in “Point” class and has basically ALL of the Vector operations you would need to perform plus a few more.
AABBox - A very lightweight object to simply store “rect” data for whatever purpose.
Matrix2D - Handles any Matrix math needed. Use in conjunction with the Vector class.
Transformations - Some static functions for performing transformations to Vectors easily (such as local to global etc…)
Geometry - A very powerful bunch of static functions for doing a wide range of math such as line intersection tests between rays, segments, polygons, circles, etc etc… This is great for most hit test operations and ray casting + other stuff…just check it out.
Math Utils - This is pretty much just a small number of things that I actually just usually copy directly into the code I am working on or as a private function into a class that needs it but wanted to have a reference to it since they are useful so it’s all bundled up in this class.








Andrew said
am June 3 2008 @ 12:13 pm
thanks.
im still in transition from as2.0
andrews /
http://www.eminentgames.com
oliver_l1 said
am June 6 2008 @ 5:19 am
How cool is that! Now i’m waiting for a more detailed explanation.
Erin said
am June 9 2008 @ 6:00 pm
Thank you.
The Geometry library was just what I was looking for.
Joony said
am July 1 2008 @ 12:01 pm
I think there might be a problem with line 418 of Geometry.as
(localPos.x-radius)(localPos.x-radius)
I’ve not had a chance to really go through and fix it myself, but I thought I’d better point it out.
Other than that, nice work.
Revue de web et le twitter Gobz said
am July 3 2008 @ 5:41 pm
[...] Quelques classes de math en AS3 qui peuvent épargner bien du temps (vecteurs, intersections, etc …) [...]
Drew said
am September 1 2008 @ 1:10 pm
You should probably change the license on these files. By GPLing them, only people who are prepared to GPL their entire flash application (which is to say — commit to releasing all their source to everyone) can use your work. It that’s your intention, that’s totally fine. But I certainly can’t use it if that’s the case, and I imagine lots of other people will have to re-do your work from scratch for similar reasons. It doesn’t seem like that’s your intention, though. It sounds like you just want to save people some work which is totally admirable. Maybe look at the MIT or BSD licenses? They might be more in line with what you have in mind here.
Colby Cheeze said
am September 1 2008 @ 4:29 pm
Thank you Drew…I really should have caught that about the GPL. I’ll switch over to the MIT license.
Drew said
am September 3 2008 @ 4:14 pm
Great, thanks!
Shell said
am March 10 2009 @ 5:35 pm
i have found it veyry useful
thank u very much fo developing and share it
Linux spirit xd