giving something back to the Flash community

massive hitTests (with no hitTest :) )

Tags: , , , ,

using bitmapData.getPixel32() instead of hitTest…

With a friend of mine, we were talikng about making a game the way we would have done it when we were younger. It ended up in a nice beer stream and indeed nothing constructive.

It was about a robot arena game, with extra modular shapes and weapons and we would have build amazing robots in a 2D physics world blablabla. That’s when I started thinking about a collision detction method that would handle hundreds of bullets collisions.

As said above, this ‘demo’ is pointless but it might come in handy if you ever wondered how to dodge the hitTest method:

on/off : on / off
obstacles : rebuilds the terrain randomly

here are the source files:

The collisions are marked with a color circle and leave a color splash on the obstacles.
it’s kind of a one-shot, not a revolutionary yet quite fun especially in standalone mode where you can push the amount of particles ( up to 5000 is ok ).

The sources arecommented when need be.

The important part lies in the Tower.as class, that’s where pseudo hitTests are performed. An idea to enhance the thing is to check the pixels inside the drawing loop, it would then check the whole length of the vector instead of the heading pixel.

The map var used in the tower might be any transparent background BitmapData and. We could also set Transparent pixels o ‘destroy’ it.

Tags: , , , ,

© 2009 HIDIHO!. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.