View difference between Paste ID: f3A7KgWh and SRSNe1ai
SHOW: | | - or go back to the newest paste.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <allegro5/allegro.h>
4
#include <allegro5/allegro_image.h>
5
6
ALLEGRO_DISPLAY *display = NULL;
7
const int SCREEN_W = 640,
8
		SCREEN_H = 480;
9
10
void quit(bool condition, const char* quitMessage) {
11
	if (condition) {
12
		fprintf(stderr, quitMessage);
13
		al_destroy_display(display);
14
		exit(-1);
15
	}
16
}
17
18
int main(int argc, char **argv) {
19
20
	ALLEGRO_EVENT_QUEUE *event_queue = NULL;
21-
	ALLEGRO_BITMAP *bg = NULL;
21+
22
	ALLEGRO_BITMAP *tilebmp = NULL;
23
24
	quit(!al_init(),
25
			"failed to initialize allegro!\n");
26
	quit(!(display = al_create_display(SCREEN_W, SCREEN_H)),
27
			"failed to create display!\n");
28
	quit(!(event_queue = al_create_event_queue()),
29
			"failed to create event_queue!\n");
30
	quit(!al_init_image_addon(),
31
			"failed to initialize image addon!\n");
32
	quit(!(tile = al_load_bitmap("resources\\tile.png")),
33-
	quit(!(bg = al_load_bitmap("resources\\bg.png")),
33+
34
	quit(!(tilebmp = al_load_bitmap("resources\\tile.bmp")),
35
			"failed to load image!\n");
36
37
	al_register_event_source(event_queue, al_get_display_event_source(display));
38
39
	al_clear_to_color(al_map_rgb(255,255,255));
40
	al_flip_display();
41
42-
	al_clear_to_color(al_map_rgb(0,0,0));
42+
43
		ALLEGRO_EVENT ev;
44
		ALLEGRO_TIMEOUT timeout;
45
		al_init_timeout(&timeout, 0.06);
46
47
		bool get_event = al_wait_for_event_until(event_queue, &ev, &timeout);
48
49
		if (get_event && ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
50
		break;
51
		}
52
53
		al_clear_to_color(al_map_rgb(255,255,255));
54
		al_draw_bitmap(tile,32,32,0);
55
		al_draw_bitmap(tilebmp,128,32,0);
56
		al_flip_display();
57
	}
58
59
	al_destroy_display(display);
60
	al_destroy_event_queue(event_queue);
61
62
	return 0;
63
}