need help

Started by
0 comments, last by Gaiiden 19 years, 5 months ago
this wont work

int pong::collision()
{
    //collison decetion
    //if they hit each other
    if(bypos == ypos-52 && bxpos == xpos-52)
    {
        ypos = -ypos;
        bypos = -bypos;
    }    
    //from the side
    if(bxpos == xpos-52)
    {
        xpos = -xpos;
        bxpos = -bxpos;
    } 
        if(bypos == ypos+52)
    {
        ypos = -ypos;
        bypos = -bypos;
    }    
    //from the side
    if(bxpos == xpos+52)
    {
        xpos = -xpos;
        bxpos = -bxpos;
    }
}    


it goes straight through the other one. when I have this done I can make a game of pong, my 1-year dream ;)
there are 10 types of people in this world, those who can do bianary and those who cant.
Advertisement
My first suggestion would be to not use the == operator. The reason being is that it's too exact. There may be a chance that you won't catch the values exactly when they equal each other. The better approach is to use >= or <=, because then if you're off by a pixel or two, the condition is still evaluated. And no one will notice if it's off by that small an amount.

Drew Sikora
Executive Producer
GameDev.net

This topic is closed to new replies.

Advertisement