mój program nie scrolluje mapy tak jak powinien postać się porusza tylko o kilka pixeli a mapa się nie scrolluje.Bardzo proszę o pomoc
#include <allegro.h>
#include <iostream>
using namespace std;
int mapa_x = 0;
int mapa_y = 0;
int ludek_x = 0;
int ludek_y = 0;
int ludek_kierunek = 0;
int ludek_klatka = 0;
int frame = 0;
BITMAP * teren = NULL;
BITMAP * bufor = NULL;
BITMAP * ludek = NULL;
int map[ 15 ][ 15 ] =
{
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
};
void wyswietl()
{
    int i;
    int j;
    for( int i = 0; i < 15; i++ )
    {
        for( int j = 0; j < 15; j++ )
        {
            blit( teren, bufor,
            ( map[ j + mapa_y ][ i + mapa_x ] % 4 ) * 40,
            ( map[ j + mapa_y ][ i + mapa_x ] / 4 ) * 40,
            i * 40, j * 40, 40, 40 );
        }
    }
    
};
int main()
{
    allegro_init();
    install_keyboard();
    set_color_depth( 32 );
    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 600, 480, 0, 0 );
    bufor = create_bitmap( 600, 480 );
    teren = load_bitmap( "teren.bmp", default_palette );
    ludek = load_bitmap( "ludek.bmp", default_palette );
    while( !key[ KEY_ESC ] )
    {
        
        ludek_kierunek = 0;
        
        if(( key[ KEY_LEFT ] ) &&( mapa_x > 0 ) )
        { ludek_kierunek = 4;
            ludek_x--;
            mapa_x--;
        }
        
        
        if(( key[ KEY_RIGHT ] ) &&( mapa_x < 15 ) )
        { ludek_kierunek = 2;
            ludek_x++;
            mapa_x++;
        }
        
        
        if(( key[ KEY_UP ] ) &&( mapa_y > 0 ) )
        { ludek_kierunek = 1;
            ludek_y--;
            mapa_y--;
        }
        
        
        if(( key[ KEY_DOWN ] ) &&( mapa_y < 15 ) )
        { ludek_kierunek = 3;
            ludek_y++;
            mapa_y++;
        }
        rest( 10 );
        frame++;
        if( frame > 40 ) frame = 0;
        
        if( frame < 20 ) { ludek_klatka = 0; }
        else if( frame >= 20 && frame < 40 ) { ludek_klatka = 1; }
        wyswietl();
        masked_blit( ludek, bufor, ludek_kierunek * 50, ludek_klatka * 50, ludek_x, ludek_y, 50, 50 );
        blit( bufor, screen, 0, 0, 0, 0, 600, 480 );
    }
    
    
    destroy_bitmap( teren );
    destroy_bitmap( bufor );
    destroy_bitmap( ludek );
    allegro_exit();
    return 0;
}
END_OF_MAIN();