Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/main.c Secret

Last active February 14, 2021 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/3bccd3e763fe0c4da968741d58ce90a5 to your computer and use it in GitHub Desktop.
Save parzibyte/3bccd3e763fe0c4da968741d58ce90a5 to your computer and use it in GitHub Desktop.
#include <allegro5/allegro5.h>
#include <allegro5/allegro_font.h>
#include <stdbool.h>
int main()
{
al_init();
al_install_keyboard();
ALLEGRO_TIMER *timer = al_create_timer(1.0 / 30.0);
ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue();
ALLEGRO_DISPLAY *disp = al_create_display(320, 200);
ALLEGRO_FONT *font = al_create_builtin_font();
al_register_event_source(queue, al_get_keyboard_event_source());
al_register_event_source(queue, al_get_display_event_source(disp));
al_register_event_source(queue, al_get_timer_event_source(timer));
bool redraw = true;
ALLEGRO_EVENT event;
al_start_timer(timer);
while (1)
{
al_wait_for_event(queue, &event);
if (event.type == ALLEGRO_EVENT_TIMER)
redraw = true;
else if ((event.type == ALLEGRO_EVENT_KEY_DOWN) || (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE))
break;
if (redraw && al_is_event_queue_empty(queue))
{
al_clear_to_color(al_map_rgb(0, 0, 0));
al_draw_text(font, al_map_rgb(255, 255, 255), 0, 0, 0, "Hola mundo");
al_flip_display();
redraw = false;
}
}
al_destroy_font(font);
al_destroy_display(disp);
al_destroy_timer(timer);
al_destroy_event_queue(queue);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment