Entering If Statement Despite Not Meeting Condition

Posted by msmf14 on Stack Overflow See other posts from Stack Overflow or by msmf14
Published on 2013-10-22T00:51:20Z Indexed on 2013/10/22 3:54 UTC
Read the original article Hit count: 118

Filed under:
|

This is a specific problem, but I can't seem to figure out what is wrong.

else if (X == 2)
        //move left
    {
        if (Level[X-1][Y] == 0);
        {

            cout << Level[X-1][Y] << "\n";
            cout << "\n MOVING LEFT from RIGHT\n";  //PROBLEM IS HERE

            Level[X][Y] = 1; // block it
            X = X - 1;
            moved = 1;
        }
    }

What I am doing is I am checking if Level[X-1][Y] is 1, indicating a column, so I can not move my player there. However for some reason, despite it being 1 and not 0 (as indicated by the output), the IF statement is still accessed. Any help will be appreciated.

© Stack Overflow or respective owner

Related posts about c++

Related posts about if-statement