It just does not appear anything graphic, the functional (close the window) works perfectly, however the graphic (background color and "nave") do not work.
#include <allegro5\allegro.h>
#include <allegro5\allegro_native_dialog.h>
#include <allegro5\allegro_primitives.h>
#include "objetos.h"
const int height = 800;
const int width = 600;
void InitNave(NaveEspacial &nave);
void DesenhaNave(NaveEspacial &nave);
int main(void)
{
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_EVENT_QUEUE *fila_eventos = NULL;
bool end = false;
NaveEspacial nave;
if(!al_init())
{
al_show_native_message_box(NULL, "AVISO!", NULL, "FALHA AO CARREGAR ALLEGRO", NULL, NULL);
return -1;
}
display = al_create_display(height, width);
al_init_primitives_addon();
fila_eventos = al_create_event_queue();
al_register_event_source(fila_eventos, al_get_display_event_source(display));
if(!display)
{
al_show_native_message_box(NULL, "AVISO!", NULL, "FALHA AO CARREGAR O DISPLAY", NULL, NULL);
return -1;
}
InitNave(nave);
while(!end)
{
ALLEGRO_EVENT ev;
al_wait_for_event(fila_eventos, &ev);
if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
{
end = true;
}
DesenhaNave(nave);
al_flip_display;
al_clear_to_color(al_map_rgb(0, 0, 0));
}
al_destroy_display(display);
al_destroy_event_queue(fila_eventos);
return 0;
}
void InitNave(NaveEspacial &nave)
{
nave.x = 20;
nave.y = height / 2;
nave.ID = JOGADOR;
nave.vidas = 3;
nave.velocidade = 7;
nave.borda_x = 6;
nave.borda_y = 7;
nave.pontos = 0;
}
void DesenhaNave(NaveEspacial &nave)
{
al_draw_filled_rectangle(nave.x, nave.y - 9, nave.x + 10, nave.y - 7, al_map_rgb(255, 0, 0));
al_draw_filled_rectangle(nave.x, nave.y + 9, nave.x + 10, nave.y + 7, al_map_rgb(255, 0, 0));
al_draw_filled_triangle(nave.x - 12, nave.y - 17, nave.x + 12, nave.y, nave.x - 12, nave.y + 17, al_map_rgb(0, 255, 0));
al_draw_filled_rectangle(nave.x - 12, nave.y - 2, nave.x + 15 , nave.y + 2, al_map_rgb(0, 0, 255));
}