Working with pixelmasks


(TaylorAnderson) #1

So I want to make a racing game, and I want the track to have curves and stuff and not look too grid based, so to accomplish this I would want to make the track’s hitbox a Grid with very small tiles. I could do it in OGMO but at that point its so slow and imprecise its unusable. Is there a way to perhaps read an image file, pixel by pixel, and set a tile depending on the alpha of the pixel? (or is there some other way of doing this?) Is this totally impossible? Will this crush the games framerate? (I don’t need to do any complex collision calculations, I’m just gonna have the player auto-fail if he hits a wall). I just don’t want to have to go to some other engine for this, since I’m in love with Flashpunk :stuck_out_tongue:


(Linck) #2

I have done a simple platformer game using a pixel mask with a huge image that represented the platforms. No fps issue at all. Seems like the most practical solution for you.

Although I don’t see why grid based collision wouldn’t work too, if its just overlap checking and not actually bouncing the vehicle out of the wall or something.


(TaylorAnderson) #3

The issue with grid based is that I want to be able to make curves and stuff in my tracks.

I forgot about flashpunk’s Pixelmask…does that just take an image and create a hitbox out of it? If so then that would be totally what I want


(Mike Evmm) #4

That’s exacty it. It’s usually used for pixel perfect collision.


(TaylorAnderson) #5

Yes, pixel perfect collision is what I need! :stuck_out_tongue:


(TaylorAnderson) #6

Sorry to bring this back up, but I just tried to make a PixelMask for my circular planet and its still square…this didn’t happen when I did it before, is there a reason why it would be happening now?


(JP Mortiboys) #7

Ensure that the background of image you’re using for the PixelMask is 100% transparent, not solid black or white.


(TaylorAnderson) #8

I checked with two different programs, the background was alpha in both.


(TaylorAnderson) #9

lol, ignore me. i was testing the hitbox with another entity with a large hitbox which made me think that it was the pixelmasks’ fault. it wasnt.