I am referring to this fireball game.

The ball will collide with background, which is in polygon form.

I was wondering, how I can match my polygon data structure with the background image. Say, I had requested artist to draw me a polygon background. Then, how I can generate a polygon data structure to describe the polygon background image?

enter image description here

  • \$\begingroup\$ -1 broad, vague, generally unclear what the question is. \$\endgroup\$ Commented Jul 1, 2011 at 6:26
  • 1
    \$\begingroup\$ You should clarify your question \$\endgroup\$
    – FxIII
    Commented Jul 1, 2011 at 7:05

1 Answer 1


Your question may mean two diffrent things, and for both there is some solutions:

  1. You have both the texture and the polygon and know you want to know how to store and draw your polygon. Storing a 2D polygon is a real easy job, you only have to store all the vertices in order in some array. and to apply a texture to your polygon you need equal number of vertices on your texture and the rest is done by the GameEngine. remember points on the texture and on your polygon should have same order.

  2. You have some texture and you want to extract vertices/edges from it. This one is a much harder problem but still it's solvable. First of all I would rather force my artist to give me polygons for the shapes he is drawing as well but maybe that's not possible so here are the steps to generate vetices/edges from a raw image. let's assume you can easily check if a pixel is a part of shape or not. So for the above picture before it's cut we have some picture like this :

    Raw image

    using edge detection algorithms you can get to this final image (all lines have one pixel width):

    enter image description here

    now you can select some black pixels as vertices and then create your polygon using them.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .