0

I am building a 2d platformer game that might have a good hundred or so rotated sprites (characters, rockets, bullets, etc) that I want to let collide with a wallmask. Currently using Allegro 5, which does not support 1bit bitmaps as would be natural to use for this.

Is it better for me to attempt creating my own bitmap implementation, and do some hack for rotation (like cache rotated sprites), or to use one of https://www.allegro.cc/manual/5/allegro_pixel_format and Allegro's get_pixel()?

And for the collision testing itself, should I use some kind of blit'ing the character masks into the alpha channel of the wallmask to test for a single value or is it better to just

if (wallmask[x][y] && character_mask[x+o_x][y+o_y]) { collide(); }

for all relevant x and y?

Thank you.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
Orpheon
  • 181
  • 2
  • 10
  • Are you sure you want to be using pixel-perfect collisions? They'll be terrible (in terms of performance) for anything above low-res sprites. Oriented bounding boxes are simple to implement and efficient, and do a really good job in approximating most things. – EvilTak Sep 18 '16 at 11:17
  • I don't really see how bounding boxes could be implemented to collide with a wallmask in a way that is more efficient than pixel-perfect, not without decomposing the wallmask into a massive list of rectangles which doesn't look much more efficient and is vastly more complicated to code. – Orpheon Sep 19 '16 at 05:32
  • He is not telling you to use boxes with a wallmask, he is telling you to avoid that approach and just use AABB from the start. Pixel perfect might be good for older consoles and dedicated hardware, but testing pixels on a modern GPU based library like allegro might totally kill your performance. Individual pixel access is maybe the slowest thing a GPU can do. – rlam12 Sep 23 '16 at 20:29

0 Answers0