I’m writing a basic game.
I want a cursor image with an actual proper outline for collision detection. This is NOT for the mouse– I want little cursors flying around in my game, and I don’t want their bounding box to be a rectangle.
But I’m new to Allegro, and graphical programming. My first idea was to use al_draw_polygon to create a standard cursor look-a-like, but then I realized I have absolutely no idea how to figure out what vertices to feed it. Is there a better way of doing this? Also, what is the standard method for figuring out the coordinates of vertices relative to one another when drawing a polygon? Surely you don’t draw up a graph on paper and calculate it out every time?
The other way I thought of was to load an image of a mouse, but then it’d be rectangular. How do I do this properly?
Note: C++. Figure that was a given, but just in case.
You are asking both how to draw the cursors and how to do collision detection. While related, those are two separate topics.
If you are just starting off, then I would recommend loading 32-bit RGBA PNG files for the cursors. The alpha channel will allow you to draw non-rectangular images. You can also rotate and/or scale the images.
Then you have to worry about collision detection. That really has nothing to do with Allegro. You could use any 2D physics library or just look up formulas on how to check if a line collides with a triangle, etc. It’s easiest to just start by approximating a box around the vital area of the object. You can always build more advanced collision detection later.