Skip to main content
gamedev.net
🔒 Locked

need help

Started by cplus programmer Nov 8, 2004 at 6:09 PM 0 replies 800+ views
Original Post
cplus programmer
cplus programmer
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.
Gaiiden
Gaiiden
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.