Original Post
What is the best way of implementing collision detection in openGL orthographic view if i use quads for everything... tiles... player... everything...
Every object is drawn with a class, an object class.
Now if I handle objects by having a structure in my main program loop
With which for every Object i declare... I also declare an object structure so i can modify position, rotation, single sprite, status (for keypress), cloacking and direction.
So with this method how can I make it so that I know when my objects collide... much like a
CheckForCollision() Function ... but that would have to be done for EVERY object... its quite hard for me... im new at this
Object::Object()
{
spAnimation = false;
spriteCounter = 0;
}
BOOL Object::draw_object(GLfloat posx, GLfloat posy, GLfloat direction, int textureID)
{
glLoadIdentity();
glPushMatrix();
glTranslatef(posx + 0.5, posy+ 0.5, 0.0f);
glRotatef(direction, 0.0f, 0.0f, 1.0f);
if(spAnimation == true)
{
glBindTexture(GL_TEXTURE_2D, texture[sprite]);
}
else
{
glBindTexture(GL_TEXTURE_2D, texture[textureID]);
}
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f); glVertex2f( 0.5f, 0.5f);
glTexCoord2f(1.0f, 0.0f); glVertex2f( 0.5f, -0.5f);
glTexCoord2f(0.0f, 0.0f); glVertex2f(-0.5f, -0.5f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(-0.5f, 0.5f);
glEnd();
glPopMatrix();
return TRUE;
}
void Object::Animate(char *pArray, int rate, int spSize)
{
if(spTimer.GetElapsedTime() > rate)
{
if(spriteCounter == spSize)
{
spriteCounter %= spSize;
}
spTimer.Initialize();
sprite = pArray[spriteCounter];
spriteCounter++;
}
}
struct sObject
{
float x;
float y;
float rotation;
int sprite;
bool status;
bool cloack;
int direction;
} ;