PDA

View Full Version : Removing remains



405290
12-13-2011, 02:15 PM
Ok so I'm making a game to do with pies and ants and its all going well until I need to delete the remains left behind after killing the ants.
so what I need to do is either remove the remains after a certain time or my idea was have 10 remains on the screen at a time, so I need to delete the oldest remains and replace it with new ones, and I don't have a clue.

I don't really care how it's solved whether I use a timer or my suggestion but Its kind of urgent

I am also having trouble with the blending of the texture. I used the same code for the live ants, the only difference is the ants don't move and it's only drawing white area of the mask, however if another ant dies over the top it draws the texture on the overlaid part.

Appreciate any help :)
405290

ZbuffeR
12-13-2011, 02:41 PM
(not opengl) Store creation time or creation index for each remain.
Then whenever you add a remain after the 10 first, delete the oldest and replace it with the new one. Or store the creation date, and each frame delete all remains older than x. Even better, do both.

For your texture issue, no idea of what is your problem.
Post your blend func, details about your textures (do they have alpha), and ideally too, an image showing the problem.

405290
12-13-2011, 03:49 PM
Here is pretty much all I consider useful code (I am a complete dunce when it come to technical stuff)

http://i.imgur.com/0eURT.png


GL.glDisable(GL.GL_DEPTH_TEST);
GL.glEnable(GL.GL_TEXTURE_2D);

GL.glEnable(GL.GL_BLEND);





GL.glBlendFunc(GL.GL_DST_COLOR, GL.GL_ZERO);
GL.glBindTexture(GL.GL_TEXTURE_2D,m_maskID );


GL.glBegin(GL.GL_QUADS);

GL.glTexCoord2f(0f, 0f);
GL.glVertex2f(pos.X, pos.Y + height);

GL.glTexCoord2f(1f, 0f);
GL.glVertex2f(pos.X, pos.Y);

GL.glTexCoord2f(1f, 1f);
GL.glVertex2f(pos.X + width, pos.Y);

GL.glTexCoord2f(0f, 1f);
GL.glVertex2f(pos.X + width, pos.Y + height);


GL.glEnd();


GL.glBlendFunc(GL.GL_ONE, GL.GL_ONE);
GL.glBindTexture(GL.GL_TEXTURE_2D, m_textureID);

GL.glBegin(GL.GL_QUADS);

GL.glTexCoord2f(0f, 0f);
GL.glVertex2f(pos.X, pos.Y + height);

GL.glTexCoord2f(1f, 0f);
GL.glVertex2f(pos.X, pos.Y);

GL.glTexCoord2f(1f, 1f);
GL.glVertex2f(pos.X + width, pos.Y);

GL.glTexCoord2f(0f, 1f);
GL.glVertex2f(pos.X + width, pos.Y + height);

GL.glEnd();

GL.glEnable(GL.GL_DEPTH_TEST);
GL.glDisable(GL.GL_TEXTURE_2D);

GL.glDisable(GL.GL_BLEND);


GL.glPopMatrix();

405290
12-13-2011, 05:21 PM
Problem solved, not sure how but well it works.