Witam,
jak większość mających problemy tutaj zaczynam z allegro, ale staram sie sobie sam radzić, z tym że mam problem i kompletnie nie wiem gdzie.
Mapa kafelkowa, wrzuciłem kafelek o kolorze 255,0,255 żeby funkcją getpixel opadał. Ale on po prostu wariuje, opada i podnosi się zarówno na kafelkach kolorowych jak i w powietrzu,

oto kod:

#include <allegro.h>

// Inicjowanie timera
volatile long speed = 0;
void increment_speed()
{
speed++;
}
END_OF_FUNCTION(increment_speed);
LOCK_VARIABLE(speed);
LOCK_FUNCTION(increment_speed);

// Zmienne potrzebne do mapy
int mapa_x = 0, mapa_y = 0;
BITMAP *teren = NULL;
BITMAP *bufor = NULL;
BITMAP *ludek = NULL;

// DEFINICJA MAPY
short int map[12][20] =
{
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,3,3,3,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,3,3,3,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,3,3,3,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,3,3,3,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,3,3,3,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,3,3,3,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,3,3,3,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,3,4,2,2,3,3,3,
8,8,8,8,8,8,8,8,8,8, 3,3,3,4,4,4,4,4,4,4,
0,3,4,4,4,4,4,4,4,4, 3,3,4,4,4,4,4,4,4,4,
1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,

};

// Funkcja wyświetlająca mapę:
void wys_mape()
{

  int licznik_x, licznik_y;
  for (licznik_x = 0; licznik_x < 16 ; licznik_x++)
  {
  for (licznik_y = 0; licznik_y < 12 ; licznik_y++)
  {                    
       masked_blit(teren,bufor,
       (map[licznik_y + mapa_y][licznik_x + mapa_x]%3) * 40, 
       (map[licznik_y + mapa_y][licznik_x + mapa_x]/3) * 40,
       licznik_x * 40,licznik_y * 40,40,40);

  }
  }     

};

// Funkcja Główna
int main()
{
allegro_init();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
install_timer();
install_int_ex(increment_speed, BPS_TO_TIMER(20));

// Do sterowania naszyą postacią:
int ludek_x = 100, ludek_y = 100;

ludek = load_bmp("ludek.bmp",default_palette);

// Tworzenie bufora
bufor = create_bitmap(640,480);
if (!bufor)
{
set_gfx_mode(GFX_TEXT,0,0,0,0);
allegro_message("Nie mogę utworzyć bufora !");
allegro_exit();
return 0;
}

// Ładowanie grafiki
teren = load_bmp("teren1.bmp",default_palette);

while( !key[KEY_ESC])
{
while( speed > 0)
{

{
// Sterowanie naszą postacią
   if((key[KEY_RIGHT]) && (ludek_x < 800)){ ludek_x +=3;} else
   if((key[KEY_LEFT]) && (ludek_x > 0)){ ludek_x -=3; } else
  // if((key[KEY_DOWN]) && (mapa_y < 5)){ mapa_y = mapa_y + 1; } else
   if((key[KEY_UP]) && (ludek_y > 40)){ ludek_y -=10; }    


	
	
	
	// Jeśli ludek wisi w powietrzu to powinien spadać:
	// if (getpixel(teren, ludek_x, ludek_y) != makecol(255,0,255) &&
		getpixel(teren, ludek_x, ludek_y-1) != makecol(255,0,255) &&
		ludek_y >2 ) ludek_y --;
	if (getpixel(teren, ludek_x, ludek_y) == makecol(255,0,255)) ludek_y +=4;

   

// SCROLLOWANIE MAPY
if((key[KEY_RIGHT]) && (mapa_x < 4)){ mapa_x = mapa_x + 1; } else
if((key[KEY_LEFT]) && (mapa_x > 0)){ mapa_x = mapa_x - 1; } else
if((key[KEY_DOWN]) && (mapa_y < 0)){ mapa_y = mapa_y - 1; } else
if((key[KEY_UP]) && (mapa_y > 0)){ mapa_y = mapa_y - 1; }
speed--;
}
}
// Czyszczenie bufora
clear_to_color(bufor, makecol(150,150,150));

// Wyświetlanie mapy
wys_mape();
masked_blit( ludek, bufor, 0,0, ludek_x-20, ludek_y-40, ludek->w, ludek->h);

blit( bufor, screen, 0,0,0,0, 640,480);
}
// Usuwanie wszystkiego z pamięci.
remove_int( increment_speed);
destroy_bitmap(teren);
destroy_bitmap(bufor);
destroy_bitmap(ludek);
allegro_exit();
return 0;
}
END_OF_MAIN();

z góry dzięki