Well, I am working on my game after a little break. I have drawn 5 rows and 8 columns of bugs to the screen. however, when I hit the initial bug with a bullet all the bugs vanish when I only want one bug to disappear.
void timer(int val)
{
int TransitionLimit = 5000;
AnimationCount++;
if (AnimationCount >= TransitionLimit * 2)
AnimationCount = 0;
if (AnimationCount < TransitionLimit)
for (float i = -90.0f; i <= 60.0f; i += 20.0f)
{
drawBug(i, 90.0f, 12, 0);
drawBug(i, 70.0f, 12, 0);
drawBug(i, 50.0f, 12, 0);
drawBug(i, 30.0f, 12, 0);
drawBug(i, 10.0f, 12, 0);
}
else
for (float i = -90.0f; i <= 60.0f; i += 20.0f)
{
drawBug(i, 90.0f, 8, 0);
drawBug(i, 70.0f, 8, 0);
drawBug(i, 50.0f, 8, 0);
drawBug(i, 30.0f, 8, 0);
drawBug(i, 10.0f, 8, 0);
}
glutPostRedisplay();
glutTimerFunc(10000, timer, 0);
}
void coll_ship_one()
{
//draw bullet
float x = -10.0f + move_x;
float y = -90.0f + bullet;
float oWidth = 5.0f;
float oHeight = 5.0f;
//draw bug
float xTwo = -10.0f;
float yTwo = 90.0f;
float oTwoWidth = 10.0f;
float oTwoHeight = 10.0f;
if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1)
{
coll = 1;
coll_count++;
// cout << coll << " " << coll_count << endl;
if (coll_count >= 1)
{
coll_count = 1;
}
cout << coll << " " << coll_count << endl;
glutPostRedisplay();
}
}
void renderScene()
{
srand(time(NULL));
glClear(GL_COLOR_BUFFER_BIT);
drawBullet();
coll_ship_one();
go_space();
if (coll == -1)
{
timer(0);
}
if (coll == 1 && coll_count == 1)
{
drawCollision(-10.0f, 90.0f, 9, 0);
coll = 0;
}
if (coll == 0 && coll_count >= 1)
{
// no bug
}
ship();
drawDice();
glFinish();
}