4
\$\begingroup\$

Let's say I want to make a really simple artillery game, something like Gorillas. I don't have any experience in games, just some basic understanding of OpenGL. I want to do this for fun and to learn something.

I figured out how to simulate gravity and generate simple terrain and how to do some collision detection. But I have no idea how do they mask out the part of the terrain that is hit with a projectile that leaves a hole in form of a circle.

I tried enabling stencil buffer and put a quad which has a circle texture on it expecting to mask out only the circle part, but it masked out the whole quad -- I mean it was a rectangle shaped hole and not a circle shaped one. Next I thought maybe some blending will do the trick but I didn't figure it out how. Or should I just draw a polygon with many edges to look like a circle and use that instead (with the stencil buffer)? I'm just curious how it is done. Can someone point me in the right direction?

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Related, probable dupe: gamedev.stackexchange.com/questions/6721/… \$\endgroup\$
    – Tetrad
    Commented May 2, 2011 at 6:18
  • \$\begingroup\$ It seems that is the way I want. I should probably use a single large texture for the terrain, I was planning to do it with quads or maybe triangles. \$\endgroup\$ Commented May 2, 2011 at 7:24
  • \$\begingroup\$ Not a dupe, as kudor gyozo wants to use a polygon based destructible environment, instead of an arbitrary bitmap. \$\endgroup\$ Commented Jul 5, 2011 at 16:08
  • \$\begingroup\$ Not sure if you've tried these or if they would work but have you made the polygon transparent and/or used a square texture where the area outside of the circle is transparent? \$\endgroup\$ Commented Jul 5, 2011 at 22:56
  • \$\begingroup\$ I ended up using only one texture and I drew holes in it. Circles with 0 alpha values. My original idea was to separate the mask from the terrain somehow but I'm a total noob to opengl, I don't know what can be and can't be done. Related: gamedev.stackexchange.com/questions/13202/… \$\endgroup\$ Commented Jul 6, 2011 at 7:07

1 Answer 1

1
\$\begingroup\$

I ended up using only one texture and I drew holes in it. Circles with 0 alpha values. My original idea was to separate the mask from the terrain somehow but I'm a total noob to opengl, I don't know what can be and can't be done. I used the information from here: Implementing a 2D destructible landscape (like Worms) and this also helped How do I draw anti-aliased holes in a bitmap.

\$\endgroup\$

You must log in to answer this question.

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