示例#1
0
int list_select_loop(struct _select_def *conf)
{
    int ch;
    int ret;

    select_set_current_conf(conf);
    list_select(conf, KEY_INIT);
    while (1) {
        if ((ch=list_select_remove_key(conf))==KEY_INVALID)
            ch = igetkey();
        ret=list_select(conf, ch);
        if ((ret == SHOW_QUIT)||(ret == SHOW_SELECT))
            break;
    }
    select_set_current_conf(conf);
    return ret;
}
示例#2
0
int river_animation_iterate()
{
    /** VARIÁVEIS *****************************************************/
    float flux = Config.flux;       /* Fluxo do rio              */
    int length = Config.length;     /* Largura do grid           */
    int zone = Config.zone;         /* Zona de conforto          */
    Link new_node;                  /* Nódulo novo da lista      */
    TStrip top;                     /* Faixa superior do rio     */

    frame_height = 0; /* Zera altura do frame que imprime o rio */

    /** AVANÇA FAIXA DE TERRENO ***************************************/
    /* Libera linha do topo do grid ('saindo da tela') */
    new_node = list_prev(list_head(river));
    list_remove(river, new_node);

    /* Cria linha da base do grid ('entrando na tela') */
    top = tstrip_generate(length, zone, flux, base, list_item(new_node));
    base = top;
    list_insert(river, new_node);

    /** IMPRIME RIO ***************************************************/
    if(gui_event_get() == CLOSE) return EXIT_FAILURE;
    gui_window_clear();
    list_select(river, HEAD, strip_print);

    gui_boat_draw(&boat_hpos, &boat_vpos, 5);
    /* Velocidade */
    speedy = 0.6 * strip1[boat_hpos].v + (sqrt(cos(boat_angle)*cos(boat_angle))+1) * speedy*0.4;

    /* Barco bateu, recomeça do meio */
    if(strip1[boat_hpos].t == LAND
            || strip1[boat_hpos-1].t == LAND
            || strip1[boat_hpos-2].t == LAND
            || strip1[boat_hpos+1].t == LAND)
    {
        P1.lifes--;
        move = 0;
        boat_hpos = (int) (Config.length/2.0);
        boat_vpos = frame_height/5;
    }
    else
    {
        boat_angle = (pi/2.0)*(1- (10.0 * move/Config.length));
    }

    gui_window_update(P1.lifes);

    /* Fim de Jogo */
    if(P1.lifes == 0) return GAME_OVER;
    return EXIT_SUCCESS;
}
示例#3
0
void river_animation_generate(int seed)
{
    /** VARIÁVEIS *****************************************************/
    int i = 0;                       /* Contador                 */
    TStrip new_line;                 /* Linha gerada             */
    TStrip first_line;               /* 1ª linha gedara          */
    int zone = Config.zone;          /* 'Zona de conforto'       */
    float flux = Config.flux;        /* Fluxo total do rio       */
    int height = Config.height;      /* Altura total do grid     */
    int length = Config.length;      /* Largura total do rio     */
    int freq = Config.freq_island;   /* Distância entre ilhas    */
    float prob = Config.prob_island; /* Probabilidade de ilhas   */
    Link new_node;

    frame_length = length*5;
    frame_height = 0; /* Zera altura do frame de impressão do rio */

    /* Inicializa semente geradora de faixas de terreno
     * e cria lista para colocá-las: nosso cenário */
    tstrip_seed(seed);
    tstrip_island(prob, freq);
    river = list_init(height);

    /** INICIALIZA RIO ************************************************/
    /* Primeira linha, que servirá de base para todo o rio */
    first_line = tstrip_generate(length, zone, flux, NO_BASE, NULL);
    new_node = list_new_node(first_line);

    /* Preenche 'altura' faixas de terreno na lista: */
    list_insert(river, new_node);

    for(i = 1, base = first_line; i < height; i++, base = new_line)
    {
        new_line = tstrip_generate(length, zone, flux, base, NULL);
        new_node = list_new_node(new_line);
        list_insert(river, new_node);
    }

    /** IMPRIME RIO ***************************************************/
    gui_window_clear();
    list_select(river, HEAD, strip_print);

    boat_hpos = (int) (Config.length/2.0);
    boat_vpos = frame_height/5;
    gui_boat_draw(&boat_hpos, &boat_vpos, 5);


    gui_window_update(P1.lifes);
}