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.

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading ... Loading ...

Google Code Sharing Project Created

Now that I will soon be releasing much more code and files I decided to go ahead and set up a google project page. You can set up a “read-only” repository to download all of my code as it is updated and added to or download the code as I post it in the packages with the demos / tutorials.

Check it out here: http://code.google.com/p/cheezeworld/

If you would like to contribute some code or a helpful tutorial etc I’d be happy to add it to the project!

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Using Objects for initialization

While programming my game’s “Entity Framework” as I like to call it, I had the need for a better way to initialize all of my entities. Here are the properties for just the base “Entity” class:

public class Entity extends EventDispatcher{
 
	public static const DISPOSE:String = "dispose_event";
 
	public var pos:Vector;
	public var rotation:Number;
	public var scale:Number;
	public var radius:Number;
	public var isCollidable:Boolean;
	public var team:String;
 
	public var _id:String;
	public var _type:String;
	public var _pos:Vector;
	public var _oldPos:Vector;
	public var _world:GameWorld;
	public var _timePassed:int;
	//...the rest of the code
}

Also I wanted to have default values as well as the ability to load the defaults from some sort of “Settings” file for pretty much all of these values so normally you would have to do your constructor like:

public function Entity(position:Vector, rotation:Number=360, scale:Number=1, radius:Number=1, isCollidable:Boolean=true, team:String="neutral", id:String=null, type:String=null, world:GameWorld=null){
 
	if(pos != null) { pos = position; } else { pos = new Vector(); }
	if(rotation != 360) { rotation = rotation } else { rotation = Settings.EntityRotation; }
	//etc...
 
}

So as you can see that would get pretty messy ESPECIALLY when you decided to extend it since you’d have to put all of those properties in the constructure PLUS any new properties…so you can just imagine the headache there.

Anyways lets just cut to the chase. Here is the wonderful solution I came up with to handle any type of constructor nightmare like that: Read the rest of this entry »

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Lost in Debug Hell : Fix Your Messy Trace Commands!

I’ve done some collab coding work as well as plenty of my own projects and if you have done the same you would probably agree that debugging can be one of the biggest tasks that we as programmers have to face in our projects.

Usually proper debugging consists of many many trace statements until we are able to pinpoint areas that aren’t doing exactly what it is that we want our code to be doing. Well, one problem that I have run along many times within my own code and more so when working with other people’s code is the problem of not being able to find trace statements and / or not knowing where a particular trace statement came from!

Take for example Read the rest of this entry »

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

How to use Flex for your Actionscript only projects

During this tutorial I will explain how to set and get started with using Flex, as well as explain some of the not so obvious at first things that go along with it. Watch the first minute or so for an intro and then you can skip to the different parts depending on what help you need (or just watch the whole thing).

Read the rest of this entry »

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)
Loading ... Loading ...

Animated Bitmap Class. This Will Speed up your games!

It took me a bit longer than I thought, but it is done! I have created a custom “BitmapClip” class for you guys! This class can do it all:

  1. Import MovieClip, Sprite, and even Tile sheets!
  2. Animate each clip at it’s own frame rate.
  3. Control it just like you would a MovieClip.
  4. It even creates pre-rotated frames for you! Now you can have super fast animated clips AND support rotation! WOOT.
  5. You can also support scaling by simply adding the clip to a sprite without losing *much* speed.

If you want to see a demo where I am using the BitmapClip with thousands of clips on screen moving / scaling and rotating then go here: Game Framework Test

You can download the package containing all of the code and demos or simply grab the file off of the repository on my Google project page.

The following are instructions on how to use it (which are included in the download as well):
Read the rest of this entry »

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading ... Loading ...

Simple and Easy to Use Custom Input Manager Class

Sweet! It’s ready to go. I have created a custom Input Manager for you to take advantage of. Check out this quick video tutorial that will walk you through how to use it in your projects or feel free to look it over yourself.

You can download the package containing the demos and the files or just grab it directly from the repository on my Google Project Page.

Read the rest of this entry »

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading ... Loading ...

Breakball

Description:
Control your Break Ball through a series of challenging levels. Can you beat the game?
This is the first game that I completed. If you create any of your own custom levels be sure to post a comment with the level code so others can try it! Read the rest of this entry »

1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 4.14 out of 5)
Loading ... Loading ...

Update: What’s going on and about to happen

Alright, I haven’t written anything here in a while and there is *sort* of  a reason for that. Recently I have been working really hard in developing my game framework, and finishing up some stuff. I have also been reading several books and trying to learn some new skills. Most likely over the next several days / weeks I will be blogging about some game stuff that I have put together. I’ll be putting together some demos and tutorials for other flash developers to learn from what I have done.

Also, a friend and I have recently begun work on building a flash game portal website. We are trying to make it all web 2.0ish, in that it’s going to have lot’s of community features. I say *we* but well, right now it’s more HIM building everything since hes the web genius hehe. I will be doing some more of the flash / promoting side of things.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

First week of fasting results and thoughts

Alright well it is day 7 of fasting and I feel fantastic! I decided that I would do a combination of water and juice fasting so that I could actually extend how long I fast. I read that I will get a pretty good detox on juice too, but that water is just much more aggressive with the detox. I purchased a juicer, and I am hoping it will be a good friend of mine for years to come as I will be doing juice fasts and making healthy foods from here on out. It is very exciting to see how this is making such a strong impact on my life.

Compared to my previous attempt at “abstaining” from something where a friend Paul and I just ate fish / fruit / water for about 20+ days (we broke before 30 days), I can actually say this has been easier, less work on my part. The thing I have noticed from these type of trials though is that it really gives you a lot of perspective on life, and a lot of discipline towards many other things. I believe that in my journey now to find discipline, god has been sending me answers…and this being one of the big ones. It’s actually funny now to think about it. For a long time I was searching for energy and motivation, and I was finally given the answer through me quitting my life as a Cutco salesman and starting into the world of online business….programming, blogging, etc.. Read the rest of this entry »

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...