Tak jak w temacie, jeśli tam linka do bitmapy z mapą i kod programu.
#include <allegro.h>
volatile long speed = 0;
void increment_speed()
{
speed++;
}
END_OF_FUNCTION( increment_speed );
LOCK_VARIABLE( speed );
LOCK_FUNCTION( increment_speed );
short int map[ 20 ][ 20 ] = {
10, 6, 1, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 12, 13, 14, 15, 16, 17, 12, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 3, 7, 3, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 12, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10,
};
int main()
{
allegro_init();
install_keyboard();
set_color_depth( 16 );
set_gfx_mode( GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0 );
clear_to_color( screen, makecol( 100, 100, 10 ) );
install_timer();
install_int_ex( increment_speed, BPS_TO_TIMER( 2 ) );
BITMAP * ludek;
BITMAP * mapa = NULL;
BITMAP * bufor = NULL;
bufor = create_bitmap( 800, 600 );
ludek = load_bmp( "grafika/ludek.bmp", default_palette );
mapa = load_bmp( "grafika/mapa.bmp", default_palette );
int ludek_x = 0;
int ludek_y = 0;
int gora = 1, dol = 1, lewo = 1, prawo = 1;
int mapa_x = 0;
int mapa_y = 0;
while( !key[ KEY_ESC ] )
{
while( speed > 0 )
{
if( key[ KEY_LEFT ] && ludek_x > 0 )
{
ludek_x = ludek_x - 48;
++lewo;
--prawo;
}
if( key[ KEY_RIGHT ] && ludek_x < 760 )
{
ludek_x = ludek_x + 48;
++prawo;
--lewo;
}
if( key[ KEY_UP ] && ludek_y > 0 )
{
ludek_y = ludek_y - 48;
++gora;
--dol;
}
if( key[ KEY_DOWN ] && ludek_y < 560 )
{
ludek_y = ludek_y + 48;
++dol;
--gora;
}
--speed;
}
clear_to_color( bufor, makecol( 0, 0, 0 ) );
for( int x = 0; x < 10; ++x )
for( int y = 0; y < 10; ++y )
{
blit( mapa, bufor,
( map[ y ][ x ] % 6 ) * 48,
( map[ y ][ x ] / 3 ) * 48,
x * 48, y * 48, 48, 48 );
}
masked_blit( ludek, bufor, 0, 0, ludek_x, ludek_y, ludek->w, ludek->h );
blit( bufor, screen, 0, 0, 0, 0, 800, 600 );
}
remove_int( increment_speed );
destroy_bitmap( ludek );
destroy_bitmap( mapa );
destroy_bitmap( bufor );
allegro_exit();
return 0;
}
END_OF_MAIN();
proszę, pomóżcie!!! Bo muszę to zrobić, bardzo mi na tym zależy bo taka prosta sprawa mi nie wychodzi, a muszę dokończyć projekt!!!