Search code examples
cprogramming-languages

error: ‘TRUE’ was not declared in this scope pad.pvx*= -1; }


void move_paddle(PADDLE pad, bool alongX)
{
    if(alongX!=TRUE)
    {
        if((pad.py+pad.length/2)>=B || (pad.py-pad.length/2)<=BB)
            pad.pvx*= -1;
    }
    else if((pad.px+pad.length/2)>=A || (pad.py-pad.length/2)<=AA)
            pad.pvx*= -1;
}

What is the actual error ? M unable to get through.


Solution

  • You should use something like an int instead of a bool in c, and as long as it's value ain't 0 it's true, I would change this to

    void move_paddle(PADDLE pad, int alongX)
    {
        if(!alongX)
        {
            if((pad.py+pad.length/2)>=B || (pad.py-pad.length/2)<=BB)
                pad.pvx*= -1;
        }
        else if((pad.px+pad.length/2)>=A || (pad.py-pad.length/2)<=AA)
                pad.pvx*= -1;
    }