• Create Account

### #ActualEndurion

Posted 10 December 2012 - 01:26 AM

I think the main problem comes from calling glutSwapBuffers two times.

Do a full redraw every time, with one glClear at the top and one glutSwapBuffers at the end. Only draw a brick, if it is not set to 0. Now when the ball is inside the brick rect (as your check seems to do), the brick is cleared and on the next redraw it is simply not drawn.

In other words, make it so:

// brick/ball collision
if ( ( x >= 3.0f )
&&   ( x <= 5.0f )
&&   ( y >= 3.5f )
&&   ( y <= 4.0f ) )
{
bricks[3][5] = 0;
}

// brick/ball draw code
if ( bricks[3][5] ) != 0 )
{
// draw the brick
}


### #2Endurion

Posted 10 December 2012 - 01:25 AM

I think the main problem comes from calling glutSwapBuffers two times.

Do a full redraw every time, with one glClear at the top and one glutSwapBuffers at the end. Only draw a brick, if it is not set to 0. Now when the ball is inside the brick rect (as your check seems to do), the brick is cleared and on the next redraw it is simply not drawn.

In other words, make it so:

if ( ( x >= 3.0f )
&&   ( x <= 5.0f )
&&   ( y >= 3.5f )
&&   ( y <= 4.0f ) )
{
bricks[3][5] = 0;
}


### #1Endurion

Posted 10 December 2012 - 01:24 AM

I think the main problem comes from calling glutSwapBuffers two times.

Do a full redraw every time, with one glClear at the top and one glutSwapBuffers at the end. Only draw a brick, if it is not set to 0. Now when the ball is inside the brick rect (as your check seems to do), the brick is cleared and on the next redraw it is simply not drawn.

In other words, make it so:

if ( ( x >= 3.0f )
&& ( x <= 5.0f )
&& ( y >= 3.5f )
&& ( y <= 4.0f ) )
{
bricks[3][5] = 0;
}


PARTNERS