breakout game

Started by
19 comments, last by phil67rpg 11 years, 4 months ago
well now comes the hard part. I am now using the following code to detect ball and brick collision detection. The error I am getting is that the ball quickly disappears on the screen when I run the program. I have done a great deal of research on this topic but I still need some help.

void brick_collision()
{
if(x>3.0f && x<5.0f)
{
brick=3.0f;
bricks[3][5]=false;
}

else if(x>1.0f && x<3.0f)
{
brick=1.0f;
bricks[3][4]=false;
}

else if(x>-1.0f && x<1.0f)
{
brick=-1.0f;
bricks[3][3]=false;
}

else if(x>-3.0f && x<-1.0f)
{
brick=-3.0f;
bricks[3][2]=false;
}

else if(x>-5.0f && x<-3.0f)
{
brick=-5.0f;
bricks[3][1]=false;
}

SPRITE object3;
SPRITE object4;

object3.x=x;
object3.y=y;
object3.width=0.1f;
object3.height=0.1f;

object4.x=brick;
object4.y=3.5f;
object4.width=2.0f;
object4.height=1.0f;

if(Sprite_Collide(&object3,&object4)==1)
{
xstep=-xstep;
ystep=-ystep;
}
}

I will do more research on collision detection.

This topic is closed to new replies.

Advertisement