예제 #1
0
void main()
{
    char opcion;
    fh = fopen(fich, "rb");
    if (fh == NULL)
    {
        puts("El archivo va a ser creado");
        creacion();
    }
    else
        fh = NULL;
    do
    {
        puts("1. Compra ");
        puts("2. Venta ");
        puts("3. Consulta ");
        puts("0. Salir");
        do {
            printf("> Elige una opción: ");
            scanf("%c%*c", &opcion);
        } while( opcion < '0' || opcion > '3' );
        
        switch(opcion)
        {
            case '1':
                compra(); break;
            case '2':
                venta(); break;
            case '3':
                consulta(); break;
        }
    } while(opcion != '0');
    if (fh != NULL) fclose(fh);
}
예제 #2
0
void tienda()
{
    int i, xi, pag = 1,
        huesos,
        pos = 0; // Posicion del indicador.
    char tecla;
    String aux;

    obtenerDatos(&huesos, &i);
    setvisualpage(pag);
    while(tecla!=27)
    {
        setactivepage(pag=!pag);
        setfillstyle(1, COLOR(79, 182, 225));
        bar(0,0, WIDTH, HEIGHT);
        dibujaHuesos(huesos);
        setfillstyle(1, 0x00f);
        for(i=0, xi=WIDTH/3; i<NSKINS; i++, xi+=PIXEL_TAM*25)
            if(pos==i)
                bar(xi, 450+PIXEL_TAM*25, xi+PIXEL_TAM*20, 460+PIXEL_TAM*25);

        if(kbhit())
            switch(tecla = getch())
            {
                case 13:
                    compra(pos+1);
                    obtenerDatos(&huesos, &i);
                    break;
                case 77:
                    if(pos!=2)
                        pos++;
                    break;
                case 75:
                    if(pos!=0)
                        pos--;
                    break;
            }

        setbkcolor(0x0066F4);
        setfillstyle(1, 0x0066F4);
        setcolor(0x003988);
        settextstyle(2, HORIZ_DIR, 8);
        for(i=0, xi=WIDTH/3; i<NSKINS; i++, xi+=PIXEL_TAM*25)
        {
            sprintf(aux, "dino%d.%d.txt", i+1,pag);
            dibujaSprite(aux, xi, 450);
            sprintf(aux, "$ %d", 300*i);
            if(i)
                outtextxy(xi, 460+PIXEL_TAM*25, aux);
        }
        setvisualpage(pag);
        delay(80);
    }

    iniciaEntorno();
}