Is there a way or function available which would stop me from going over the characters. The maze looks like the following below. I actually dont use printf, but mvprint. I just used printf as an example below.
printf("xxxxxx x");
printf("xxxxxx x");
printf("xxxxxx x");
printf("x x");
printf("x xxxxxx");
printf("x xxxxxx");
I tried the this code below but it doesn't seem to work. The cursor still goes over the x characters. In the third line of the code you can see I've said that if there is a character 'f' there which is created by the bunch of printf
statements seen above, the cursor shouldn't move. This doesn't seem to work.
if(m == 's')
{
if((oldy+1,x)=='x') // This is the part of the code where i say that if the next spot is an 'x' dont move.
{
mvprint(win, 10,0,"Sorry, you cant move there.");
refresh(win);
}
else
{
move((y= oldy+1),x);
refresh();
oldy = y;
}
}