When I include i++; inside this loop I get a runtime error and I have no idea why I get it:
Do you have any idea?

while (i <= 3){
        
           if (tauler[PacMan.y][PacMan.x]==0)
               xoc = 0;
           else if (tauler[PacMan.y][PacMan.x]==1)
               xoc = 1;
           else if (tauler[PacMan.y][PacMan.x]==2)
               xoc = 2;
           else 
               xoc = 3;
               
        
         i++;
         PacMan.x += dx;
         PacMan.y += dy;
}

What was the value of i before you went into the while loop?

Solved,
tauler[PacMan.y + 1 ] is an invalid vaule.
Thanks to everyone who has helped.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.