Witam, mam problem, otóż mam program z mapą który wygląda tak:
#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;
// DEFINICJA MAPY
short int map[60][60] =
{
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,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,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,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,1,1,1,1,1,
};
// Funkcja wyświetlająca mapę:
void wys_mape()
{
int licznik_x, licznik_y;
for (licznik_x = 0; licznik_x < 10 ; licznik_x++)
{
for (licznik_y = 0; licznik_y < 5 ; licznik_y++)
{
blit(teren,bufor,
(map[licznik_y + mapa_y][licznik_x + mapa_x]%6) * 60,
(map[licznik_y + mapa_y][licznik_x + mapa_x]/6) * 60,
licznik_x * 60,licznik_y * 60,60,60);
}
}
};
// Funkcja Główna
int main()
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
install_timer();
install_int_ex(increment_speed, BPS_TO_TIMER(40));
// Tworzenie bufora
bufor = create_bitmap(1240,980);
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("teren.bmp",default_palette);
while( !key[KEY_ESC])
{
while( speed > 0)
{
// SCROLLOWANIE MAPY
if((key[KEY_RIGHT]) && (mapa_x < 10)){ 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 < 5)){ 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();
blit( bufor, screen, 0,0,0,0, 640,480);
}
// Usuwanie wszystkiego z pamięci.
remove_int( increment_speed);
destroy_bitmap(teren);
destroy_bitmap(bufor);
allegro_exit();
return 0;
}
END_OF_MAIN();