1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <allegro.h>
BITMAP *item;
int x = 10;
int y = 10;
int main(){
allegro_init();
install_keyboard();
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
item = load_bitmap( "item.bmp", NULL);
while ( !key[KEY_ESC] ){
clear_keybuf();
acquire_screen();
textout_ex( screen, font, " ", x, y, makecol( 0, 0, 0), makecol( 0, 0, 0) );
if (key[KEY_UP]) y--;
else if (key[KEY_DOWN]) y++;
else if (key[KEY_RIGHT]) x++;
else if (key[KEY_LEFT]) x--;
// textout_ex( screen, font, "X", x, y, makecol( 255, 0, 0), makecol( 0, 0, 0) ); // Player
circle(screen, x, y, 10, makecol( 255, 0, 0));
release_screen();
rest(50); // Speed of the player
// circle( screen, 13, 13, 10, makecol( 255, 0, 0));
draw_sprite( screen, item, 400, 300);
}
return 0;
}
END_OF_MAIN();
|