Original Post
Greetings, In the game I am working on, a top-down shooter, the bullets are currently not working. When you fire, they don't start in the right spot, nor do they travel at the propper angle. ? Any Ideas? I add 25 and 13 because x and y are the positions of the center of the player. Adding that moves it to the position of the gun. Any ideas why this doesn't work? Thanks.
void CBullet::Draw()
{
glPushMatrix();
DisableTextures();
glColor3ub(255, 255 ,255);
glTranslatef(x, y, 0.0f);
glRotatef(angle, 0.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex2i(x, y);
glVertex2i(x + 3, y);
glEnd();
EnableTextures();
glPopMatrix();
}
//... some stuff that isn't pertanant.
void CEntity::Fire()
{
CBullet *index = NULL;
for(int i = 0; i < MAX_BULLETS; i++)
{
if(!bullets.inUse)
{
index = &bullets;
break;
}
}
// If all the bullets are in use, kill all of them.
if(index == NULL)
{
for(i = 0; i < MAX_BULLETS; i++)
bullets.KillBullet();
index = &bullets[0];
}
index->angle = rot;
index->inUse = true;
index->x = x + 25;
index->y = y + 13;
}