Hi so i’m trying to check a certain character in a string to make sure it’s not a \,=,|, etc. and replacing the space with the “player” character if it’s not but the function is returning true everytime, even if char newLoc is equal to ” (empty):
screen.get_contents returns a vector container full of strins, and
sprite.get_location returns an int array with two number, [0] representing X, [1] is Y.
bool check_collision(Sprite& sprite,int X, int Y, Screen& screen)
{
////////////////////// check whats already there /////
char newLoc = screen.get_contents(sprite.get_location()[0]+Y,sprite.get_location()[1]+X);
if (newLoc == '|' || '/' || '_' || '=' || 'X' || 'x' )
return true;
else
return false;
};
what is the problem? Thanks!!
You need:
What you have written is equivalent to:
which is equivalent to:
Note that a cleaner way of writing this might be: