Published May 12, 2010
Flash , Games
Here’s a little flash game I put together in about three days. Its called focus and basically it’s just a little arcade style game. You play as the little red ship at the bottom of the screen and you shoot the little green ships whizzing all over the place.
Here it is: focus.
How to play:
Arrow keys to move. Space bar to shoot. You can get hit 100 times before the game is over.
The past few days, I’ve been interested in the idea of Boids. This is basically a system that allows unique animation of crowd or herd behaviors on the fly. Each Boid represents a single member of the herd (or crowd, or flock, or school…). The whole system is comprised of three basic function: Separation, Cohesion, and Alignment. Separation keeps the Boids from getting too close to each other. Cohesion makes the Boids move towards the center of their neighboring Boids. Alignment causes the Boids to try and match their velocities with those of their neighboring Boids. Combining these three functions with varying weight for each results in an enormous amount of possible motions.
Check it out here.
So after about a week of tinkering with this I finally got it to work properly. Basically I started with checking for a difference in every pixel’s color value from the previous frame and then comparing that value with a predefined tolerance variable. Unfortunately this is processor intensive and laggy. So my next method uses a difference filter to see when there is a difference in the current frame compared to the previous frame. The result is far more accurate and less processor intensive. This method is a direct implementation of Justin Windle’s motion tracking program.
Check it out at this link. (you will need a webcam installed)