예제 #1
0
void gui_window_create(int length, int height)
{
    /* Variável representando a janela principal */
    window = NULL;
    boat = NULL;
    heart = NULL;

    /* Criamos a nossa janela - dimensões de largura x altura pixels */
    window = al_create_display(length, height);
    boat = al_load_bitmap("b3.png");
    heart = al_load_bitmap("heart.png");
    boat_height = al_get_bitmap_height(boat);
    boat_width = al_get_bitmap_width(boat);

    /* Preenchemos a janela de branco */
    al_clear_to_color(al_map_rgb(255, 255, 255));

    /* Atualiza a tela */
    al_flip_display();
    if (!event_queue)
    {
        fprintf(stderr, "Falha ao criar fila de eventos.\n");
        gui_window_destroy();
    }

    al_set_window_title(window, "Jogo da canoa");

    /* Associa teclado com a janela */
    al_register_event_source(event_queue,
        al_get_display_event_source(window));
}
예제 #2
0
static void __CDECL menu_close_win(short item, short title, void *data)
{
	LOG(("%s", __FUNCTION__));
	if( input_window == NULL )
		return;
	gui_window_destroy( input_window );
}
예제 #3
0
void river_animation_finish()
{
    list_free(river);
    river = NULL;
    base = NULL;
    gui_window_destroy();
}
예제 #4
0
int gui_event_get(void)
{
    if (!al_is_event_queue_empty(event_queue))
    {
        ALLEGRO_EVENT event;
        al_wait_for_event(event_queue, &event);

        /* 1º Caso: fechar a janela */
        if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
        {
            al_destroy_event_queue(event_queue);
            gui_window_destroy();
            return CLOSE;
        }
        /* 2º Caso: pressionando tecla */
        else if (event.type == ALLEGRO_EVENT_KEY_DOWN)
        {
            switch(event.keyboard.keycode)
            {
                case ALLEGRO_KEY_LEFT:
                    gui_keyboard(MOVE_LEFT);
                    break;
                case ALLEGRO_KEY_RIGHT:
                    gui_keyboard(MOVE_RIGHT);
                    break;
            }
        }
        /* 3º caso: soltando tecla */
        else if (event.type == ALLEGRO_EVENT_KEY_UP)
        {
            switch(event.keyboard.keycode)
            {
                case ALLEGRO_KEY_LEFT:
                    gui_keyboard(STOP_LEFT);
                    break;
                case ALLEGRO_KEY_RIGHT:
                    gui_keyboard(STOP_RIGHT);
                    break;
            }
        }
    } /* while */
    return 0;
}