When I run the following code the ball bounces just above the paddle (around 10 pixels above the paddle). I haven't messed with the detect-collision function and following are my initPaddle() and code to change direction after hitting paddle
GRect initPaddle(GWindow window)
{
GRect paddle = newGRect(0, 0, PWIDTH, PHEIGHT);
setFilled(paddle, true);
setColor(paddle,"BLUE");
setLocation(paddle,WIDTH/2 - PWIDTH/2,HEIGHT- PHEIGHT - 50);
add(window, paddle);
return paddle ;
}
And the code
else if(collision != NULL)
{
string temp = getType(collision);
//If collision(GObject) hit paddle
if(collision == paddle)
{
velocityY = -velocityY;
}
//If collision hit brick
else if((strcmp(temp,"GRect")==0) && collision != paddle)
{
velocityY = -velocityY;
points++;
bricks--;
sprintf(s, "%i", points);
setLabel(label,s);
removeGWindow(window,collision);
}
Any Help will be appreciated
PS: Here is the complete code http://pastebin.com/JRkYST2g