Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <allegro5/allegro.h>
- #include <allegro5/allegro_image.h>
- ALLEGRO_DISPLAY *display = NULL;
- const int SCREEN_W = 640,
- SCREEN_H = 480;
- void quit(bool condition, const char* quitMessage) {
- if (condition) {
- fprintf(stderr, quitMessage);
- al_destroy_display(display);
- exit(-1);
- }
- }
- int main(int argc, char **argv) {
- ALLEGRO_EVENT_QUEUE *event_queue = NULL;
- ALLEGRO_BITMAP *tile = NULL;
- ALLEGRO_BITMAP *tilebmp = NULL;
- quit(!al_init(),
- "failed to initialize allegro!\n");
- quit(!(display = al_create_display(SCREEN_W, SCREEN_H)),
- "failed to create display!\n");
- quit(!(event_queue = al_create_event_queue()),
- "failed to create event_queue!\n");
- quit(!al_init_image_addon(),
- "failed to initialize image addon!\n");
- quit(!(tile = al_load_bitmap("resources\\tile.png")),
- "failed to load image!\n");
- quit(!(tilebmp = al_load_bitmap("resources\\tile.bmp")),
- "failed to load image!\n");
- al_register_event_source(event_queue, al_get_display_event_source(display));
- al_clear_to_color(al_map_rgb(255,255,255));
- al_flip_display();
- while(1) {
- ALLEGRO_EVENT ev;
- ALLEGRO_TIMEOUT timeout;
- al_init_timeout(&timeout, 0.06);
- bool get_event = al_wait_for_event_until(event_queue, &ev, &timeout);
- if (get_event && ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
- break;
- }
- al_clear_to_color(al_map_rgb(255,255,255));
- al_draw_bitmap(tile,32,32,0);
- al_draw_bitmap(tilebmp,128,32,0);
- al_flip_display();
- }
- al_destroy_display(display);
- al_destroy_event_queue(event_queue);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement