Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
-1 broad, vague, generally unclear what the question is. –  Maik Semder Jul 1 '11 at 6:26
1  
You should clarify your question –  FxIII Jul 1 '11 at 7:05
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.