Archive for June, 2010
Sierpinski Triangle
Jun 22nd
Sierpinski Triangle
The Sierpinski Triangle is a famous fractal named after the mathematician who discovered it.
It is made up of nested triangles that get smaller and smaller. If you were to zoom in, you would see the same image (though it may be translated) and you could zoom forever and never find the end.
So, how do you create the Sierpinski Triangle in AS3?
First you have to know how to do recursion. Recursion is where a function calls itself over and over. This creates an infinite loop.
Because you have an infinte loop, you need a way to stop it. In order to More >
Steering Behaviors: Arrival
Jun 18th
Next in the series on Steering Behaviors is arrival. As always, we will be using the Vehicle.as class. It is based on Craig Reynolds’ article, Steering Behaviors For Autonomous Characters.
The Arrival Behavior. Click to see it.
The arrival behavior is almost exactly like seeking, except it has a little, but useful, twist. When the vehicle is seeking a target and it reaches the target, its velocity is greater than 0 and it continues to move, thus overshooting the target. So the vehicle turns around and does it again. This results in an oscillation More >
Steering Behaviors: Wander
Jun 16th
The next steering behavior is wander. It is the next steering behavior in the series. This will use the same Vehicle.as class. If you haven’t read the previous posts, you should, especially the Seeking Behavior. These behaviors are based on Craig Reynolds’ article, Steering Behaviors For Autonomous Characters.
Wander Behavior
Wandering produces a random path. You could add a random number to the velocity each frame, but that would produce a jittery motion. This method creates a smooth and natural feeling motion. To wander, you change the velocity in small amounts each frame.
A More >
Steering Behaviors: Pursuit and Evade
Jun 14th
Up next is pursuit. Again, we will be using the Vehicle.as class. It’s the next on in the steering behaviors series. It is based on Craig Reynolds’ article, Steering Behaviors For Autonomous Characters.
Pursuit Behavior
Pursuit is the most complicated behavior we’ve done so far. To pursue, there needs to be another moving target which you want to pursue. To pursue, you look at the current vehicle, use its current velocity, and predict where it will be in T. Then you simply seek the predicted point. Now pursuit assumes that the other vehicle is More >
Steering Behavior: Fleeing
Jun 12th
Time for the next steering behavior, fleeing. This will use the same Vehicle.as class and will be built off what we did in the seeking behavior. It is based on Craig Reynolds’ article, Steering Behaviors For Autonomous Characters.
Fleeing Behavior
Fleeing is very similar to seeking. It is actually the inverse of seeking. Instead of going towards the target, fleeing goes away from the target. It works like this:
1. desiredVelocity = target – position
2. desiredVelocity is normalized and multiplied by maxSpeed.
3. desiredVelocity is multiplied by -1 to go away from the target
4. steeringForce More >
Steering Behaviors: Seeking
Jun 11th
Steering behaviors are used to create intelligent movements on a computer. These posts will be an AS3 version of the principles illustrated in Craig Reynolds’ article located at http://www.red3d.com/cwr/steer/gdc99/.
Before we can start using steering behaviors, we need a few classes. First we will be using, yet again, the Vector2D.as class. Steering behaviors rely on vector math, so you should be familiar with it.
If you need more information on vector mathematics, you can look here:
https://users.cs.jmu.edu/bernstdh/web/common/lectures/slides_vector-math-2d.php
http://en.wikipedia.org/wiki/Vector_%28mathematics%29
Next we will need a vehicle class to hold all the vehicle’s properties. The properties each vehicle will More >






