Anyone here familiar with the allegro game library?
I have some code that does not work:
Basically, what im trying to do here is to have a 32 x 32 bitmap and put it on the screen and move it when the user presses the 'D' button.
I have some code that does not work:
Code:
//This is a small test for allegro #include <allegro.h> #define WHITE makecol(255, 255, 255) BITMAP *img; char filename[50] = "D:\\clown.bmp"; int x, y; char buffer[255]; int main() { allegro_init(); install_keyboard(); install_mouse(); set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 800, 600, 0, 0); textout_ex(screen, font, "This is a test", 0, 0, WHITE, 0); uszprintf(buffer, sizeof(buffer), "Resolution is = %dx%d", SCREEN_W, SCREEN_H); //load the sprite img = load_bitmap(filename, NULL); // set_mouse_sprite(img); // show_mouse(img); // textout_ex(screen, font, buffer, 0, 24, WHITE, 0); //declare pos of sprite x = SCREEN_W / 2 - 1; y = SCREEN_H / 2 - 1; //main loop while(!key[KEY_ESC]) { draw_sprite(screen, img, x, y);//note that the x and y as pos //check for arrow key if(key[KEY_D]) { if(x > SCREEN_W) { x = SCREEN_W - 1; uszprintf(buffer, sizeof(buffer), "The x = %d, and the y = %d", x, y); textout_ex(screen, font, buffer, 200, 157, WHITE, 0); textout_ex(screen, font, "Tried 2 leave window", 200, 150, WHITE, 0); } x = x + 1; } } destroy_bitmap(img); allegro_exit(); return 0; } END_OF_MAIN()
Comment