I am trying this error for hours, checked many segmentation faults, tried various code but i can not figure out why this is happening.
breakout.c
//Detecting collision
GObject collision = detectCollision(window, ball);
if (collision != NULL)
{
if (strcmp(getType(collision), paddle) == 0)
{
velocityY = -velocityY ;
}
if (strcmp(getType(collision), brick) == 0)
{
velocityY = -velocityY;
removeGWindow(window, brick);
points = points + 1;
bricks = bricks - 1;
updateScoreboard(window,label,points);
}
if (strcmp(getType(collision), label) == 0)
{
}
return 0;
}
update: This way ball does not bounce off bricks.
//Detecting collision
GObject collision = detectCollision(window, ball);
if (collision != NULL)
{
if (strcmp(getType(collision), "GRect") == 0)
{
if (collision == paddle)
{
velocityY = -velocityY;
}
if (collision == brick)
{
velocityY = -velocityY;
removeGWindow(window, brick);
points = points + 1;
bricks = bricks - 1;
}
if (strcmp(getType(collision), label) == 0)
{
}
updateScoreboard(window, label, points);
}
}
valgrind
tell you?