Untitled
raw download clone
TEXT
views 13
,
size 1559 b
#include <stdio.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
/*
    TODO: Declare display variable.
*/
ALLEGRO_DISPLAY* display = NULL;
const int width = 800;
const int height = 600;
void show_err_msg(int msg);
void game_init();
void game_begin();
void game_destroy();
int main(int argc, char *argv[]) {
    int msg = 0;
    printf("Hello world!!!\n");
    al_rest(5);
    game_init();
    game_begin();
    al_rest(5);
    printf("See you, world!!\n");
    game_destroy();
    return 0;
}
void show_err_msg(int msg) {
    fprintf(stderr, "unexpected msg: %d", msg);
    game_destroy();
    exit(9);
}
/*
    The function above aims to show the error message and terminate the game.
    You may use it in any function need to deal with some error message.
    The program would not get any error if you don't utilize it,
    But you may get a tough debugging time when some mistakes happen.
    You can modify it to fit for your habit.
*/
void game_init() {
    if (!al_init()) {
        show_err_msg(-1);
    }
    display = al_create_display(width, height);
    /*
        TODO: Create your display variable.
    */
}
void game_begin() {
    al_clear_to_color(al_map_rgb(0, 100, 100));
    al_flip_display();
    /*
        TODO: Fill the whole window with an arbitrary color, and show the window
    */
}
void game_destroy() {
    al_destroy_display(display);
    /*
        TODO: Destroy everything you have initialized or created.
    */
}
close fullscreen
Login or Register to edit or fork this paste. It's free.