Esempio n. 1
0
File: main.c Progetto: jaici/grafo
int main()
{
    GrafoM* testeMatriz;
    testeMatriz = init(SIZE);//inicia com numero máximo de grafo
    grafoInsert(testeMatriz,0,1);
    grafoInsert(testeMatriz,1,2);
    grafoInsert(testeMatriz,1,4);
    grafoInsert(testeMatriz,2,3);
    grafoInsert(testeMatriz,2,4);
    grafoInsert(testeMatriz,2,9);
    grafoInsert(testeMatriz,3,4);
    grafoInsert(testeMatriz,4,5);
    grafoInsert(testeMatriz,4,6);
    grafoInsert(testeMatriz,4,7);
    grafoInsert(testeMatriz,5,6);
    grafoInsert(testeMatriz,7,8);
    grafoInsert(testeMatriz,7,9);
    grafoShow(testeMatriz);
    geraArq(testeMatriz);
printf("\n###################\nBusca de profundidade\n#####################\n");
    DIGRAPHbfs(testeMatriz,0);

    liberaMem(testeMatriz,SIZE);

    /**NÃO ESTÁ FUNCIONANDO LISTA ENCADEADA*/
    return 0;
}
Esempio n. 2
0
void Juego::cambiaEstado(Estado es) {
    switch (es) {
        case MENU:
            liberaMem();
#            ifdef DEB
            cout << "CAMBIANDO ESTADO: MENU" << endl;
#            endif
            fondo = IMG_Load(fond.c_str());
            bjugar = new Boton(pantalla, "jugarOFF.png", "jugarON.png", 5, 475);
            bsalir = new Boton(pantalla, "salirOFF.png", "salirON.png", 5, 540);
            e = MENU;
#            ifdef DEB
            cout << "ESTADO CAMBIADO A MENU" << endl;
#            endif
            break;
        case JUEGO:
            if (e != SUBMENU) {
                liberaMem();
            }
#            ifdef DEB
            cout << "CAMBIANDO ESTADO: JUEGO" << endl;
#            endif
#            ifdef DEB
            cout << "\tcontrolador>Cambiando fondo" << endl;
#            endif
            fondo = IMG_Load(mapas.consulta().c_str());
            if (jugador == NULL) {
#                ifdef DEB
                cout << "\tcontrolador>Creando jugador" << endl;
#                endif
                jugador = new Tanque(40, 40, 550.0, 550.0, 1.0, 0);
            }
            if (oponentes == NULL) {
#                ifdef DEB
                cout << "\tcontrolador>Creando enemigos" << endl;
#                endif
                oponentes = new Enemigos();
#                ifdef DEB
                cout << "\tcontrolador>agnadiendo enemigos" << endl;
#                endif
                oponentes->agnadirEnems(2);
            }
            if (cif == NULL) {
#                ifdef DEB
                cout << "\tcontrolador>Creando Marcador" << endl;
#                endif
                cif = new Cifra("numeros2.png", 5, 690, 10);
            }
            e = JUEGO;
#            ifdef DEB
            cout << "ESTADO CAMBIADO A JUEGO" << endl;
#            endif
            break;

        case SALIR:
#            ifdef DEB
            cout << "CAMBIANDO ESTADO: SALIR" << endl;
#            endif
            if (e == JUEGO) {
                cambiaEstado(SUBMENU);
            } else if (e == MENU || e == SUBMENU) {

                liberaMem();
                e = SALIR;
#                ifdef DEB
                cout << "ESTADO CAMBIADO A SALIR" << endl;
#                endif
                finJuego();
            }
            break;
        case SUBMENU:
#            ifdef DEB
            cout << "CAMBIANDO ESTADO: SUBMENU" << endl;
#            endif
            confirma = IMG_Load("salirMenu.png");
            bSI = new Boton(pantalla, "siON.png", "siOFF.png", 300, 300);
            bNO = new Boton(pantalla, "noON.png", "noOFF.png", 300, 375);
#            ifdef DEB
            cout << "ESTADO CAMBIADO A SUBMENU" << endl;
#            endif
            e = SUBMENU;
            break;
        case GAMEOVER:
#            ifdef DEB
            cout << "CAMBIANDO ESTADO:GAMEOVER" << endl;
#            endif
            liberaMem();
            fondo = IMG_Load("gameover.png");
#            ifdef DEB
            cout << "ESTADO CAMBIADO A GAMEOVER" << endl;
#            endif
            e = GAMEOVER;
            break;
        case FINFASE:
#            ifdef DEB
            cout << "CAMBIANDO ESTADO:FINFASE" << endl;
#            endif
            liberaMem();
            fondo = IMG_Load("finfase.png");
#            ifdef DEB
            cout << "ESTADO CAMBIADO A FINFASE" << endl;
#            endif
            e = FINFASE;
            break;
    }
}