4

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?

gyozo kudor
  • 359
  • 3
  • 13
  • 2
    Related, probable dupe: http://gamedev.stackexchange.com/questions/6721/implementing-a-2d-destructible-landscape-like-worms – Tetrad May 02 '11 at 06:18
  • 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. – gyozo kudor May 02 '11 at 07:24
  • Not a dupe, as kudor gyozo wants to use a polygon based destructible environment, instead of an arbitrary bitmap. – AttackingHobo Jul 05 '11 at 16:08
  • 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? – Gyan aka Gary Buyn Jul 05 '11 at 22:56
  • 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: http://gamedev.stackexchange.com/questions/13202/how-do-i-draw-anti-aliased-holes-in-a-bitmap – gyozo kudor Jul 06 '11 at 07:07
  • I didn't want to use polygon based collision detection, I wanted it pixel based, this is the part where I failed and posted this question; I first tried stencil buffer, thinking that the stencil buffer uses the (circle (loaded from a png, transparent background with a white circle on it)) texture on a quad as a mask and not the quad itself as a mask, so with stencil buffer I ended up with a rectangle shaped hole instead of a round one. – gyozo kudor Jul 06 '11 at 07:31

1 Answers1

1

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.

gyozo kudor
  • 359
  • 3
  • 13