   Checking Passability
  This looking kinda dumb to make, but i aint gotting it. Im using allegro, with the function Passavel to verify if the next tile is passable or not. Im using the response only at a textprintf to check if its right, and its not, its all crazy sometimes returns not passable on a normal tile. Tiles can be only 1 or 2. 0 is not passable.#include <stdio.h>#include <stdlib.h>#include <allegro.h> int p_x = 0, p_y = 0;int m_altura, m_largura;int mapa[8][8] = {{1,1,1,1,1,1,1,1},   {1,1,1,2,2,1,1,1},   {1,1,1,2,2,1,1,1},   {1,1,1,2,2,1,1,1},   {1,1,1,2,2,1,1,1}};int passavel(int dir){  if(!dir || dir==0) return 1;  if(dir=2 && mapa[p_x][p_y+1]==0) return 0;    if(dir=4 && mapa[p_x-1][p_y]==0) return 0;   if(dir=6 && mapa[p_x+1][p_y]==0) return 0;   if(dir=8 && mapa[p_x][p_y-1]==0) return 0;   return 1;}END_OF_FUNCTION(passavel); void desenha_mapa(BITMAP **mapaM, BITMAP **mapaL1){   BITMAP *tile, *tile2, *grama2, *grama4, *grama8, *grama6;tile = load_bitmap("tiles/grama.bmp", NULL); tile2 = load_bitmap("tiles/areia.bmp", NULL); grama2 = load_bitmap("tiles/grama2.bmp", NULL);grama6 = load_bitmap("tiles/grama6.bmp", NULL); grama8 = load_bitmap("tiles/grama8.bmp", NULL); grama4 = load_bitmap("tiles/grama4.bmp", NULL);  int x, y;int tx = 0; int ty = 100;    for(y=0;y<8;y++) {    for(x=0;x<8;x++)    { switch(mapa[y][x]) {   case 1: draw_sprite(*mapaM, tile, tx, ty); break;   case 2: draw_sprite(*mapaM, tile2, tx, ty);  if(mapa[x+1][y]==1) draw_sprite(*mapaL1, grama6, tx, ty); if(mapa[x-1][y]==1) draw_sprite(*mapaL1, grama4, tx, ty); if(mapa[x][y+1]==1) draw_sprite(*mapaL1, grama2, tx, ty); if(mapa[x][y-1]==1) draw_sprite(*mapaL1, grama8, tx, ty);    break;    } tx+=16;  ty-=8;    }    ty = 100+(1+y)*8;    tx = (y+1)*16; }  }END_OF_FUNCTION(desenha_mapa); volatile long speed_counter = 0; void increment_speed_counter() { speed_counter++;} END_OF_FUNCTION(increment_speed_counter); int main(int argc, char *argv[]){m_altura = 8;    m_largura = 8;allegro_init();install_keyboard(); install_timer(); LOCK_VARIABLE(speed_counter); LOCK_FUNCTION(increment_speed_counter);install_int_ex(increment_speed_counter, BPS_TO_TIMER(40)); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);BITMAP *my_pic;my_pic = load_bitmap("neguim.bmp", NULL);  int movimento = 0;int contagem = 0;BITMAP *buffer; BITMAP *mapaM;BITMAP *mapaL1;mapaL1 = create_bitmap(640, 480);buffer = create_bitmap(640,480); mapaM = create_bitmap(640, 480);int my_pic_x = 0; int my_pic_y = 0;desenha_mapa(&mapaM, &mapaL1);   while(!key[KEY_ESC]) {  if(movimento==0)  {   if(key[KEY_RIGHT]) movimento = 6; else if(key[KEY_LEFT]) movimento = 4; else if(key[KEY_UP]) movimento = 8; else if(key[KEY_DOWN]) movimento = 2;   }  while(speed_counter > 0){  if(contagem < 8 && movimento!=0)  { switch(movimento) {    case 4: my_pic_x-= 2; my_pic_y++; break;    case 6: my_pic_x+= 2; my_pic_y--; break;case 2: my_pic_x+=2; my_pic_y++; break;    case 8: my_pic_x-=2; my_pic_y--;break;} contagem++;  }  else if(contagem==8)  {    switch(movimento)    { case 2:p_y++; break; case 4:p_x--;break; case 8:p_y--;break; case 6:p_x++; break;   }  movimento = 0;    contagem = 0;    }  speed_counter --;}draw_sprite(buffer, mapaM, 0, 0);//draw_sprite(buffer, mapaL1, 0, 0);draw_sprite(buffer, my_pic, my_pic_x+5, my_pic_y+83);textprintf(buffer,font,0,0,makecol(99,99,99),"X:%d Y:%d Dir: %d Passavel? %d", p_x, p_y , movimento , passavel(movimento));blit(buffer, screen, 0,0,0,0,640,480); clear_bitmap(buffer);} return 0; }END_OF_MAIN() 
int passavel(int dir){  if(!dir || dir==0) return 1;  if(dir=2 && mapa[p_x][p_y+1]==0) return 0;    if(dir=4 && mapa[p_x-1][p_y]==0) return 0;   if(dir=6 && mapa[p_x+1][p_y]==0) return 0;   if(dir=8 && mapa[p_x][p_y-1]==0) return 0;   return 1;}END_OF_FUNCTION(passavel); Are you sure you meant the = to be assignments instead of comparisons?   ;  shet man that was the prob. Thx and sorry for tha dumb question.   