diff --git a/DOCUMENTACION/Juego/mainwindow.cpp b/DOCUMENTACION/Juego/mainwindow.cpp index 4e1658c..98255ac 100644 --- a/DOCUMENTACION/Juego/mainwindow.cpp +++ b/DOCUMENTACION/Juego/mainwindow.cpp @@ -7,1186 +7,951 @@ MainWindow::MainWindow(QWidget *parent) { //intro->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/fantasy.mp3")); + niveles(opcion); start=new QPushButton("INICIAR JUEGO", this); -start->setGeometry(QRect( QPoint(310,160), //250x160 +start->setGeometry(QRect( QPoint(310,160), // Valores por defecto 250x160 QSize(200, 50) )); -//200x 50 +//Valores por defecto : 200x 50 connect(start, SIGNAL (clicked()),this, SLOT (botonInicio())); start->setStyleSheet("background-color: gray"); saveData=new QPushButton ("CONTINUAR PARTIDA ",this); -saveData->setGeometry(QRect( QPoint(310,300), //250x160 + + +saveData->setGeometry(QRect( QPoint(310,300), QSize(200, 50) )); connect(saveData, SIGNAL (clicked()),this, SLOT (guardarPartida())); saveData->setStyleSheet("background-color: gray"); bolaFuego=new Objeto(0,0,30, ":/IMAGENES/BOLADEFUEGO.png"); - timer=new QTimer(this); //crea el timer - timer->stop(); //para el timer - connect(timer,SIGNAL(timeout()),this,SLOT(lanzamiento())); - timer->start(10); + +/* +timer->stop(); +connect(timer,SIGNAL(timeout()),this,SLOT(actualizar())); +timer->start(dt);*/ + + + +/*LISTA.append(new Particula(0,0,0,0,50000,200)); +LISTA.append(new Particula(-5000,0,0,0,70,70)); +LISTA.append(new Particula(5000,0,0,0,70,70)); */ //Planetas agregados directamente +// LISTA.append(new Graficar(0,-5000,2,0,70,70)); +//LISTA.append(new Graficar(0,5000,-2,0,70,70)); + + + } + +//-------------------------------------------------KEYPRESSEVENT-------------------------------------------------- + void MainWindow::keyPressEvent(QKeyEvent *evento) { + qDebug()<pos()<x(); + +//-----------------------------------------EVENTO PERSONAJE 1 NIVEL 1------------------------------------------------- + if (opcion==1) { if(evento->key()==Qt::Key_A) { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + coaliciones('A', personaje1); + } - //---------GIRO DEL PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(180); - personaje1->izquierda(); + else if(evento->key()==Qt::Key_D) + { + coaliciones('D', personaje1); - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) + } + else if(evento->key()==Qt::Key_W) { - bolaH->izquierda(); - } - if(personaje1->collidesWithItem(enemigo1)) - { - enemigo1->izquierda(); - x = enemigo1->x(); - y = enemigo1->y(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); + coaliciones('W', personaje1); - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } } - //-------EVALUAR COALISIONES CON MUROS----- - for (int i=0;ikey()==Qt::Key_S) { - if (personaje1->collidesWithItem(muros.at(i))) - { - personaje1->derecha(); - } + coaliciones('S', personaje1); } - //-------EVALUAR COALISIONES CON PIEDRAS----- - - for (int i=0;icollidesWithItem(piedras.at(i))) - { - - personaje1->derecha(); - } - } - - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); - - - //llaves+=1; +// qDebug()<pos()<x(); - } +//-------------------------------------------------EVENTO PERSONAJE 2 NIVEL 1------------------------------------------------------------ +if(evento->key()==Qt::Key_I) +{ - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { + coaliciones('I', personaje2); - personaje1->derecha(); - //remover escena - } +} +if(evento->key()==Qt::Key_J) +{ + coaliciones('J', personaje2); - } +} +if(evento->key()==Qt::Key_L) +{ - else if(evento->key()==Qt::Key_D) - { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + coaliciones('L', personaje2); - //---------GIRO DEL PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(0); - personaje1->derecha(); +} +if(evento->key()==Qt::Key_K) - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) +{ - { - bolaH->derecha(); - } - if(personaje1->collidesWithItem(enemigo1)) + coaliciones('K', personaje2); - { - x = enemigo1->x(); - y = enemigo1->y(); - enemigo1->derecha(); - //bolaFuego->setPosx(personaje1->pos()); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); +} - timer->start(30); - } +//------------------------------------------------CAMBIO DE NIVEL 1 A 2------------------------------------------------- - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } - //-------EVALUAR COALISIONES CON MUROS----- - for (int i=0;icollidesWithItem(muros.at(i))) - { + if (((personaje1->x()==250 or personaje2->x()==250) and (personaje1->y()==390 or personaje2->y()==390 )) ) + { + opcion=2; + niveles(opcion); - personaje1->izquierda(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- + } - for (int i=0;icollidesWithItem(piedras.at(i))) - { +} - personaje1->derecha(); - } - } +//--------------------------------------------------EVENTO PERSONAJE 1 NIVEL 2------------------------------------------------- - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); +if (opcion==2) +{ + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + else if(evento->key()==Qt::Key_D) + { - //llaves+=1; + coaliciones('D', personaje1); - } + } + else if(evento->key()==Qt::Key_W) + { - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->izquierda(); - //remover escena - } + coaliciones('W', personaje1); + } + else if(evento->key()==Qt::Key_S) + { + coaliciones('S', personaje1); } - else if(evento->key()==Qt::Key_W) - { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - //---------GIRO DE PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(270); - personaje1->subir(); +// qDebug()<pos()<x(); +//-------------------------------------------EVENTO PERSONAJE 2 NIVEL 2------------------------------------------------------------ +if(evento->key()==Qt::Key_I) +{ - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->subir(); - } - if(personaje1->collidesWithItem(enemigo1)) + coaliciones('I', personaje2); - { - enemigo1->subir(); +} +if(evento->key()==Qt::Key_J) +{ + coaliciones('J', personaje2); - x = enemigo1->x(); - y = enemigo1->y(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); +} +if(evento->key()==Qt::Key_L) +{ - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } - //-------EVALUAR COALISIONES CON MUROS----- - for (int i=0;icollidesWithItem(muros.at(i))) - { + coaliciones('L', personaje2); +} +if(evento->key()==Qt::Key_K) - personaje1->bajar(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- - for (int i=0;icollidesWithItem(piedras.at(i))) - { - personaje1->derecha(); - } - } - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); +//------------------------------------------------CAMBIO DE NIVEL 2 A 3------------------------------------------------- - //llaves+=1; + if ((personaje1->x()==250 and personaje1->y()==390) ) + { - } + niveles(3); - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->bajar(); - //remover escena - } + } - } - else if(evento->key()==Qt::Key_S) - { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); +} +//-----------------------------------------------EVENTO PERSONAJE 1 NIVEL 3------------------------------------------------- - //---------GIRO DE PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(90); - personaje1->bajar(); +if (opcion==3) +{ + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->bajar(); - } - if(personaje1->collidesWithItem(enemigo1)) + else if(evento->key()==Qt::Key_D) + { + coaliciones('D', personaje1); - { + } + else if(evento->key()==Qt::Key_W) + { - x = enemigo1->x(); - y = enemigo1->y(); - enemigo1->bajar(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); + coaliciones('W', personaje1); - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } + } - //-------EVALUAR COALISIONES CON MUROS----- + else if(evento->key()==Qt::Key_S) + { - for (int i=0;icollidesWithItem(muros.at(i))) - { + coaliciones('S', personaje1); + } - personaje1->subir(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- - for (int i=0;icollidesWithItem(piedras.at(i))) - { - personaje1->derecha(); - } - } - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); +//---------------------------------------------EVENTO PERSONAJE 2 NIVEL 3------------------------------------------------------------ - //llaves+=1; +if(evento->key()==Qt::Key_I) +{ - } + coaliciones('I', personaje2); - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->subir(); - //remover escena - } +} +if(evento->key()==Qt::Key_J) +{ + coaliciones('J', personaje2); +} +if(evento->key()==Qt::Key_L) +{ + coaliciones('L', personaje2); +} +if(evento->key()==Qt::Key_K) - } +{ -// qDebug()<pos()<x(); + coaliciones('K', personaje2); +} - if ((personaje1->x()==250 and personaje1->y()==390) ) - { - opcion=2; - niveles(opcion); +} - } } -if (opcion==2) + +void MainWindow::coaliciones(char letra , Personaje *personaje) { - if(evento->key()==Qt::Key_A) + if (personaje==personaje1) { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - //---------GIRO DEL PERSONAJE------- + if (letra=='A') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + + //---------------------------GIRO DEL PERSONAJE1 (A)------------------------------ + personaje1->setTransformOriginPoint(0,0); personaje1->setRotation(180); personaje1->izquierda(); - //---------COALISIONES------- + //------------------------------COALISIONES1 (A) ---------------------------- + if(personaje1->collidesWithItem(bolaH)) { - bolaH->izquierda(); + bolaH->izquierda(); } if(personaje1->collidesWithItem(enemigo1)) { - enemigo1->izquierda(); - x = enemigo1->x(); - y = enemigo1->y(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); + resorte('A', personaje1); + x = enemigo1->x(); + y = enemigo1->y(); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); - timer->start(30); + timer->start(30); } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } + if (personaje1->collidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } } - //-------EVALUAR COALISIONES CON MUROS----- + */ + //------------------------EVALUAR COALISIONES CON MUROS 1(A)------------------ + for (int i=0;icollidesWithItem(muros.at(i))) - { + if (personaje1->collidesWithItem(muros.at(i))) + { - personaje1->derecha(); - } + personaje1->derecha(); + } } - //-------EVALUAR COALISIONES CON PIEDRAS----- + //--------------------EVALUAR COALISIONES CON PIEDRAS 1(A)-------------------- for (int i=0;icollidesWithItem(piedras.at(i))) - { + { + if (personaje1->collidesWithItem(piedras.at(i))) + { - personaje1->derecha(); - } - } + personaje1->derecha(); + } + } - //-------CAPTURAR LLAVES----- + //--------------------------CAPTURAR LLAVES 1(A)------------------------------- if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); + { + //key->play(); + scene->removeItem(llave); - //llaves+=1; + //llaves+=1; - } + } - //------------PUERTA-------------- + //--------------------------PUERTA 1(A)------------------------------------------- if (personaje1->collidesWithItem(puerta)) - { - - personaje1->derecha(); - //remover escena - } - + { + personaje1->derecha(); + //remover escena } - else if(evento->key()==Qt::Key_D) - { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - - //---------GIRO DEL PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(0); - personaje1->derecha(); - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->derecha(); - } - if(personaje1->collidesWithItem(enemigo1)) - { - x = enemigo1->x(); - y = enemigo1->y(); - enemigo1->derecha(); - //bolaFuego->setPosx(personaje1->pos()); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } - //-------EVALUAR COALISIONES CON MUROS----- - for (int i=0;icollidesWithItem(muros.at(i))) - { + } + if (letra=='D') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + //--------------------------GIRO DEL PERSONAJE 1(D)--------------- + personaje1->setTransformOriginPoint(0,0); + personaje1->setRotation(0); + personaje1->derecha(); + //---------------------------COALISIONES 1(D)---------------------------- - personaje1->izquierda(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- + if(personaje1->collidesWithItem(bolaH)) - for (int i=0;icollidesWithItem(piedras.at(i))) - { + { + bolaH->derecha(); + } + if(personaje1->collidesWithItem(enemigo1)) - personaje1->derecha(); - } - } + { + x = enemigo1->x(); + y = enemigo1->y(); + resorte('D', personaje1); + //bolaFuego->setPosx(personaje1->pos()); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); + + timer->start(30); + } - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); + /*for (int i=0;icollidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } + }*/ + //----------------------EVALUAR COALISIONES CON MUROS 1(D)------------------ + for (int i=0;icollidesWithItem(muros.at(i))) + { - //llaves+=1; - } + personaje1->izquierda(); + } + } + //----------------------EVALUAR COALISIONES CON PIEDRAS 1(D)---------------------- - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->izquierda(); - //remover escena - } + for (int i=0;icollidesWithItem(piedras.at(i))) + { + + personaje1->izquierda(); + } + } + + //----------------------------CAPTURAR LLAVES 1(D)---------------------------------- + if (personaje1->collidesWithItem(llave)) + { + //key->play(); + scene->removeItem(llave); + //llaves+=1; } - else if(evento->key()==Qt::Key_W) - { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + //--------------------------PUERTA 1(D)------------------------------ + if (personaje1->collidesWithItem(puerta)) + { + personaje1->izquierda(); + //remover escena + } + } + if (letra=='W') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - //---------GIRO DE PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(270); - personaje1->subir(); + //-------------------------GIRO DE PERSONAJE 1(W)----------------------- + personaje1->setTransformOriginPoint(0,0); + personaje1->setRotation(270); + personaje1->subir(); - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->subir(); - } - if(personaje1->collidesWithItem(enemigo1)) - { - enemigo1->subir(); + //----------------------------COALISIONES 1(W)-------------------------------- + if(personaje1->collidesWithItem(bolaH)) + { + bolaH->subir(); + } + if(personaje1->collidesWithItem(enemigo1)) - x = enemigo1->x(); - y = enemigo1->y(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); - scene->addItem(cuerpos.back()); + { + resorte('W', personaje1); - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } - //-------EVALUAR COALISIONES CON MUROS----- - for (int i=0;icollidesWithItem(muros.at(i))) - { + x = enemigo1->x(); + y = enemigo1->y(); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); - personaje1->bajar(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- + timer->start(30); + } + /*for (int i=0;icollidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } + }*/ + //----------------EVALUAR COALISIONES CON MUROS 1(W))----------------------- + for (int i=0;icollidesWithItem(muros.at(i))) + { - for (int i=0;icollidesWithItem(piedras.at(i))) - { - personaje1->derecha(); - } - } + personaje1->bajar(); + } + } + //-------------------EVALUAR COALISIONES CON PIEDRAS 1(W)--------------------- - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); + for (int i=0;icollidesWithItem(piedras.at(i))) + { - //llaves+=1; + personaje1->bajar(); + } + } - } + //-----------------------------CAPTURAR LLAVES 1(W)---------------------------- + if (personaje1->collidesWithItem(llave)) + { + //key->play(); + scene->removeItem(llave); - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->bajar(); - //remover escena - } + //llaves+=1; + } + //-----------------------------------PUERTA 1(W)------------------------------- + if (personaje1->collidesWithItem(puerta)) + { + personaje1->bajar(); + //remover escena } - else if(evento->key()==Qt::Key_S) - { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - //---------GIRO DE PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(90); - personaje1->bajar(); + } + if (letra=='S') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->bajar(); - } - if(personaje1->collidesWithItem(enemigo1)) + //---------------------------GIRO DE PERSONAJE 1(S)--------------------------- + personaje1->setTransformOriginPoint(0,0); + personaje1->setRotation(90); + personaje1->bajar(); - { + //------------------------------COALISIONES 1(S)----------------------------- + if(personaje1->collidesWithItem(bolaH)) + { + bolaH->bajar(); + } + if(personaje1->collidesWithItem(enemigo1)) - x = enemigo1->x(); - y = enemigo1->y(); - enemigo1->bajar(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); - timer->start(30); - } - for (int i=0;ix(); + y = enemigo1->y(); + resorte('S', personaje1); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); + + timer->start(30); + } + /*for (int i=0;icollidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } + } + */ + //-----------------------EVALUAR COALISIONES CON MUROS 1(S)---------------- + + for (int i=0;icollidesWithItem(muros.at(i))) { - if (personaje1->collidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } - //-------EVALUAR COALISIONES CON MUROS----- + personaje1->subir(); + } + } + //----------------------EVALUAR COALISIONES CON PIEDRAS 1(S)--------------- - for (int i=0;icollidesWithItem(muros.at(i))) + if (personaje1->collidesWithItem(piedras.at(i))) { personaje1->subir(); } } - //-------EVALUAR COALISIONES CON PIEDRAS----- - for (int i=0;icollidesWithItem(piedras.at(i))) - { + //--------------------------CAPTURAR LLAVES 1(S)------------------------- + if (personaje1->collidesWithItem(llave)) + { + //key->play(); + scene->removeItem(llave); - personaje1->derecha(); - } - } + //llaves+=1; - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); + } - //llaves+=1; + //-------------------------PUERTA 1(S)----------------------------------- + if (personaje1->collidesWithItem(puerta)) + { + personaje1->subir(); + //remover escena } - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->subir(); - //remover escena - } + } - } + } + if (personaje==personaje2) + { - if ((personaje1->x()==250 and personaje1->y()==390) ) - { + if (letra=='I') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + //-------------------GIRO DE PERSONAJE 2(I)------------------- + personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(270); + personaje2->subir(); - niveles(3); - } + //--------------------------COALISIONES 2(I)------------------------ -} -if (opcion==3) -{ + if(personaje2->collidesWithItem(bolaH)) + { + bolaH->subir(); + } + if(personaje2->collidesWithItem(enemigo1)) - if(evento->key()==Qt::Key_A) { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + resorte('I', personaje2); - //---------GIRO DEL PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(180); - personaje1->izquierda(); + x = enemigo1->x(); + y = enemigo1->y(); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->izquierda(); + timer->start(30); } - if(personaje1->collidesWithItem(enemigo1)) - + /*for (int i=0;iizquierda(); - x = enemigo1->x(); - y = enemigo1->y(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); - - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) { - if (personaje1->collidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; } - //-------EVALUAR COALISIONES CON MUROS----- + }*/ + //-----------------------------EVALUAR COALISIONES CON MUROS 2(I)------------------ + for (int i=0;icollidesWithItem(muros.at(i))) - { - - personaje1->izquierda(); - } - } + if (personaje2->collidesWithItem(muros.at(i))) + { - //-------EVALUAR COALISIONES CON PIEDRAS----- + personaje2->bajar(); + } + } + //-------------------------------EVALUAR COALISIONES CON PIEDRAS 2(I)-------------- for (int i=0;icollidesWithItem(piedras.at(i))) - { - - personaje1->derecha(); - } - } + { + if (personaje2->collidesWithItem(piedras.at(i))) + { - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); + personaje2->bajar(); + } + } + //------------------------------------CAPTURAR LLAVES 2(I)-------------------- - //llaves+=1; + if (personaje2->collidesWithItem(llave)) + { + //key->play(); + scene->removeItem(llave); - } + //llaves+=1; - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { + } - personaje1->derecha(); - //remover escena - } + //------------------------------------PUERTA 2(I)---------------------------------- + if (personaje2->collidesWithItem(puerta)) + { + personaje2->bajar(); + //remover escena + } } - else if(evento->key()==Qt::Key_D) + if (letra=='J') { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); //---------GIRO DEL PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(0); - personaje1->derecha(); + personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(180); + personaje2->izquierda(); + - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) + //------------------------COALISIONES 2(J)---------------------------------- + if(personaje2->collidesWithItem(bolaH)) { - bolaH->derecha(); + bolaH->izquierda(); } - if(personaje1->collidesWithItem(enemigo1)) + if(personaje2->collidesWithItem(enemigo1)) { - x = enemigo1->x(); - y = enemigo1->y(); - enemigo1->derecha(); - //bolaFuego->setPosx(personaje1->pos()); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); + resorte('J', personaje2); + x = enemigo1->x(); + y = enemigo1->y(); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); - timer->start(30); + timer->start(30); } - - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } + if (personaje2->collidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; } - //-------EVALUAR COALISIONES CON MUROS----- + }*/ + //-----------------------EVALUAR COALISIONES CON MUROS 2(J)--------------------- for (int i=0;icollidesWithItem(muros.at(i))) - { + if (personaje2->collidesWithItem(muros.at(i))) + { + personaje2->derecha(); + } + } - personaje1->izquierda(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- + //-------------------------EVALUAR COALISIONES CON PIEDRAS 2(J)-------------- for (int i=0;icollidesWithItem(piedras.at(i))) - { - - personaje1->derecha(); - } - } + { + if (personaje2->collidesWithItem(piedras.at(i))) + { - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); + personaje2->derecha(); + } + } + //----------------------------CAPTURAR LLAVES 2(J)----------------------- - //llaves+=1; + if (personaje2->collidesWithItem(llave)) + { + //key->play(); + scene->removeItem(llave); - } - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->izquierda(); - //remover escena - } + //llaves+=1; + } + //----------------------------------PUERTA 2(J)------------------------------- - } - else if(evento->key()==Qt::Key_W) + if (personaje2->collidesWithItem(puerta)) { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - - //---------GIRO DE PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(270); - personaje1->subir(); - - - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->subir(); + personaje2->derecha(); + //remover escena } - if(personaje1->collidesWithItem(enemigo1)) - { - enemigo1->subir(); - x = enemigo1->x(); - y = enemigo1->y(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } - //-------EVALUAR COALISIONES CON MUROS----- - for (int i=0;icollidesWithItem(muros.at(i))) - { - personaje1->derecha(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- - for (int i=0;icollidesWithItem(piedras.at(i))) - { - personaje1->derecha(); - } - } + } - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); - //llaves+=1; + if (letra=='L') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); - } + //---------GIRO DEL PERSONAJE------- + personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(0); + personaje2->derecha(); - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->bajar(); - //remover escena - } + //-------------------------------COALISIONES 2(L) -------------------------------- + if(personaje2->collidesWithItem(bolaH)) + { + bolaH->derecha(); + } + if(personaje2->collidesWithItem(enemigo1)) + { + x = enemigo1->x(); + y = enemigo1->y(); + resorte('L', personaje2); + //bolaFuego->setPosx(personaje1->pos()); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); + + timer->start(30); } - else if(evento->key()==Qt::Key_S) - { - //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + /* + for (int i=0;icollidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } + }*/ + //------------------------EVALUAR COALISIONES CON MUROS 2(L)-------------------------- + for (int i=0;icollidesWithItem(muros.at(i))) + { - //---------GIRO DE PERSONAJE------- - personaje1->setTransformOriginPoint(0,0); - personaje1->setRotation(90); - personaje1->bajar(); + personaje2->izquierda(); + } + } + //---------------------EVALUAR COALISIONES CON PIEDRAS 2(L)---------------------------- - //---------COALISIONES------- - if(personaje1->collidesWithItem(bolaH)) - { - bolaH->bajar(); - } - if(personaje1->collidesWithItem(enemigo1)) + for (int i=0;icollidesWithItem(piedras.at(i))) + { + personaje2->izquierda(); + } + } - { + //------------------------------CAPTURAR LLAVES 2(L)-------------------------------- - x = enemigo1->x(); - y = enemigo1->y(); - enemigo1->bajar(); - cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); + if (personaje2->collidesWithItem(llave)) + { + //key->play(); + scene->removeItem(llave); - timer->start(30); - } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } - } - - //-------EVALUAR COALISIONES CON MUROS----- - - for (int i=0;icollidesWithItem(muros.at(i))) - { - - personaje1->subir(); - } - } - //-------EVALUAR COALISIONES CON PIEDRAS----- - - for (int i=0;icollidesWithItem(piedras.at(i))) - { - - personaje1->derecha(); - } - } - - //-------CAPTURAR LLAVES----- - if (personaje1->collidesWithItem(llave)) - { - //key->play(); - scene->removeItem(llave); - - //llaves+=1; - - } - - //------------PUERTA-------------- - if (personaje1->collidesWithItem(puerta)) - { - personaje1->subir(); - //remover escena - } - - - - - - } - -// qDebug()<pos()<x(); - - - if ((personaje1->x()==250 and personaje1->y()==390) ) - { - - - - //niveles(3); - - } - -} -} - - - - -MainWindow::~MainWindow() -{ - delete ui; -} + //llaves+=1; + } -void MainWindow::mover() -{ - for (QList :: iterator it=cuerpos.begin(); it!=cuerpos.end(); it++) + //-------------------------------------PUERTA 2(L)----------------------------- + if (personaje2->collidesWithItem(puerta)) { - (*it)->CalcularVelocidad(); - (*it)->ActualizarPosicion(); - - + personaje2->izquierda(); + //remover escena } - for (int i=0;icollidesWithItem(cuerpos.at(i))) - { - scene->removeItem(cuerpos.at(i)); - cuerpos.removeOne(cuerpos.at(i)); - //vidas-=1; - } } -} - -void MainWindow::botonInicio() -{ - opcion=1; - niveles(opcion); -} + if (letra=='K') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); -void MainWindow::guardarPartida() -{ - QFile archivo("PLANETAS.txt"); - if(archivo.open(QIODevice::Append | QIODevice::Text)){ - QTextStream datosArchivo(&archivo); + //---------------------------------GIRO DE PERSONAJE 2(K)---------------------- + personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(90); + personaje2->bajar(); - //datosArchivo << text<< endl; - } - archivo.close(); -} + //----------------------------------COALISIONES 2(K)-------------------------------- -void MainWindow:: lanzamiento () -{ /*int xinicial,xfinal,yinicial,yfinal; - xinicial=enemigo1->getPosx(); - xfinal=personaje1->getPosx(); - yinicial=enemigo1->getPosy(); - yfinal=personaje1->getPosy(); - while ((xinicial!=xfinal) or (yinicial!=yfinal)) - { + if(personaje2->collidesWithItem(bolaH)) + { + bolaH->bajar(); + } + if(personaje2->collidesWithItem(enemigo1)) - if (xinicialx(); + y = enemigo1->y(); + resorte('K', personaje2); + //cuerpos.push_back(new Particula (0, x, y ,100,10,":/IMAGENES/BOLA DE FUEGO.png")); + //scene->addItem(cuerpos.back()); - } + timer->start(30); + } + /*for (int i=0;icollidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } + } + */ + //--------------------------EVALUAR COALISIONES CON MUROS 2(K)-------------------------- - if (yinicial>yfinal) - { - yinicial--; + for (int i=0;icollidesWithItem(muros.at(i))) + { - } + personaje2->subir(); + } + } + //-----------------------------EVALUAR COALISIONES CON PIEDRAS 2(K)---------------------- + for (int i=0;icollidesWithItem(piedras.at(i))) + { - path++; - } - //cout<<" PATH: "<<"( "<subir(); + } + } - else - if(xinicial>xfinal) + //-----------------------------CAPTURAR LLAVES 2(K)------------------------------------ + if (personaje2->collidesWithItem(llave)) + { + //key->play(); + scene->removeItem(llave); - { + //llaves+=1; - xinicial--; - if(yinicialyfinal) - { - yinicial--; + //------------------------------PUERTA 2(K)------------------------------------------ - } + if (personaje2->collidesWithItem(puerta)) + { + personaje2->subir(); + //remover escena + } - path++; - } - if(path%10==0) - {if (i==1) - { - bolaFuego->setPos(xinicial,yinicial); - scene->addItem(bolaFuego); - } - if(i==100) - { - bolaFuego->setPos(xinicial,yinicial); - scene->addItem(bolaFuego); - i=0; - } - i++; - } } + } - - -*/ } -void MainWindow::lanzarfuego() -{ -/*if (opcion==1){ - x = enemigo1->x(); - y = enemigo1->y(); - cuerpos.push_back(new Particula (0,x, y,100,30,":/IMAGENES/BOLADEFUEGO.png")); - scene->addItem(cuerpos.back()); +//------------------------------------------------------NIVELES-------------------------------------------------- - timer->start(30); -}*/ +void MainWindow::botonInicio() +{ + opcion=1; + niveles(opcion); } - void MainWindow:: niveles(int opcion) { if (opcion==0) @@ -1196,11 +961,20 @@ void MainWindow:: niveles(int opcion) scene = new QGraphicsScene; ui->graphicsView->setScene(scene); + /*QMovie *movie= new QMovie (":/IMAGENES/MENU.gif"); + label->setMovie(movie); + movie->start(); + */ + /* QMovie *movie= new QMovie (":/IMAGENES/MENU.gif"); + label = new QLabel(this); + label->setMovie(movie); + movie->start();*/ + scene->setBackgroundBrush(QPixmap(":/IMAGENES/MAINMENU.png")); scene->setSceneRect(0,0,790,550); intro=new QMediaPlayer (); - intro->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/action.mp3")); + intro->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/fantasy.mp3")); //intro->play(); @@ -1222,11 +996,14 @@ void MainWindow:: niveles(int opcion) connect(cronometro, SIGNAL(timeout()),this,SLOT(lanzarfuego())); cronometro->start(1000); - QTimer *cronometro2 = new QTimer(this); - connect(cronometro2, SIGNAL(timeout()),this,SLOT(lanzamiento())); - cronometro2->start(1000); - + /* QTimer *cronometro2 = new QTimer(this); + connect(cronometro2, SIGNAL(timeout()),this,SLOT(magnetismo())); + cronometro2->start(1000);*/ + /* parabolico= new QTimer; + parabolico->stop(); + connect(parabolico,SIGNAL(timeout()),this,SLOT(Mover())); + parabolico->start(40);*/ //CREANDO LA ESCENA ui->setupUi(this); scene = new QGraphicsScene; @@ -1236,11 +1013,36 @@ void MainWindow:: niveles(int opcion) - personaje1=new Personaje(495,410,30,2, ":/IMAGENES/PERSONAJE1.png"); - scene->addItem(personaje1); + //x,y ,r,friccion,a,v,ang,path + personaje1=new Personaje(495,410,30,1,10, ":/IMAGENES/PERSONAJE1.png"); + scene->addItem(personaje1); + + personaje2=new Personaje(0,0,45,1,10, ":/IMAGENES/PERSONAJE2.png"); + scene->addItem(personaje2); + + enemigo1= new Personaje (-105,310,60,1,5,":/IMAGENES/ENEMIGO.png"); //antes -105, 310 + scene->addItem(enemigo1); + + timerEnem= new QTimer; + timerEnem->stop(); + connect(timerEnem, SIGNAL(timeout()), this , SLOT (moverEnemigo())); + timerEnem->start(40); + + rigidez=20; + + //particula1=new Particula( -105,310,0,0,50000,200, ":/IMAGENES/BOLADEMETAL.png "); + //particula2=new Particula(-5000,0,0,0,70,70 ,":/IMAGENES/BOLA DE FUEGO.png "); + + + + + + /* disparo=new QTimer; + disparo->stop(); + connect(disparo, SIGNAL(timeout()), this , SLOT (lanzamiento)); + disparo->start(1000);*/ + - enemigo1= new Personaje (0,0,60,2,":/IMAGENES/ENEMIGO.png"); - scene->addItem(enemigo1); @@ -1270,16 +1072,22 @@ void MainWindow:: niveles(int opcion) QTimer *cronometro = new QTimer(this); connect(cronometro, SIGNAL(timeout()),this,SLOT(lanzarfuego())); cronometro->start(1000); - + /* parabolico= new QTimer; + parabolico->stop(); + connect(parabolico,SIGNAL(timeout()),this,SLOT(Mover())); + parabolico->start(40); QTimer *cronometro2 = new QTimer(this); connect(cronometro2, SIGNAL(timeout()),this,SLOT(lanzamiento())); - cronometro2->start(1000); - timer->start(); - personaje1=new Personaje(495,410,30,1, ":/IMAGENES/PERSONAJE1.png"); + cronometro2->start(1000);*/ + timer->start(); //x,y ,r,friccion,a,v,ang,path + personaje1=new Personaje(495,410,30,1.5,0, ":/IMAGENES/PERSONAJE1.png"); scene->addItem(personaje1); - enemigo1= new Personaje (-135,415,60,1,":/IMAGENES/ENEMIGO.png"); - scene->addItem(enemigo1); + enemigo1= new Personaje (-135,415,60,1.5,0, ":/IMAGENES/ENEMIGO.png"); + scene->addItem(enemigo1); + + + rigidez=40; @@ -1307,21 +1115,25 @@ void MainWindow:: niveles(int opcion) QTimer *cronometro = new QTimer(this); connect(cronometro, SIGNAL(timeout()),this,SLOT(lanzarfuego())); cronometro->start(1000); - + /* parabolico= new QTimer; + parabolico->stop(); + connect(parabolico,SIGNAL(timeout()),this,SLOT(Mover())); + parabolico->start(40); QTimer *cronometro2 = new QTimer(this); connect(cronometro2, SIGNAL(timeout()),this,SLOT(lanzamiento())); - cronometro2->start(1000); - timer->start(); - personaje1=new Personaje(495,410,30,0.5, ":/IMAGENES/PERSONAJE1.png"); + cronometro2->start(1000);*/ + timer->start(); //x,y ,r,friccion,a,v,ang,path + personaje1=new Personaje(495,410,30,1.2, 1, ":/IMAGENES/PERSONAJE1.png"); scene->addItem(personaje1); - enemigo1= new Personaje (395,210,60,0.5,":/IMAGENES/SERPIENTE1 (1).png"); + enemigo1= new Personaje (395,210,60,1.5,1,":/IMAGENES/SERPIENTE1(1).png"); scene->addItem(enemigo1); - totem= new Personaje (0,0,60 ,0.5, ":/IMAGENES/TOTEM ARENA.png"); + totem= new Personaje (0,0,60 ,1,1.5, ":/IMAGENES/TOTEMARENA.png"); scene->addItem(totem); timer->start(); + rigidez=80; items(); @@ -1329,39 +1141,6 @@ void MainWindow:: niveles(int opcion) } -void MainWindow::clean() -{ - scene->removeItem(enemigo1); - delete (enemigo1); - scene->removeItem(personaje1); - delete (personaje1); - - - for (int i=0;iremoveItem(cuerpos.at(i)); - delete (cuerpos.at (i)); - cuerpos.removeOne(cuerpos.at(i)); - - - - } - for (int i=0;iremoveItem(piedras.at(i)); - delete (piedras.at (i)); - piedras.removeOne(piedras.at(i)); - - } - - - - scene->removeItem(puerta); - delete (puerta); -} - - void MainWindow::items() { @@ -1411,5 +1190,328 @@ void MainWindow::items() } +void MainWindow::clean() +{ + scene->removeItem(enemigo1); + delete (enemigo1); + scene->removeItem(personaje1); + delete (personaje1); + + + /*for (int i=0;iremoveItem(cuerpos.at(i)); + delete (cuerpos.at (i)); + cuerpos.removeOne(cuerpos.at(i)); + + }*/ + for (int i=0;iremoveItem(piedras.at(i)); + delete (piedras.at (i)); + piedras.removeOne(piedras.at(i)); + + } + + + + scene->removeItem(puerta); + delete (puerta); +} + +void MainWindow::guardarPartida() +{ + QFile archivo("PLANETAS.txt"); + if(archivo.open(QIODevice::Append | QIODevice::Text)){ + QTextStream datosArchivo(&archivo); + + + //datosArchivo << text<< endl; + + } + archivo.close(); +} + + +//--------------------------------------------------FISICAS-------------------------------------------------- + + +void MainWindow::CoeficienteRestitucion() +{ + +} + +void MainWindow::aceleracion(int) +{ + +} +void MainWindow:: lanzamiento () +{ + + /* int xinicial=0; + int xfinal=personaje1->x(); + int yinicial=0; + int yfinal=personaje1->y(); + + while ((xinicial!=xfinal) or (yinicial!=yfinal)) + { + + if (xinicialyfinal) + { + yinicial--; + + } + + path++; + } + //cout<<" PATH: "<<"( "<xfinal) + + { + + xinicial--; + if(yinicialyfinal) + { + yinicial--; + + } + + + path++; + } + if(path%10==0) + {if (i==1) + { + bolaFuego->setPos(xinicial,yinicial); + scene->addItem(bolaFuego); + timer->start(30); + + } + + if(i==100) + { + bolaFuego->setPos(xinicial,yinicial); + scene->addItem(bolaFuego); + i=0; + timer->start(30); + } + + i++; + +} + } +*/ + + +} + + +void MainWindow::lanzarfuego() +{if (opcion==1){ + x = enemigo1->x(); + y = enemigo1->y(); + cuerpos.push_back(new Particula (0,x, y,100,30,":/IMAGENES/BOLADEFUEGO.png")); + scene->addItem(cuerpos.back()); + timer->start(30); +} + +} +void MainWindow::mover() +{ + for (QList :: iterator it=cuerpos.begin(); it!=cuerpos.end(); it++) + { + (*it)->CalcularVelocidad(); + (*it)->ActualizarPosicion(); + + + } + for (int i=0;icollidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } + + } + for (int i=0;icollidesWithItem(cuerpos.at(i))) + { + scene->removeItem(cuerpos.at(i)); + cuerpos.removeOne(cuerpos.at(i)); + //vidas-=1; + } + + } +} + +void MainWindow::resorte(char letra , Personaje *personaje) +{ + if (personaje==personaje1) + { + + if (letra=='A') + {personaje1-> setPos(personaje1->x()+5*rigidez,personaje1->y()); + } + if (letra=='D') + {personaje1-> setPos(personaje1->x()-5*rigidez,personaje1->y()); + } + if (letra=='W') + {personaje1->setPos(personaje1->x(),personaje1->y()+5*rigidez); + } + if(letra=='S') + {personaje1->setPos(personaje1->x(),personaje1->y()-5*rigidez); + } + } + + if(personaje==personaje2) + {if(letra=='J') + {personaje2-> setPos(personaje2->x()+5*rigidez,personaje2->y()); + } + if(letra=='L') + {personaje2-> setPos(personaje2->x()-5*rigidez,personaje2->y()); + } + if(letra=='I') + {personaje2->setPos(personaje2->x(),personaje2->y()+5*rigidez); + } + if(letra=='K') + {personaje2->setPos(personaje2->x(),personaje2->y()-5*rigidez); + } + } +} + +void MainWindow::magnetismo() +{ + /*if (opcion==1) + {float f, dx, dy,r; + dx=enemigo1->x()-personaje1->x(); + dy=enemigo1->x()-personaje1->x(); + r=pow(dx,2)+pow(dy,2); + f=(M*M)/(K*pow(r,2)); + x = enemigo1->x()*f; + y = enemigo1->y()*f; + bolaFuego->setPos(x,y); + scene->addItem(bolaFuego); + timer->start(30); + }*/ +} + +void MainWindow::Mover() +{/* + for(QList::iterator it=cuerpos.begin(); it!=cuerpos.end();it++) + { + (*it)->CalcularVelicidad(); + (*it)->ActualizarPosicion(); + } + double ang,x,y,v,a; + ang= enemigo1->angulo; + x= enemigo1->posx; + y= enemigo1->posy; + v= enemigo1->velocidad; + a= (ang/180)*3.1416; + cuerpos.push_back(new particula(rad, x, y, v)); + scene->addItem(cuerpos.back()); + //cuerpo= new particula(rad, x, y, v); + //Scene->addItem(cuerpo); + timer->start(30);*/ + +} + +void MainWindow::moverEnemigo( ) +{ +/* + if(ban==false) + {enemigo1->setX(enemigo1->x()+2); + if(enemigo1->x()<100) + {enemigo1->setX(enemigo1->x()+2*enemigo1->aceleracion+2);} + else if (enemigo1->x()<300) + {enemigo1->setX(enemigo1->x()+2*enemigo1->aceleracion);} + else if (enemigo1->x()<500) + {enemigo1->setX(enemigo1->x()+2*enemigo1->aceleracion+1);} + else if(enemigo1->x()>514) + {ban=true; + } + } + if(ban==true) + {enemigo1->setX(enemigo1->x()-2); + if(enemigo1->x()<100) + {enemigo1->setX(enemigo1->x()-2*enemigo1->aceleracion+2);} + else if (enemigo1->x()<300) + {enemigo1->setX(enemigo1->x()-2*enemigo1->aceleracion);} + else if (enemigo1->x()<500) + {enemigo1->setX(enemigo1->x()-2*enemigo1->aceleracion+1);} + if(enemigo1->x()<-116) + {ban=false; + } + } + +*/ +} + + + +//-------------------------------------------------DESTRUCTOR--------------------------------------------------------------- + + +MainWindow::~MainWindow() +{ + delete ui; + +} + + + +void MainWindow::actualizar() +{ + + + /*for (int i=0; i Acacelx(*(particula2)); + + // LISTA.at(i)-> Acacely(*(LISTA.at(j) )); + } + } + } + for(int i=0;iActualizar(); + particula1->Actualizar(particula1); + particula1->Actualizar(particula2); + + + }*/ + //actualiza cada dato + + + +//actualiza cada dato +} + diff --git a/DOCUMENTACION/Juego/mainwindow.h b/DOCUMENTACION/Juego/mainwindow.h index dde3d63..e289712 100644 --- a/DOCUMENTACION/Juego/mainwindow.h +++ b/DOCUMENTACION/Juego/mainwindow.h @@ -17,6 +17,9 @@ #include #include #include +#include + +#define K 0.00000001 QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; @@ -34,15 +37,26 @@ class MainWindow : public QMainWindow //QList muros; QList muros; QList piedras; + QList cuerpos; private slots: //SLOTS DE LA PARTÍCULA + + + /*double masa; + double posx; + double posy; + double radio; + double vx; + double vy;*/ + void mover(); + void actualizar(); - void lanzamiento (int xi, int xf, int yi, int yf); + void lanzamiento (); void lanzarfuego(); @@ -50,6 +64,18 @@ private slots: void botonInicio(); + void moverEnemigo(); + + void CoeficienteRestitucion(); + + void coaliciones (char , Personaje *personaje ); + + void magnetismo(); + + void Mover(); + + void resorte(char letter,Personaje *personaje); + private: Ui::MainWindow *ui; @@ -61,27 +87,40 @@ private slots: //PARTÍCULA + QTimer *timerEnem; QTimer *timer; - Particula *cuerpo; + QTimer *Timer; + QTimer *disparo; + QTimer *parabolico; + QLabel *label; + /*Particula *cuerpo; QListcuerpos; + QListLISTA;*/ //OBJETOS //Personaje *personaje1; Personaje *enemigo1; Personaje *totem; Personaje *personaje1; + Personaje *personaje2; Personaje *lanzador; Sprite *dragon; Objeto *puerta; Objeto *bolaH; - Objeto *bolaFuego; Objeto *llave; + QObject *personaje; + //particula *cuerpo; double x; double y; int opcion=0; int nivel=0; + int i=0; + int rigidez=0; + //____ prueba + /*Particula *particula1; + Particula *particula2;*/ // Sprite *personaje1; void keyPressEvent(QKeyEvent * evento); @@ -90,9 +129,13 @@ private slots: void niveles(int); + void aceleracion(int); + void clean (); + int path=0; + bool ban=false; QPushButton *start; QPushButton *saveData; diff --git a/instrucciones.cpp b/instrucciones.cpp new file mode 100644 index 0000000..9038f78 --- /dev/null +++ b/instrucciones.cpp @@ -0,0 +1,14 @@ +#include "instrucciones.h" +#include "ui_instrucciones.h" + +Instrucciones::Instrucciones(QWidget *parent) : + QDialog(parent), + ui(new Ui::Instrucciones) +{ + ui->setupUi(this); +} + +Instrucciones::~Instrucciones() +{ + delete ui; +} diff --git a/instrucciones.h b/instrucciones.h new file mode 100644 index 0000000..72d1694 --- /dev/null +++ b/instrucciones.h @@ -0,0 +1,22 @@ +#ifndef INSTRUCCIONES_H +#define INSTRUCCIONES_H + +#include + +namespace Ui { +class Instrucciones; +} + +class Instrucciones : public QDialog +{ + Q_OBJECT + +public: + explicit Instrucciones(QWidget *parent = 0); + ~Instrucciones(); + +private: + Ui::Instrucciones *ui; +}; + +#endif // INSTRUCCIONES_H diff --git a/instrucciones.ui b/instrucciones.ui new file mode 100644 index 0000000..d3fb526 --- /dev/null +++ b/instrucciones.ui @@ -0,0 +1,69 @@ + + + Instrucciones + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 15 + 10 + 371 + 281 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INSTRUCCIONES</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INTRODUCCIÓN</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Escape medieval es un juego en el que se pueden participar 1 ó 2 jugadores .</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Los hechos se desarrollan en el castillo Alcázar de Segovia cuando un excéntrico aventurero trata de investigar este templo medieval , allí bajo un extraño acontecimiento se pierde en su interior , por lo tanto debe reunír todas las llaves para poder escapar mientras enfrenta a los monstruos que hay en su interior.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">COMO JUGAR </p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">El jugador debe eleigr un nombre , una contraseña y un modo de juego (multi jugador ó un solo jugador)</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Al registrarse deberá acceder .</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Para mover al personaje 1 , use las las teclas :</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A= IZQUIERDA</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">D=DERECHA</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">W=ARRIBA</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">S=ABAJO</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Para mover al personaje 2 , use las teclas :</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">J=IZQUIERDA</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">L=DERECHA</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">I=ARRIBA</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">K=ABAJO</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Para un solo jugador :</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Capture todas las llaves para desbloquear la puerta final</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">En modo multijugador :</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Capture todas las llaves para desbloquear la puerta final en un tiempo máximo de 5 minutos</p></body></html> + + + + + + diff --git a/llaves.cpp b/llaves.cpp new file mode 100644 index 0000000..4874abc --- /dev/null +++ b/llaves.cpp @@ -0,0 +1,33 @@ +#include "llaves.h" + +#include + +llaves::llaves(QGraphicsItem *parent): QGraphicsTextItem(parent) +{ + //inicializar las llaves en 0 + key = 0; + + //ESCRIBIR EL TEXTO + setPlainText(QString("Llaves: ")+QString::number(key)); + setDefaultTextColor(Qt::red); + setFont(QFont("times",16)); + +} + +void llaves::increase() +{ + key++; + setPlainText(QString("Llaves: ")+QString::number(key)); + +} + +int llaves::getkey() +{ + return key; +} + +void llaves::setKey(int value) +{ + key = value; + setPlainText(QString("Llaves: ")+QString::number(key)); +} diff --git a/llaves.h b/llaves.h new file mode 100644 index 0000000..67aa3ff --- /dev/null +++ b/llaves.h @@ -0,0 +1,23 @@ +#ifndef LLAVES_H +#define LLAVES_H + +#include + + +class llaves: public QGraphicsTextItem +{ + +public: + + llaves(QGraphicsItem * parent=0); + + void increase(); + int getkey(); + void setKey(int value); + +private: + + int key; +}; + +#endif // LLAVES_H diff --git a/lose.cpp b/lose.cpp new file mode 100644 index 0000000..0e1eeb7 --- /dev/null +++ b/lose.cpp @@ -0,0 +1,14 @@ +#include "lose.h" +#include "ui_lose.h" + +Lose::Lose(QWidget *parent) : + QDialog(parent), + ui(new Ui::Lose) +{ + ui->setupUi(this); +} + +Lose::~Lose() +{ + delete ui; +} diff --git a/lose.h b/lose.h new file mode 100644 index 0000000..0c8de67 --- /dev/null +++ b/lose.h @@ -0,0 +1,22 @@ +#ifndef LOSE_H +#define LOSE_H + +#include + +namespace Ui { +class Lose; +} + +class Lose : public QDialog +{ + Q_OBJECT + +public: + explicit Lose(QWidget *parent = 0); + ~Lose(); + +private: + Ui::Lose *ui; +}; + +#endif // LOSE_H diff --git a/lose.ui b/lose.ui new file mode 100644 index 0000000..4d94207 --- /dev/null +++ b/lose.ui @@ -0,0 +1,46 @@ + + + Lose + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 10 + 10 + 371 + 271 + + + + + + + 60 + 110 + 256 + 61 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:28pt;">PERDISTE</span></p></body></html> + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..91af976 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,2829 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + //intro->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/fantasy.mp3")); + +ui->setupUi(this); +scene = new QGraphicsScene; +ui->graphicsView->setScene(scene); +if(llavesL.size()==0) +{llavesL.push_back(new Objeto (-65,220,30,":/I/I/llave1.png")); + scene->addItem(llavesL.back()); +llavesL.push_back(new Objeto (470,35,30,":/I/I/llave1.png")); + scene->addItem(llavesL.back()); +llavesL.push_back(new Objeto (480,45,30,":/I/I/llave1.png")); + scene->addItem(llavesL.back()); +llavesL.push_back(new Objeto (490,55,30,":/I/I/llave1.png")); + scene->addItem(llavesL.back()); +llavesL.push_back(new Objeto (10,100,30,":/I/I/llave1.png")); + scene->addItem(llavesL.back()); +llavesL.push_back(new Objeto (460,25,30,":/I/I/llave1.png")); + scene->addItem(llavesL.back()); +} +for (int i=0;ihide(); + + } +niveles(opcion,jugadores); + +//--------------------BOTÓN INICIAR JUEGO NUEVO---------------------- + +start=new QPushButton("INICIAR JUEGO NUEVO", this); + +start->setGeometry(QRect( QPoint(310,160), // Valores por defecto 250x160 +QSize(200, 50) )); +//Valores por defecto : 200x 50 + +connect(start, SIGNAL (clicked()),this, SLOT (Iniciar())); +start->setStyleSheet("background-color: gray"); + +//-----------------------BOTÓN INSTRUCCIONES------------------ + +instruccion=new QPushButton (" INSTRUCCIONES ",this); + +instruccion->setGeometry(QRect( QPoint(310,300), +QSize(200, 50) )); + +connect(instruccion, SIGNAL (clicked()),this, SLOT (instrucciones())); +instruccion->setStyleSheet("background-color: gray"); + + +//-----------------------------BOTÓN REGISTRO ------------------ + +registrar=new QPushButton ("REGISTRARSE",this); + +registrar->setGeometry(QRect( QPoint(310,450), +QSize(200, 50) )); + +connect(registrar, SIGNAL (clicked()),this, SLOT (registro())); +registrar ->setStyleSheet("background-color: gray"); + +//-----------------------------BOTÓN GUARDADO ------------------ + +save=new QPushButton ("GUARDAR PARTIDA",this); + +save->setGeometry(QRect( QPoint(0,0), +QSize(200, 50) )); + +connect(save, SIGNAL (clicked()),this, SLOT (guardar())); +save ->setStyleSheet("background-color: gray"); + + + +/*LISTA.append(new Particula(0,0,0,0,50000,200)); +LISTA.append(new Particula(-5000,0,0,0,70,70)); +LISTA.append(new Particula(5000,0,0,0,70,70)); */ //Planetas agregados directamente +// LISTA.append(new Graficar(0,-5000,2,0,70,70)); +//LISTA.append(new Graficar(0,5000,-2,0,70,70)); + + + +} + + +//-------------------------------------------------KEYPRESSEVENT-------------------------------------------------- + +void MainWindow::keyPressEvent(QKeyEvent *evento) +{ + + qDebug()<pos()<x(); + +//-----------------------------------------EVENTO PERSONAJE 1 NIVEL 1------------------------------------------------- + +if (opcion==1) +{ + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + + else if(evento->key()==Qt::Key_D) + { + + coaliciones('D', personaje1); + + } + else if(evento->key()==Qt::Key_W) + { + + coaliciones('W', personaje1); + + } + + else if(evento->key()==Qt::Key_S) + { + + coaliciones('S', personaje1); + } + + +// qDebug()<pos()<x(); + +//-------------------------------------------------EVENTO PERSONAJE 2 NIVEL 1------------------------------------------------------------ +if(evento->key()==Qt::Key_I) +{ + + coaliciones('I', personaje2); + +} +if(evento->key()==Qt::Key_J) +{ + coaliciones('J', personaje2); + + +} +if(evento->key()==Qt::Key_L) +{ + + coaliciones('L', personaje2); + +} +if(evento->key()==Qt::Key_K) +{ + + coaliciones('K', personaje2); + +} +teletransportacion(); +//------------------------------------------------CAMBIO DE NIVEL 1 A 2------------------------------------------------- + +/*if (evento->key()==Qt::Key_2) + //if (((personaje1->x()==200 )and (personaje1->y()==60 )) ) + { + }*/ + +} + +//-----------------------------------------------EVENTO PERSONAJE 1 NIVEL 2------------------------------------------------- + +if (opcion==2) +{ + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + + else if(evento->key()==Qt::Key_D) + { + + coaliciones('D', personaje1); + + } + else if(evento->key()==Qt::Key_W) + { + + coaliciones('W', personaje1); + + } + + else if(evento->key()==Qt::Key_S) + { + + coaliciones('S', personaje1); + } + + +// qDebug()<pos()<x(); + +//-------------------------------------------EVENTO PERSONAJE 2 NIVEL 2------------------------------------------------------------ +if(evento->key()==Qt::Key_I) +{ + + coaliciones('I', personaje2); + +} +if(evento->key()==Qt::Key_J) +{ + coaliciones('J', personaje2); + + +} +if(evento->key()==Qt::Key_L) +{ + + coaliciones('L', personaje2); + +} +if(evento->key()==Qt::Key_K) +{ + coaliciones('K', personaje2); +} +teletransportacion(); +//------------------------------------------------CAMBIO DE NIVEL 2 A 3------------------------------------------------- + +/*if (evento->key()==Qt::Key_3) + { + clean(); + opcion=3; + niveles(opcion); + }*/ + + +} + +//-----------------------------------------------EVENTO PERSONAJE 1 NIVEL 3------------------------------------------------- + +if (opcion==3) +{ + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + + else if(evento->key()==Qt::Key_D) + { + + coaliciones('D', personaje1); + + } + else if(evento->key()==Qt::Key_W) + { + + coaliciones('W', personaje1); + + } + + else if(evento->key()==Qt::Key_S) + { + + coaliciones('S', personaje1); + } + + +//---------------------------------------------EVENTO PERSONAJE 2 NIVEL 3------------------------------------------------------------ + +if(evento->key()==Qt::Key_I) +{ + + coaliciones('I', personaje2); + +} +if(evento->key()==Qt::Key_J) +{ + coaliciones('J', personaje2); + + +} +if(evento->key()==Qt::Key_L) +{ + + coaliciones('L', personaje2); + +} +if(evento->key()==Qt::Key_K) +{ + + coaliciones('K', personaje2); + +} + +teletransportacion(); + + +} +//-----------------------------------------------EVENTO PERSONAJE 1 NIVEL 4------------------------------------------------- + +if (opcion==4) +{ + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + + else if(evento->key()==Qt::Key_D) + { + + coaliciones('D', personaje1); + + } + else if(evento->key()==Qt::Key_W) + { + + coaliciones('W', personaje1); + + } + + else if(evento->key()==Qt::Key_S) + { + + coaliciones('S', personaje1); + } + + //---------------------------------------------EVENTO PERSONAJE 2 NIVEL 4------------------------------------------------------------ + + if(evento->key()==Qt::Key_I) + { + + coaliciones('I', personaje2); + + } + if(evento->key()==Qt::Key_J) + { + coaliciones('J', personaje2); + + + } + if(evento->key()==Qt::Key_L) + { + + coaliciones('L', personaje2); + + } + if(evento->key()==Qt::Key_K) + { + + coaliciones('K', personaje2); + + } + teletransportacion(); + /*if (evento->key()==Qt::Key_5) + { + clean(); + opcion=5; + niveles(5); + }*/ +} +//-----------------------------------------------EVENTO PERSONAJE 1 NIVEL 5------------------------------------------------- + +if (opcion==5) +{ + + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + + else if(evento->key()==Qt::Key_D) + { + + coaliciones('D', personaje1); + + } + else if(evento->key()==Qt::Key_W) + { + + coaliciones('W', personaje1); + + } + + else if(evento->key()==Qt::Key_S) + { + + coaliciones('S', personaje1); + } + + + //---------------------------------------------EVENTO PERSONAJE 2 NIVEL 5------------------------------------------------------------ + + if(evento->key()==Qt::Key_I) + { + + coaliciones('I', personaje2); + + } + if(evento->key()==Qt::Key_J) + { + coaliciones('J', personaje2); + + + } + if(evento->key()==Qt::Key_L) + { + + coaliciones('L', personaje2); + + } + if(evento->key()==Qt::Key_K) + { + + coaliciones('K', personaje2); + + } + +teletransportacion(); + /*if (evento->key()==Qt::Key_6) + { + clean(); + opcion=6; + niveles(6); + }*/ + +} +//-----------------------------------------------EVENTO PERSONAJE 1 NIVEL 6------------------------------------------------- + +if (opcion==6) +{ + + + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + + else if(evento->key()==Qt::Key_D) + { + + coaliciones('D', personaje1); + + } + else if(evento->key()==Qt::Key_W) + { + + coaliciones('W', personaje1); + + } + + else if(evento->key()==Qt::Key_S) + { + + coaliciones('S', personaje1); + } + + +//---------------------------------------------EVENTO PERSONAJE 2 NIVEL 6------------------------------------------------------------ + +if(evento->key()==Qt::Key_I) +{ + + coaliciones('I', personaje2); + +} +if(evento->key()==Qt::Key_J) +{ + coaliciones('J', personaje2); + + +} +if(evento->key()==Qt::Key_L) +{ + + coaliciones('L', personaje2); + +} +if(evento->key()==Qt::Key_K) +{ + + coaliciones('K', personaje2); + +} +teletransportacion(); +/*if (evento->key()==Qt::Key_7) + { + clean(); + opcion=7; + niveles(opcion); + }*/ + } + +if (opcion==7) +{ + + + + if(evento->key()==Qt::Key_A) + { + coaliciones('A', personaje1); + } + + else if(evento->key()==Qt::Key_D) + { + + coaliciones('D', personaje1); + + } + else if(evento->key()==Qt::Key_W) + { + + coaliciones('W', personaje1); + + } + + else if(evento->key()==Qt::Key_S) + { + + coaliciones('S', personaje1); + } + + + //---------------------------------------------EVENTO PERSONAJE 2 NIVEL 6------------------------------------------------------------ + + if(evento->key()==Qt::Key_I) + { + + coaliciones('I', personaje2); + + } + if(evento->key()==Qt::Key_J) + { + coaliciones('J', personaje2); + + + } + if(evento->key()==Qt::Key_L) + { + + coaliciones('L', personaje2); + + } + if(evento->key()==Qt::Key_K) + { + + coaliciones('K', personaje2); + + } + +teletransportacion(); + +} + +if(evento->key()==Qt::Key_0) +{ + guardarPartida(); +} + +/*if(evento->key()==Qt::Key_1) +{ + clean(); + opcion=1; + niveles (opcion,jugadores); +} +if(evento->key()==Qt::Key_2) +{ + clean(); + opcion=2; + niveles (opcion,jugadores); +} +if(evento->key()==Qt::Key_3) +{ + clean(); + opcion=3; + niveles (opcion,jugadores); +} +if(evento->key()==Qt::Key_4) +{ + clean(); + opcion=4; + niveles (opcion,jugadores); +} +if(evento->key()==Qt::Key_5) +{ + clean(); + opcion=5; + niveles (opcion,jugadores); +} +if(evento->key()==Qt::Key_6) +{ + clean(); + opcion=6; + niveles (opcion,jugadores); +} +if(evento->key()==Qt::Key_7) +{ + clean(); + opcion=7; + niveles (opcion,jugadores); +}*/ +} + +void MainWindow::coaliciones(char letra , Objeto *personaje) +{ + + /*if(vida->getlife()==0) + { + }*/ + + /*if(keys->getkey()==6) + { + piedra->hide(); + }*/ + + if (personaje==personaje1) + { + + if (letra=='A') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + + //---------------------------GIRO DEL PERSONAJE1 (A)------------------------------ + + /*personaje1->setTransformOriginPoint(0,0); + personaje1->setRotation(180);*/ + personaje1->izquierda(1,1); + + + //------------------------------COALISIONES1 (A) ---------------------------- + + if (bolaH->isVisible()) + { + if(personaje1->collidesWithItem(bolaH)) + { + bolaH->izquierda(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje1->collidesWithItem(bolafuego)) + { + personaje1->derecha(1,1); + vida->decrease(); + } + } + if (dragon->isVisible()) + { + if(personaje1->collidesWithItem(dragon)) + { + personaje1->derecha(1,1); + vida->decrease(); + } + } + + if(enemigo1->isVisible()) + { + if(personaje1->collidesWithItem(enemigo1)) + + { + resorte('A', personaje1); + vida->decrease(); + } + } + + //------------------------EVALUAR COALISIONES CON MUROS 1(A)------------------ + + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(muros.at(i))) + { + + personaje1->derecha(1,1); + } + } + } + + + //--------------------EVALUAR COALISIONES CON PIEDRAS 1(A)-------------------- + + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(piedras.at(i))) + { + + personaje1->derecha(1,1); + } + } + } + + //--------------------------CAPTURAR LLAVES 1(A)------------------------------- + + //key->play(); + + //llave->hide(); + + for (int i=0; icollidesWithItem(llavesL.at(i))) + if(llavesL.at(i)->isVisible()) + {{if (personaje1->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + + } + if (letra=='D') + { + //lanzamiento(-40,personaje1->x(),70,personaje1->y()); + + //--------------------------GIRO DEL PERSONAJE 1(D)--------------- + /*personaje1->setTransformOriginPoint(0,0); + personaje1->setRotation(0);*/ + personaje1->derecha(1,1); + + //---------------------------COALISIONES 1(D)---------------------------- + + if (bolaH->isVisible()) + { + if(personaje1->collidesWithItem(bolaH)) + + { + bolaH->derecha(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje1->collidesWithItem(bolafuego)) + { + personaje1->izquierda(1,1); + vida->decrease(); + } + } + + if (dragon->isVisible()) + { + if(personaje1->collidesWithItem(dragon)) + { + personaje1->izquierda(1,1); + vida->decrease(); + } + } + + if(enemigo1->isVisible()) + {if(personaje1->collidesWithItem(enemigo1)) + + { + resorte('D', personaje1); + x = enemigo1->x(); + y = enemigo1->y(); + vida->decrease(); + } + } + //----------------------EVALUAR COALISIONES CON MUROS 1(D)------------------ + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(muros.at(i))) + { + + + + personaje1->izquierda(1,1); + } + } + } + //----------------------EVALUAR COALISIONES CON PIEDRAS 1(D)---------------------- + + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(piedras.at(i))) + { + + personaje1->izquierda(1,1); + } + } + } + + //----------------------------CAPTURAR LLAVES 1(D)---------------------------------- + for (int i=0; iisVisible()) + {{if (personaje1->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + if (letra=='W') + { + //-------------------------GIRO DE PERSONAJE 1(W)----------------------- + /*personaje1->setTransformOriginPoint(0,0); + personaje1->setRotation(270);*/ + personaje1->subir(1,1); + + + //----------------------------COALISIONES 1(W)-------------------------------- + + if (bolaH->isVisible()) + { + if(personaje1->collidesWithItem(bolaH)) + { + bolaH->subir(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje1->collidesWithItem(bolafuego)) + { + personaje1->bajar(1,1); + vida->decrease(); + } + } + + if (dragon->isVisible()) + { + if(personaje1->collidesWithItem(dragon)) + { + personaje1->bajar(1,1); + vida->decrease(); + } + } + + + if(enemigo1->isVisible()) + {if(personaje1->collidesWithItem(enemigo1)) + { + resorte('W', personaje1); + vida->decrease(); + } + } + + //----------------EVALUAR COALISIONES CON MUROS 1(W))----------------------- + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(muros.at(i))) + { + personaje1->bajar(1,1); + } + } + } + //-------------------EVALUAR COALISIONES CON PIEDRAS 1(W)--------------------- + + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(piedras.at(i))) + { + + personaje1->bajar(1,1); + } + } + } + + //-----------------------------CAPTURAR LLAVES 1(W)---------------------------- + for (int i=0; iisVisible()) + {{if (personaje1->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + if (letra=='S') + { + //---------------------------GIRO DE PERSONAJE 1(S)--------------------------- + /*personaje1->setTransformOriginPoint(0,0); + personaje1->setRotation(90);*/ + personaje1->bajar(1,1); + + + //------------------------------COALISIONES 1(S)----------------------------- + if (bolaH->isVisible()) + { + if(personaje1->collidesWithItem(bolaH)) + { + bolaH->bajar(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje1->collidesWithItem(bolafuego)) + { + personaje1->subir(1,1); + vida->decrease(); + } + } + + if (dragon->isVisible()) + { + if(personaje1->collidesWithItem(dragon)) + { + personaje1->subir(1,1); + vida->decrease(); + } + } + + if(enemigo1->isVisible()) + {if(personaje1->collidesWithItem(enemigo1)) + {vida->decrease(); + resorte('S', personaje1); + } + } + //-----------------------EVALUAR COALISIONES CON MUROS 1(S)---------------- + + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(muros.at(i))) + { + + personaje1->subir(1,1); + } + } + } + //----------------------EVALUAR COALISIONES CON PIEDRAS 1(S)--------------- + + for (int i=0;iisVisible()) + { + if (personaje1->collidesWithItem(piedras.at(i))) + { + + personaje1->subir(1,1); + } + } + } + + //--------------------------CAPTURAR LLAVES 1(S)------------------------- + for (int i=0; iisVisible()) + {{if (personaje1->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + + + } + + + + if (personaje==personaje2) + { + + if (letra=='I') + { + //-------------------GIRO DE PERSONAJE 2(I)------------------- + /*personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(270);*/ + personaje2->subir(1,1); + + + //--------------------------COALISIONES 2(I)------------------------ + + if (bolaH->isVisible()) + { + if(personaje2->collidesWithItem(bolaH)) + { + bolaH->subir(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje2->collidesWithItem(bolafuego)) + { + personaje2->bajar(1,1); + vida->decrease(); + } + } + + if (dragon->isVisible()) + { + if(personaje2->collidesWithItem(dragon)) + { + personaje2->bajar(1,1); + vida->decrease(); + } + } + + if(enemigo1->isVisible()) + {if(personaje2->collidesWithItem(enemigo1)) + + { + resorte('I', personaje2); + vida->decrease(); + } + } + //-----------------------------EVALUAR COALISIONES CON MUROS 2(I)------------------ + + for (int i=0;iisVisible()) + { + if (personaje2->collidesWithItem(muros.at(i))) + { + personaje2->bajar(1,1); + } + } + } + + //-------------------------------EVALUAR COALISIONES CON PIEDRAS 2(I)-------------- + //qDebug() <<"Personaje 2 visible"<isVisible()) + { + if (personaje2->collidesWithItem(piedras.at(i))) + { + + personaje2->bajar(1,1); + } + } + } + + //------------------------------------CAPTURAR LLAVES 2(I)-------------------- + + for (int i=0; iisVisible()) + {{if (personaje2->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + + if (letra=='J') + { + //---------GIRO DEL PERSONAJE------- + /*personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(180);*/ + personaje2->izquierda(1,1); + + + //------------------------COALISIONES 2(J)---------------------------------- + + if (bolaH->isVisible()) + { + if(personaje2->collidesWithItem(bolaH)) + { + bolaH->izquierda(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje2->collidesWithItem(bolafuego)) + { + personaje2->derecha(1,1); + vida->decrease(); + } + } + + if (dragon->isVisible()) + { + if(personaje2->collidesWithItem(dragon)) + { + personaje2->derecha(1,1); + vida->decrease(); + } + } + + if(enemigo1->isVisible()) + {if(personaje2->collidesWithItem(enemigo1)) + + { + resorte('J', personaje2); + vida->decrease(); + } + } + //-----------------------EVALUAR COALISIONES CON MUROS 2(J)--------------------- + + for (int i=0;iisVisible()) + { + if (personaje2->collidesWithItem(muros.at(i))) + { + personaje2->derecha(1,1); + } + } + } + //-------------------------EVALUAR COALISIONES CON PIEDRAS 2(J)-------------- + + for (int i=0;iisVisible()) + { + if (personaje2->collidesWithItem(piedras.at(i))) + { + personaje2->derecha(1,1); + } + } + } + + //----------------------------CAPTURAR LLAVES 2(J)----------------------- + + for (int i=0; iisVisible()) + {{if (personaje2->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + + + if (letra=='L') + { + //---------GIRO DEL PERSONAJE------- + /*personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(0);*/ + personaje2->derecha(1,1); + + //-------------------------------COALISIONES 2(L) -------------------------------- + if (bolaH->isVisible()) + { + if(personaje2->collidesWithItem(bolaH)) + + { + bolaH->derecha(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje2->collidesWithItem(bolafuego)) + { + personaje2->izquierda(1,1); + vida->decrease(); + } + } + + if (dragon->isVisible()) + { + if(personaje2->collidesWithItem(dragon)) + { + personaje2->izquierda(1,1); + vida->decrease(); + } + } + + if(enemigo1->isVisible()) + {if(personaje2->collidesWithItem(enemigo1)) + { + resorte('L', personaje2); + vida->decrease(); + } + } + //------------------------EVALUAR COALISIONES CON MUROS 2(L)-------------------------- + + for (int i=0;iisVisible()) + { + if (personaje2->collidesWithItem(muros.at(i))) + { + personaje2->izquierda(1,1); + } + } + } + //---------------------EVALUAR COALISIONES CON PIEDRAS 2(L)---------------------------- + + for (int i=0;iisVisible()) + { + if (personaje2->collidesWithItem(piedras.at(i))) + { + personaje2->izquierda(1,1); + } + } + } + + //------------------------------CAPTURAR LLAVES 2(L)-------------------------------- + + for (int i=0; iisVisible()) + {{if (personaje2->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + if (letra=='K') + { + //---------------------------------GIRO DE PERSONAJE 2(K)---------------------- + /*personaje2->setTransformOriginPoint(0,0); + personaje2->setRotation(90);*/ + personaje2->bajar(1,1); + + + //----------------------------------COALISIONES 2(K)-------------------------------- + + if (bolaH->isVisible()) + { + if(personaje2->collidesWithItem(bolaH)) + { + bolaH->bajar(3,1); + } + } + + if (bolafuego->isVisible()) + { + if(personaje2->collidesWithItem(bolafuego)) + { + personaje2->subir(1,1); + vida->decrease(); + } + } + + if (dragon->isVisible()) + { + if(personaje2->collidesWithItem(dragon)) + { + personaje2->subir(1,1); + vida->decrease(); + } + } + + if(enemigo1->isVisible()) + {if(personaje2->collidesWithItem(enemigo1)) + {vida->decrease(); + resorte('K', personaje2); + } + } + //--------------------------EVALUAR COALISIONES CON MUROS 2(K)-------------------------- + + + for (int i=0;iisVisible()) + { + if (personaje2->collidesWithItem(muros.at(i))) + {personaje2->subir(1,1); + } + } + } + //-----------------------------EVALUAR COALISIONES CON PIEDRAS 2(K)---------------------- + for (int i=0;iisVisible()) + { + if (personaje2->collidesWithItem(piedras.at(i))) + { + personaje2->subir(1,1); + } + } + } + + //-----------------------------CAPTURAR LLAVES 2(K)------------------------------------ + for (int i=0; iisVisible()) + {{if (personaje2->collidesWithItem(llavesL.at(i))) + {scene->removeItem(llavesL.at(i)); + llavesL.removeOne(llavesL.at(i)); + keys->increase(); + } + } + } + } + } + +} + +//------------------------------------------------------NIVELES-------------------------------------------------- + +void MainWindow::registro() +{ + regis=new Registro(this); + regis->show(); +} + +void MainWindow::continuar() +{ + Verificar *verificar=new Verificar; + verificar=new Verificar (this); + + + verificar->show(); + ban3=true; +} + +void MainWindow::setnivel(int opcion_) +{ + opcion=opcion_; + niveles (opcion,jugadores); +} + +void MainWindow::SETMODO(int modoo) +{ + jugadores=modoo; + qDebug()<<"cantidad de jugadores CUANDO INICIO "<setLife(opcion_); +} + +void MainWindow::LLAVES(int opcion_) +{ + qDebug()<<"llaves despues de guardar"<setKey(opcion_); + if (keys->getkey()==6) + { + for (int i=0; iposx==175 and piedras.at(i)->posy==30) + { + + piedras.at(i)->hide(); + + + } + } + } +} + +void MainWindow::TIEMPO(int opcion_) +{ + qDebug()<<"Tiempo después de guardar"<settime(opcion_); +} + +void MainWindow::Iniciar() +{ + Verificar *verificar; + verificar=new Verificar (this); + verificar->show(); +} + +void MainWindow::guardar() +{ + +arch =false; + + QString nivel= QString::number(opcion); + //QString nivel="7"; + + QString contrasena=user->getContrasena(); + + QString modo=user->getModoDeJuego(); + + QString usu=user->getNombre(); + + + + QString VIDAS=QString::number(vida->getlife()); //LLAVES,VIDAS Y TIEMPO QUE DEBE RECIBIR EL ARCHIVO + + QString LLAVES=QString::number(keys->getkey()); + + QString TIEMPO=QString::number(tiempo->gettime()); + + //user=new Usuario; + user->setNivel(nivel); + + QListcont_nivel={contrasena,nivel}; + +qDebug()<<"name "<< usu<<" pass "<>ArchivoUsuario>>passArchivo>>nivelUsuario>>mode>>Vidas>>Llaves>>Tiempo; + + //qDebug()<<"name "<< ArchivoUsuario<<" pass "<>ArchivoUsuario1>>passArchivo1>>nivelUsuario1>>mode1>>vidas1>>llaves1>>tiempo1>>endl; + if (usu==ArchivoUsuario1) + { + WRITECAMBIOS<> registro; + registro[usu]=cont_nivel; + escribir<show(); + arch =false; + ReinicioDEnivel(); + + +} + +void MainWindow::ReinicioDEnivel() +{ + arch=false; + QString nivel= QString::number(opcion); + //QString nivel="7"; + + QString contrasena=user->getContrasena(); + + QString modo=user->getModoDeJuego(); + + QString usu=user->getNombre(); + + qDebug()<<"modo"<getlife()); //LLAVES Y VIDAS QUE DEBE RECIBIR EL ARCHIVO + + QString LLAVES=QString::number(keys->getkey()); + + //user=new Usuario; + user->setNivel(nivel); + + QListcont_nivel={contrasena,nivel}; + +//qDebug()<<"name "<< usu<<" pass "<>ArchivoUsuario>>passArchivo>>nivelUsuario>>mode>>Vidas>>Llaves; + + qDebug()<<"name "<< ArchivoUsuario<<" pass "<>ArchivoUsuario1>>passArchivo1>>nivelUsuario1>>mode1>>vidas1>>llaves1>>endl; + if (usu==ArchivoUsuario1) + { + WRITECAMBIOS<> registro; + registro[usu]=cont_nivel; + escribir<show(); +} + +void MainWindow::instrucciones() +{ + Instrucciones *instr; + instr=new Instrucciones (this); + instr->show(); + + +} + +//------------------------------------------------------NIVELES-------------------------------------------------- + +void MainWindow:: niveles(int opcion,int jugadores) +{ + if (opcion==0) + { + timer= new QTimer; + connect(timer,SIGNAL(timeout()), this, SLOT (actualizar())); + timer->start(1440); + + //..................CREANDO LA ESCENA............. + + scene->setBackgroundBrush(QPixmap(":/I/I/MAINMENU.png")); + if (opcion==0) + { + scene->setSceneRect(0,0,790,550); + + } + + // 310,300 + //LLAVE + + personaje1=new Objeto(180,410,30, ":/I/I/PERSONAJE1.png"); + scene->addItem(personaje1); + personaje1->hide(); + + personaje2=new Objeto(180,410,30, ":/I/I/PERSONAJE1.png"); + scene->addItem(personaje2); + personaje2->hide(); + + enemigo1= new Objeto (475,225,60,":/I/I/ENEMIGO.png"); + scene->addItem(enemigo1); + enemigo1->hide(); + + dragon= new Objeto (305,180,40,":/I/I/dragon.png"); + scene->addItem(dragon); + dragon->hide(); + + bolaH= new Objeto (-25,420, 30,":/I/I/BOLADEMETAL.png"); + scene->addItem(bolaH); + bolafuego= new Particula (505,505,200,30,":/I/I/BOLADEFUEGO.png"); + scene->addItem(bolafuego); + + //intro=new QMediaPlayer (); + //intro->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/fantasy.mp3")); + + + //intro->play(); + + muros.push_back(new Pared (200,-450,800,100, "")); + scene->addItem(muros.back()); + + muros.push_back(new Pared (200,150,800,100, "")); + scene->addItem(muros.back()); + + muros.push_back(new Pared (250,100,100,800, "")); + scene->addItem(muros.back()); + + muros.push_back(new Pared (-550,100,100,800, "")); + scene->addItem(muros.back()); + + for (int i=0;ihide(); + + } + + piedras.push_back(new Objeto(175,30,40,":/I/I/P1.png")); + scene->addItem(piedras.back()); + + //CANTIDAD DE VIDAS + vida=new vidas(); + vida->setLife(5); + vida->setPos(200,-90); + scene->addItem(vida); + vida->hide(); + + + //CANTIDAD DE LLAVES + keys=new llaves(); + keys->setKey(0); + keys->setPos(70,-90); + scene->addItem(keys); + + //CANTIDAD DE Tiempo + tiempo=new Timer(); + tiempo->settime(313); + tiempo->setPos(435,-90); + + } + if (opcion==1) + { + qDebug()<<"entra nivel 1"<stop(); + //key=new QMediaPlayer (); + //key->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/KEY.wav")); + + //------------------------TIMER------------------ + //timer= new QTimer; + //connect(timer,SIGNAL(timeout()), this, SLOT (actualizar())); + //timer->start(1440); + + + scene->setSceneRect(0,0,400,400); + scene->setBackgroundBrush(QPixmap(":/I/I/LN1.jpg")); + start->hide(); + instruccion->hide(); + registrar->hide(); + + + + vida->show(); + qDebug()<<"numero de jugadores"<addItem(tiempo); + personaje2->setPos(100,410); + personaje2->show(); + } + + bolaH->hide(); + scene->addItem(vida); + scene->addItem(keys); + + personaje1->setPos(-120,420); + personaje1->show(); + + for (int i=0; igetPosx()==-65 and llavesL.at(i)->getPosy()==220) + {llavesL.at(i)->show(); + } + else + {llavesL.at(i)->hide(); + } + } + //vida->show(); + //vida->setPos(120,35); + + for (int i=0; igetPosx()==175 and piedras.at(i)->getPosy()==30) + {piedras.at(i)->hide(); + } + } + + enemigo1->setPos(475,225); + enemigo1->show(); + + dragon->setPos(305,180); + dragon->show(); + + //bolafuego= new Particula (0,505,505,200,30,":/I/I/BOLA DE FUEGO.png"); + //scene->addItem(bolafuego); + + rigidez=3; + friccion=10; + xmenor=60; + xmayor=330; + /*piedras.push_back(new Objeto(170,35,40,":/I/I/ROCAS.png")); + scene->addItem(piedras.back()); + piedras.back()->hide();*/ + + items(); + + teletransportacion(); + + + } + if (opcion==2) + { + + + + //intro->stop(); + //key=new QMediaPlayer (); + //key->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/KEY.wav")); + + /*timer= new QTimer; + connect(timer,SIGNAL(timeout()), this, SLOT (mover())); + QTimer *cronometro = new QTimer(this); + connect(cronometro, SIGNAL(timeout()),this,SLOT(lanzarfuego())); + cronometro->start(1000); + + QTimer *cronometro2 = new QTimer(this); + connect(cronometro2, SIGNAL(timeout()),this,SLOT(lanzamiento())); + cronometro2->start(1000); + + + //CREANDO LA ESCENA + ui->setupUi(this); + scene = new QGraphicsScene; + ui->graphicsView->setScene(scene); + scene->setBackgroundBrush(QPixmap(":/I/I/LN1.jpg")); + scene->setSceneRect(0,0,400,400); + + personaje1=new Personaje(180,410,30, ":/I/I/PERSONAJE1.png"); + scene->addItem(personaje1); + + personaje2=new Personaje(0,0,45, ":/I/I/PERSONAJE2.png"); + scene->addItem(personaje2); + + llave= new Objeto (470,35,30,":/I/I/llave1.png"); + scene->addItem(llave);*/ + scene->setSceneRect(0,0,400,400); + scene->setBackgroundBrush(QPixmap(":/I/I/HIELO.png")); + start->hide(); + instruccion->hide(); + registrar->hide(); + + bolaH->hide(); + + if(jugadores==2) + {scene->addItem(tiempo); + personaje2->setPos(100,410); + personaje2->show(); + } + + for (int i=0; igetPosx()==175 and piedras.at(i)->getPosy()==30) + {piedras.at(i)->show(); + } + else if (keys->getkey()==6) + { + qDebug()<<"LLAVES N2"<getkey(); + for (int i=0; iposx==175 and piedras.at(i)->posy==30) + { + + piedras.at(i)->hide(); + + + } + } + } + } + + personaje1->show(); + personaje1->setPos(360,420); + + enemigo1->show(); + enemigo1->setPos(500,500); + + dragon->show(); + scene->addItem(dragon); + //bolafuego->setPos(305,180); + + for (int i=0; igetPosx()==470 and llavesL.at(i)->getPosy()==35) + {llavesL.at(i)->show(); + } + else + {llavesL.at(i)->hide(); + } + } + + vida->show(); + //vida->setPos(120,35); + + keys->setPos(70,-90); + scene->addItem(keys); + + rigidez=4; + friccion=20; + ymenor=-15; + ymayor=420; + xmayor=520; + xmenor=-35; + items(); + + teletransportacion(); + + } + if (opcion==3) + { + + + + + //intro->stop(); + //key=new QMediaPlayer (); + //key->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/KEY.wav")); + + /*timer= new QTimer; + connect(timer,SIGNAL(timeout()), this, SLOT (mover())); + QTimer *cronometro = new QTimer(this); + connect(cronometro, SIGNAL(timeout()),this,SLOT(lanzarfuego())); + cronometro->start(1000); + + QTimer *cronometro2 = new QTimer(this); + connect(cronometro2, SIGNAL(timeout()),this,SLOT(lanzamiento())); + cronometro2->start(1000);*/ + + scene->setSceneRect(0,0,400,400); + scene->setBackgroundBrush(QPixmap(":/I/I/H1.jpg")); + start->hide(); + instruccion->hide(); + registrar->hide(); + vida->show(); + + if(jugadores==2) + {scene->addItem(tiempo); + personaje2->setPos(100,410); + personaje2->show(); + } + + for (int i=0; igetPosx()==175 and piedras.at(i)->getPosy()==30) + { + piedras.at(i)->hide(); + } + } + + for (int i=0; igetPosx()==480 and llavesL.at(i)->getPosy()==45) + {llavesL.at(i)->show(); + } + else + {llavesL.at(i)->hide(); + } + } + + + personaje1->show(); + personaje1->setPos(-120,420); + + enemigo1->show(); + enemigo1->setPos(-120,80); + dragon->setPos(435,300); + dragon->show(); + + //bolafuego->setPos(-20,345); + bolaH->hide(); + + /*totem= new Personaje (0,0,60,""); + scene->addItem(totem); + timer->start();*/ + + rigidez=3; + friccion=20; + xmenor=-120; + xmayor=520; + ymayor=350; + ymenor=-5; + items(); + + teletransportacion(); + + + + } + if (opcion==4) + { + //intro->stop(); + //key=new QMediaPlayer (); + //key->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/KEY.wav")); + + /*timer= new QTimer; + connect(timer,SIGNAL(timeout()), this, SLOT (mover())); + QTimer *cronometro = new QTimer(this); + connect(cronometro, SIGNAL(timeout()),this,SLOT(lanzarfuego())); + cronometro->start(1000); + + QTimer *cronometro2 = new QTimer(this); + connect(cronometro2, SIGNAL(timeout()),this,SLOT(lanzamiento())); + cronometro2->start(1000); + + //CREANDO LA ESCENA + ui->setupUi(this); + scene = new QGraphicsScene;*/ + scene->setSceneRect(0,0,400,400); + scene->setBackgroundBrush(QPixmap(":/I/I/ARENA.jpg")); + start->hide(); + instruccion->hide(); + registrar->hide(); + vida->show(); + + for (int i=0; igetPosx()==175 and piedras.at(i)->getPosy()==30) + { + piedras.at(i)->hide(); + } + } + + for (int i=0; igetPosx()==490 and llavesL.at(i)->getPosy()==55) + {llavesL.at(i)->show(); + } + else + {llavesL.at(i)->hide(); + } + } + + if(jugadores==2) + {scene->addItem(tiempo); + personaje2->setPos(100,410); + personaje2->show(); + } + + bolaH->hide(); + enemigo1->show(); + enemigo1->setPos(-120,105); + + personaje1->show(); + personaje1->setPos(180,420); + //bolafuego->setPos(-20,345); + xmenor=-120; + xmayor=520; + ymayor=350; + ymenor=5; + rigidez=11; + friccion=10; + + items(); + + teletransportacion(); + + } + if (opcion==5) + { + qDebug()<<" ENTRO AL NIVEL 5"; + //intro->stop(); + //key=new QMediaPlayer (); + //key->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/KEY.wav")); + + scene->setSceneRect(0,0,400,400); + scene->setBackgroundBrush(QPixmap(":/I/I/L3.jpg")); + + start->hide(); + instruccion->hide(); + registrar->hide(); + vida->show(); + + for (int i=0; igetPosx()==175 and piedras.at(i)->getPosy()==30) + { + piedras.at(i)->hide(); + } + } + + if(jugadores==2) + {scene->addItem(tiempo); + personaje2->setPos(100,410); + personaje2->show(); + } + + personaje1->setPos(-120,420); + personaje1->show(); + + enemigo1->show(); + enemigo1->setPos(100,10); + bolaH->setPos(0,215); + bolaH->show(); + + bolafuego->setX(165); + + dragon->setPos(355,215); + dragon->show(); + + for (int i=0; igetPosx()==10 and llavesL.at(i)->getPosy()==100) + {llavesL.at(i)->show(); + } + else + {llavesL.at(i)->hide(); + } + } + + keys->setPos(70,-90); + scene->addItem(keys); + xmenor=55; + xmayor=320; + ymenor=110; + ymayor=370; + rigidez=3; + friccion=20; + items(); + + teletransportacion(); + + + } + if (opcion==6) + { + //intro->stop(); + //key=new QMediaPlayer (); + //key->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/KEY.wav")); + + scene->setSceneRect(0,0,400,400); + scene->setBackgroundBrush(QPixmap(":/I/I/L7.png")); + start->hide(); + instruccion->hide(); + registrar->hide(); + vida->show(); + + for (int i=0; igetPosx()==175 and piedras.at(i)->getPosy()==30) + { + piedras.at(i)->hide(); + } + } + + for (int i=0; igetPosx()==460 and llavesL.at(i)->getPosy()==25) + {llavesL.at(i)->show(); + } + else + {llavesL.at(i)->hide(); + } + } + + if(jugadores==2) + {scene->addItem(tiempo); + personaje2->setPos(100,410); + personaje2->show(); + } + + personaje1->show(); + personaje1->setPos(-120,420); + + enemigo1->show(); + enemigo1->setPos(-95,125); + + dragon->show(); + dragon->setPos(445,360); + //bolafuego->setPos(-5,345); + bolaH->hide(); + bolafuego->setX(95); + xmenor=-120; + xmayor=520; + ymenor=-45; + ymayor=410; + rigidez=6; + friccion=30; + + items(); + + teletransportacion(); + + } + if (opcion==7) + { + //intro->stop(); + //key=new QMediaPlayer (); + //key->setMedia(QUrl("qrc:/SONIDOS/SONIDOS/KEY.wav")); + + scene->setSceneRect(0,0,400,400); + scene->setBackgroundBrush(QPixmap(":/I/I/LAVA1.png")); + + for (int i=0; igetPosx()==175 and piedras.at(i)->getPosy()==30) + { + piedras.at(i)->hide(); + } + } + + start->hide(); + instruccion->hide(); + registrar->hide(); + bolaH->hide(); + vida->show(); + + if (personaje1->x()==520 and personaje1->y()==360) //puerta derecha conexión parte de arriba + { + personaje1->setPos(520,60); + } + if (personaje1->x()==-120 and personaje1->y()==60) //puerta final + { + ganar(); + this->close(); + } + + if(jugadores==2) + {scene->addItem(tiempo); + personaje2->setPos(100,410); + personaje2->show(); + } + + enemigo1->setPos(-95,105); + enemigo1->show(); + + dragon->setPos(320,355); + dragon->show(); + + personaje1->setPos(-115,350); + personaje1->show(); + + xmenor=-50; + xmayor=520; + ymayor=350; + rigidez=11; + friccion=30; + + items(); + teletransportacion(); + + } +} + +void MainWindow::items() +{ + + /* llave= new Objeto (470,35,30,":/IMAGENES/llave1.png"); + scene->addItem(llave);*/ + + for (int i=0;igetPosx()==200 and muros.at(i)->getPosy()==-450) + {muros.at(i)->show(); + scene->addItem(muros.at(i));} + + else if(muros.at(i)->getPosx()==200 and muros.at(i)->getPosy()==150) + {muros.at(i)->show(); + scene->addItem(muros.at(i));} + + else if(muros.at(i)->getPosx()==250 and muros.at(i)->getPosy()==100) + {muros.at(i)->show(); + scene->addItem(muros.at(i));} + + else if(muros.at(i)->getPosx()==-550 and muros.at(i)->getPosy()==100) + {muros.at(i)->show(); + scene->addItem(muros.at(i));} + + else + {muros.at(i)->hide();} + } + + if (opcion==1) + { + piedras.push_back(new Objeto(-100,320,40,":/I/I/P1.png")); + scene->addItem(piedras.back()); + + piedras.push_back(new Objeto(-15,290,40,":/I/I/P1.png")); + scene->addItem(piedras.back()); + + piedras.push_back(new Objeto(0,200,40,":/I/I/P1.png")); + scene->addItem(piedras.back()); + + piedras.push_back(new Objeto(-50,120,40,":/I/I/P1.png")); + scene->addItem(piedras.back()); + + muros.push_back(new Pared (-350,50,50,800, ":/I/I/rocas2.png")); //muro vertical + scene->addItem(muros.back()); + + muros.push_back(new Pared (-120,50,20,50, ":/I/I/BLOQUE.jpg")); //abajo derecha conexion nivel 5 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-200,50,20,50, ":/I/I/BLOQUE.jpg")); //abajo izqu conexion nivel 5 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-10,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 4 ancho alto + scene->addItem(muros.back()); + + muros.push_back(new Pared (150,-160,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 2 arriba ancho alto conex n 2 + scene->addItem(muros.back()); + + muros.push_back(new Pared (150,-250,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 3 abajo ancho alto conex nivel 2 + scene->addItem(muros.back()); + } + + if (opcion==2) + { + muros.push_back(new Pared (-120,50,20,50, ":/I/I/BLOQUE.jpg")); //arriba conex nivel 7 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-200,50,20,50, ":/I/I/BLOQUE.jpg")); //arriba izq conex nivel 7 + scene->addItem(muros.back()); + + muros.push_back(new Pared (90,-400,20,50, ":/I/I/BLOQUE.jpg")); //abajo izqu //-200 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-150,50,20, ":/I/I/BLOQUE.jpg")); //derecha arriba + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-230,50,20, ":/I/I/BLOQUE.jpg")); //derecha abajo + scene->addItem(muros.back()); + + for (int i=0;ix()==170 and piedras.at(i)->y()==35) + { + piedras.at(i)->show(); + } + } + } + + if (opcion==3) + { + + muros.push_back(new Pared (150,-160,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 5 arriba ancho alto + scene->addItem(muros.back()); + + muros.push_back(new Pared (150,-250,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 5 abajo ancho alto + scene->addItem(muros.back()); + + muros.push_back(new Pared (-420,-400,30,50, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 4 izqu abajo ancho alto + scene->addItem(muros.back()); + + muros.push_back(new Pared (-520,-400,30,50, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 4 derecha abajo ancho alto + scene->addItem(muros.back()); + + muros.push_back(new Pared (-50,-150,200,50, ":/I/I/BLOQUE.jpg")); //muro centro arriba + scene->addItem(muros.back()); + + muros.push_back(new Pared (-50,-150,50,300, ":/I/I/BLOQUE.jpg")); //muro centro izquierda + scene->addItem(muros.back()); + + muros.push_back(new Pared (-250,-150,50,150, ":/I/I/BLOQUE.jpg")); //muro centro derecha + scene->addItem(muros.back()); + + } + + if (opcion==4) + { + //_------ muros extra + muros.push_back(new Pared (-100,-300,50,200, ":/I/I/BLOQUE.jpg")); //VERTICAL ABAJO + scene->addItem(muros.back()); + + //muros.push_back(new Pared (150,-300,300,50, ":/IMAGENES/BLOQUE.jpg")); //HORIZONTAL ABAJO + //scene->addItem(muros.back()); + + + //muros puertas + + muros.push_back(new Pared (150,-10,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 1 ancho alto + scene->addItem(muros.back()); + + muros.push_back(new Pared (-220,50,30,50, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 3 + scene->addItem(muros.back()); + + } + + if (opcion==5) + { + /* muros.push_back(new Pared (0,200,50,400, ":/IMAGENES/BLOQUE.jpg")); //centro derecha conexion nivel 7 + scene->addItem(muros.back()); + muros.push_back(new Pared (-320,200,50,400, ":/IMAGENES/BLOQUE.jpg")); //centro izquierda conexion nivel 7 + scene->addItem(muros.back());*/ + + muros.push_back(new Pared (-120,-400,20,50, ":/I/I/BLOQUE.jpg")); //abajo derecha conexion nivel 1 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-200,-400,20,50, ":/I/I/BLOQUE.jpg")); //abajo izqu conexion nivel 1 + scene->addItem(muros.back()); + + muros.push_back(new Pared (150,-160,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 2 arriba ancho alto conex n 2 + scene->addItem(muros.back()); + + muros.push_back(new Pared (150,-250,50,30, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 3 abajo ancho alto conex nivel 2 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-150,50,20, ":/I/I/BLOQUE.jpg")); //derecha arriba conex nivel 3 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-230,50,20, ":/I/I/BLOQUE.jpg")); //derecha abajo conex nivel 3 + scene->addItem(muros.back()); + + + + + //muros.push_back(new Pared (0,200,50,800, ":/IMAGENES/BLOQUE.jpg")); + //scene->addItem(muros.back()); + + } + + if (opcion==6) + { + + muros.push_back(new Pared (30,200,50,400, ":/I/I/BLOQUE.jpg")); //centro derecha conexion nivel 7 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-370,200,50,400, ":/I/I/BLOQUE.jpg")); //centro izquierda conexion nivel 7 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-170,-200,50,400, ":/I/BLOQUE.jpg")); //centro izquierda conexion nivel 7 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-200,50,20, ":/I/I/BLOQUE.jpg")); //derecha arriba conex nivel 1 + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-280,50,20, ":/I/I/BLOQUE.jpg")); //derecha abajo conex nivel 1 + scene->addItem(muros.back()); + + + muros.push_back(new Pared (85,50,30,50, ":/I/I/BLOQUE.jpg")); //puerta conexion nivel 2 + scene->addItem(muros.back()); + + boton=new Objeto(255,420,40,""); + } + + if (opcion==7) + { + muros.push_back(new Pared (200,-200,800,50, ":/I/I/rocas2.png")); //muro centro + scene->addItem(muros.back()); + + muros.push_back(new Pared (85,-400,30,50, ":/I/I/BLOQUE.jpg")); //puerta abajo conexion nivel 2 + scene->addItem(muros.back()); + + muros.push_back(new Pared (150,-0,50,30, ":/I/I/BLOQUE.jpg")); //puerta final + scene->addItem(muros.back()); + + muros.push_back(new Pared (150,-90,50,30, ":/I/I/BLOQUE.jpg")); //Puerta final + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-10,50,20, ":/I/I/BLOQUE.jpg")); //puerta segunda parte derecha (arriba) + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-90,50,20, ":/I/I/BLOQUE.jpg")); //puerta segunda parte derecha (abajo) + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-310,50,20, ":/I/I/BLOQUE.jpg")); //puerta primera parte derecha (arriba) + scene->addItem(muros.back()); + + muros.push_back(new Pared (-500,-390,50,20, ":/I/I/BLOQUE.jpg")); //puerta primera parte derecha (abajo) + scene->addItem(muros.back()); + } + +} + +void MainWindow::clean() +{ + for (int i=0;ihide(); + } + + +} + +void MainWindow::teletransportacion() +{ + if (opcion==1) + { + if (personaje1->x()==170 and personaje1->y()==-20) //puerta arriba //conexion nivel 5 + { + + clean(); + + opcion=5; + niveles(opcion, jugadores); + personaje1->setPos(170,345); + personaje2->setPos(115,350); + } + + if (personaje1->x()==520 and personaje1->y()==-20) //puerta arriba //conexion nivel 4 + { + clean(); + opcion=4; + niveles(opcion,jugadores); + personaje1->setPos(-80,-20); + personaje2->setPos(-55,-20); + } + if (personaje1->x()==-120 and personaje1->y()==220) + { + + clean(); + opcion=6; + niveles(opcion,jugadores); + personaje1->setPos(455,250); + } + + + + } + if (opcion==2) + { + + if (personaje1->x()==170 and personaje1->y()==-20) //puerta arriba //conexion nivel 7 + { + clean(); + opcion=7; + niveles(opcion,jugadores); + personaje1->setPos(-115,350); + personaje2->setPos(-10,335); + } + if (personaje1->x()==520 and personaje1->y()==200) //puerta izquierda //conexion nivel 5 + { + clean(); + opcion=5; + niveles(opcion,jugadores); + personaje1->setPos(-65,215); + personaje2->setPos(-50,320); + } + if (personaje1->x()==-120 and personaje1->y()==420) //puerta abajo //conexion nivel 6 + { + clean(); + opcion=6; + niveles(opcion,jugadores); + personaje1->setPos(-120,5); + personaje2->setPos(-60,30); + } + /*if (personaje1->x()==520 and personaje1->y()==200) //puerta derecha //conexion nivel 3 + { + clean(); + opcion=3; + niveles(opcion); + }*/ + } + if (opcion==3) + { + + if (personaje1->x()==-115 and personaje1->y()==220) //puerta izquierda //conexion nivel 5 + { + clean(); + opcion=5; + niveles(opcion,jugadores); + personaje1->setPos(455,205); + personaje2->setPos(375,205); + } + if (personaje1->x()==485 and personaje1->y()==420) //puerta izquierda //conexion nivel 4 + { + clean(); + opcion=4; + niveles(opcion,jugadores); + personaje1->setPos(280,20); + personaje2->setPos(350,-20); + } + + } + + if (opcion==4) + { + + if (personaje1->x()==-115 and personaje1->y()==-20) //puerta izquierda //conexion nivel 1 + { + clean(); + opcion=1; + niveles(opcion,jugadores); + personaje1->setPos(515,-20); + personaje2->setPos(430,-20); + + } + if (personaje1->x()==280 and personaje1->y()==-20) //puerta arriba //conexion nivel 3 + { + clean(); + opcion=3; + niveles(opcion,jugadores); + personaje1->setPos(475,360); + + } + + } + + if (opcion==5) + { + + if (personaje1->x()==170 and personaje1->y()==415) //puerta abajo//conexion nivel 1 + { + clean(); + opcion=1; + niveles(opcion,jugadores); + personaje1->setPos(155,45); + personaje2->setPos(105,40); + + } + if (personaje1->x()==520 and personaje1->y()==200) //puerta derecha//conexion nivel 3 + { + clean(); + opcion=3; + niveles(opcion,jugadores); + personaje1->setPos(-70,220); + personaje2->setPos(-70,305); + + } + if (personaje1->x()==-120 and personaje1->y()==220) //puerta izquierda //conexion nivel 2 + { + clean(); + opcion=2; + niveles(opcion,jugadores); + personaje1->setPos(460,205); + personaje2->setPos(470,115); + + } + + + } + if (opcion==6) + { + + if (personaje1->x()==515 and personaje1->y()==250) //puerta derecha conex nivel 1 + { + clean(); + opcion=1; + niveles(opcion,jugadores); + personaje1->setPos(-110,220); + personaje2->setPos(-70,220); + + } + if (personaje1->x()==-120 and personaje1->y()==-15) //puerta arriba //conexion nivel 2 + { + clean(); + opcion=2; + niveles(opcion,jugadores); + personaje1->setPos(-115,355); + + } + } + if (opcion==7) + { + if (personaje1->x()==520 and personaje1->y()==360) //puerta derecha conexión parte de arriba + { + + + personaje1->setPos(520,60); + + } + if (personaje1->x()==-120 and personaje1->y()==60) //puerta final + { + + + ganar(); + this->close(); + + } + + + } + +} + +//--------------------------------------------------FISICAS-------------------------------------------------- + + +/*void MainWindow::lanzarfuego() +{ + if (opcion==1) + {x=dragon->getPosx(); + y=dragon->getPosy(); //(an,posxx,posyy,velocidad,r,path) + cuerpos.push_back(new Particula (0,x, y,100,30,":/I/I/BOLADEFUEGO.png")); + scene->addItem(cuerpos.back()); + } + + if (opcion==3) + { + //(an,posxx,posyy,velocidad,r,path) + cuerpos.push_back(new Particula (0,520,330,300,30,":/I/I/BOLADEFUEGO.png")); + scene->addItem(cuerpos.back()); + } + if (opcion==4) + { //(an,posxx,posyy,velocidad,r,path) + cuerpos.push_back(new Particula (0,520,330,400,30,":/I/I/BOLADEFUEGO.png")); + scene->addItem(cuerpos.back()); + } + if (opcion==5) + { //(an,posxx,posyy,velocidad,r,path) + cuerpos.push_back(new Particula (0,515,325,500,30,":/I/I/BOLADEFUEGO.png")); + scene->addItem(cuerpos.back()); + } + if (opcion==6) + { //(an,posxx,posyy,velocidad,r,path) + cuerpos.push_back(new Particula (0,445,360,600,30,":/I/I/BOLADEFUEGO.png")); + scene->addItem(cuerpos.back()); + } + if (opcion==7) + { //(an,posxx,posyy,velocidad,r,path) + cuerpos.push_back(new Particula (0,500,325,600,30,":/I/I/BOLADEFUEGO.png")); + scene->addItem(cuerpos.back()); + } + +}*/ + +void MainWindow::moverfuego() +{ + if(ban2==false) + {bolafuego->setY(bolafuego->y()+2*friccion*M*G); + if(bolafuego->y()>=ymayor) + {ban2=true;} + if(bolaH->collidesWithItem(bolafuego)) + {ban2=true;} + } + if(ban2==true) + {bolafuego->setY(bolafuego->y()-2*friccion*M*G); + if(bolafuego->y()<=ymenor) + {ban2=false; + } + if(bolaH->collidesWithItem(bolafuego)) + {ban2=false;} + } + if(personaje1->collidesWithItem(bolafuego)) + { + vida->decrease(); + personaje1->subir(1,1); + } + if(personaje2->collidesWithItem(bolafuego)) + { + vida->decrease(); + personaje2->subir(1,1); + } + +} + +void MainWindow::resorte(char letra , Objeto *personaje) +{ + if (personaje==personaje1) + { + + if (letra=='A') + {personaje1-> setPos(personaje1->x()+5*rigidez,personaje1->y()); + } + if (letra=='D') + {personaje1-> setPos(personaje1->x()-5*rigidez,personaje1->y()); + } + if (letra=='W') + {personaje1->setPos(personaje1->x(),personaje1->y()+5*rigidez); + } + if(letra=='S') + {personaje1->setPos(personaje1->x(),personaje1->y()-5*rigidez); + } + } + + if(personaje==personaje2) + {if(letra=='J') + {personaje2-> setPos(personaje2->x()+5*rigidez,personaje2->y()); + } + if(letra=='L') + {personaje2-> setPos(personaje2->x()-5*rigidez,personaje2->y()); + } + if(letra=='I') + {personaje2->setPos(personaje2->x(),personaje2->y()+5*rigidez); + } + if(letra=='K') + {personaje2->setPos(personaje2->x(),personaje2->y()-5*rigidez); + } + } +} + +void MainWindow::moverEnemigo( ) +{ + if(ban==false) + {enemigo1->setX(enemigo1->x()+2*friccion*M*G); + if(enemigo1->x()>=xmayor) + {ban=true;} + if(bolaH->collidesWithItem(enemigo1)) + {ban=true;} + } + if(ban==true) + {enemigo1->setX(enemigo1->x()-2*friccion*M*G); + if(enemigo1->x()<=xmenor) + {ban=false;} + if(bolaH->collidesWithItem(bolafuego)) + {ban=false;} + } + if(personaje1->collidesWithItem(enemigo1)) + { + vida->decrease(); + personaje1->derecha(1,1); + } + if(personaje2->collidesWithItem(enemigo1)) + { + vida->decrease(); + personaje2->derecha(1,1); + } +} + +//-------------------------------------------------DESTRUCTOR--------------------------------------------------------------- + + +MainWindow::~MainWindow() +{ + delete ui; + +} + + + +void MainWindow::actualizar() +{switch(opcion) + { case 1: + moverEnemigo(); + if(jugadores==2) + {tiempo->decrease();} + break; + + case 2: + moverfuego(); + if(jugadores==2) + {tiempo->decrease();} + break; + default: + moverEnemigo(); + moverfuego(); + if(jugadores==2) + {tiempo->decrease();} + break; + } +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..d5aea30 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,183 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +//#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + //QList muros; + QList muros; + QList piedras; + QList llavesL; + + void setnivel(int opcion_); + + void VIDAS(int opcion_); + + void LLAVES(int opcion_); + + void TIEMPO(int opcion_); + + void SETMODO(int modoo); + + void setUser(Usuario *value); + +private slots: + + void continuar(); + + //void botonInicio(); + + void actualizar(); + + void Iniciar(); + + void registro(); + + void guardar(); + + void ganar(); + + void instrucciones(); + + void ReinicioDEnivel(); + + void perder(); + +private: + + Ui::MainWindow *ui; + QGraphicsScene *scene; + + //TIPO VENTANAS + Usuario *user; + Registro *regis; + + //SONIDOS + //QMediaPlayer *key; + //QMediaPlayer *intro; + + + //PARTÍCULA + QTimer *timer; + QLabel *label; + + //-------BOTONES + QPushButton *start; + QPushButton *instruccion; + QPushButton *save; + QLineEdit *usuario; + + //--------ARCHIVOS-------- + QFile archivo; + QString ArchivoUsuario; + QString passArchivo; + QString nivelUsuario; + QString mode; + QString ArchivoUsuario1; + QString passArchivo1; + QString nivelUsuario1; + QString mode1; + QString Vidas; + QString Llaves; + QString Tiempo; + QString vidas1; + QString llaves1; + QString tiempo1; + QPushButton *registrar; + + //OBJETOS + Objeto *enemigo1; + Objeto *personaje1; + Objeto *personaje2; + Particula *bolafuego; + Objeto *bolaH; + QObject *personaje; + Objeto *boton; + Objeto *dragon; + vidas *vida; + llaves *keys; + Timer *tiempo; + double x; + double y; + int opcion=0; + int nivel=0; + int rigidez=0; + int friccion=0; + int counter=0; + int xmenor=0; + int xmayor=0; + int ymenor=0; + int ymayor=0; + int path=0; + int jugadores=0; + bool ban=false; + bool ban2=false; + bool ban3; + bool visible; + bool arch; + int opcionArchivo=1; + + //____ prueba + + void keyPressEvent(QKeyEvent * evento); + + void items(); + + void niveles(int,int); + + void guardarPartida(); + + void clean (); + + void teletransportacion(); + + void moverfuego(); + + //void lanzarfuego(); + + void moverEnemigo(); + + void coaliciones (char , Objeto *personaje); + + void resorte(char letter,Objeto *personaje); + +}; +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..1d578bf --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,48 @@ + + + MainWindow + + + + 0 + 0 + 812 + 605 + + + + MainWindow + + + /*#graphicsView +{ +background-image : url(:/IMAGENES/MAINMENU.png); +}*/ + + + + + + -10 + 10 + 800 + 581 + + + + + + + + 0 + 0 + 812 + 20 + + + + + + + + diff --git a/objeto.cpp b/objeto.cpp new file mode 100644 index 0000000..8700d62 --- /dev/null +++ b/objeto.cpp @@ -0,0 +1,80 @@ +#include "objeto.h" + +Objeto::Objeto() +{ + +} + +Objeto::Objeto(int x, int y, int r, QString rt) +{ + posx=x; + posy=y; + radio=r; + ruta=rt; + setPos(posx,posy); +} + +int Objeto::getR() +{ + return radio; +} + +void Objeto::setR(int r) +{ + radio=r; +} + + +int Objeto::getPosx() +{ + return posx; +} + +void Objeto::setPosx(int px) +{ + posx=px; +} + +int Objeto::getPosy() +{ + return posy; +} + +void Objeto::setPosy(int py) +{ + posy = py; +} +void Objeto::subir(int ECI, int ECF) +{ + setPos(x(),y()-5*ECI*ECF); +} + +void Objeto::bajar(int ECI, int ECF) +{ + setPos(x(),y()+5*ECI*ECF); +} + +void Objeto::derecha(int ECI,int ECF) +{ + setPos(x()+5*ECI*ECF,y()); +} + +void Objeto::izquierda(int ECI, int ECF) +{ + setPos(x()-5*ECI*ECF,y()); +} + +QRectF Objeto::boundingRect() const +{ + return QRectF(-radio,-radio,2*radio,2*radio); + +} + +void Objeto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + QPixmap pixmap; + + pixmap.load(ruta); + + painter->drawPixmap(boundingRect(),pixmap,pixmap.rect()); +} diff --git a/objeto.h b/objeto.h new file mode 100644 index 0000000..805ee43 --- /dev/null +++ b/objeto.h @@ -0,0 +1,34 @@ + #ifndef OBJETO_H + #define OBJETO_H + #include + #define M 5 + #define G 1 + #include + #include + class Objeto : public QGraphicsItem + {public: + + int radio; + int posx, posy; + QString ruta; + int ECI; + int ECF; + + public: + Objeto(); + Objeto(int x, int y, int r, QString ruta); + int getR(); + void setR(int r); + int getPosx(); + void setPosx(int px); + int getPosy(); + void setPosy(int py); + void subir(int ECI,int ECF); + void bajar(int ECI,int ECF); + void derecha(int ECI,int ECF); + void izquierda(int ECI,int ECF); + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr); + }; + + #endif // OBJETO_H diff --git a/particula.cpp b/particula.cpp new file mode 100644 index 0000000..8b85205 --- /dev/null +++ b/particula.cpp @@ -0,0 +1,24 @@ +#include "particula.h" + +void Particula::setVel(double value) +{ + vel = value; +} + +Particula::Particula() +{ + +} + +Particula::Particula(double posxx, double posyy, double velocidad, int r, QString path) +{ + posx=posxx; + posy=posyy; + vel=velocidad; + ruta=path; + radio=r; + setPos(posx, posy); + +} + + diff --git a/particula.h b/particula.h new file mode 100644 index 0000000..849ba04 --- /dev/null +++ b/particula.h @@ -0,0 +1,23 @@ +#ifndef PARTICULA_H +#define PARTICULA_H +#include +#include +#include +#include //seno coseno raiz + +class Particula: public Objeto +{ + //se le dan las conidiones iniciales (atributos) + double vel; + // se van a recalculas con base en las ecuaciones + double g= 9.8; //tiempo + +public: + Particula(); + Particula( double posxx, double posyy , double velocidad, int r, QString path); + + void setVel(double value); +}; + +#endif // PARTICULA_H + diff --git a/personaje.cpp b/personaje.cpp new file mode 100644 index 0000000..10a66bc --- /dev/null +++ b/personaje.cpp @@ -0,0 +1,84 @@ +#include "personaje.h" + +Personaje::Personaje() +{ + +} + +Personaje::Personaje(int x, int y, int r, QString path) +{ + radio=r; + posx = x; + posy = y; + ruta=path; + setPos(posx,posy); +} + +int Personaje::getR() +{ + return radio; +} + +void Personaje::setR(int r) +{ + radio = r; +} + +int Personaje::getPosx() +{ + return posx; +} + +void Personaje::setPosx(int px) +{ + posx=px; +} + +int Personaje::getPosy() +{ + return posy; +} + +void Personaje::setPosy(int py) +{ + posy = py; +} + +void Personaje::subir() +{setPos(x(),y()-5); +} + +void Personaje::bajar() +{ + setPos(x(),y()+5); +} + +void Personaje::derecha() +{ + setPos(x()+5,y()); +} + +void Personaje::izquierda() +{ + + setPos(x()-5,y()); + +} + +QRectF Personaje::boundingRect() const +{ + return QRectF(-radio,-radio,2*radio,2*radio); +} + +void Personaje::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + /*QPixmap personaje; + personaje.load(ruta); + painter->drawPixmap(boundingRect(),personaje,personaje.rect());*/ + + + QPixmap *personaje=new QPixmap(ruta); + *personaje=personaje->transformed(QTransform().scale(-1,1)); + painter->drawPixmap(boundingRect(),*personaje,personaje->rect()); + +} diff --git a/personaje.h b/personaje.h new file mode 100644 index 0000000..ebc56dd --- /dev/null +++ b/personaje.h @@ -0,0 +1,36 @@ +#ifndef PERSONAJE_H +#define PERSONAJE_H +#include +#include + +#include +#define M 5 +#define G 1 + +class Personaje : public QGraphicsItem +{ +public: + int radio; + int posx, posy; + QString ruta; + +public: + + Personaje(); + Personaje ( int x, int y , int r, QString path); + int getR(); + void setR(int radio); + int getPosx(); + void setPosx(int px); + int getPosy(); + void setPosy(int py); + void subir(); + void bajar(); + void derecha(); + void izquierda(); + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr); + +}; + +#endif // PERSONAJE_H diff --git a/registro.cpp b/registro.cpp new file mode 100644 index 0000000..e42d7bf --- /dev/null +++ b/registro.cpp @@ -0,0 +1,108 @@ +#include "registro.h" +#include "ui_registro.h" + +Registro::Registro(QWidget *parent) : + QDialog(parent), + ui(new Ui::Registro) +{ + ui->setupUi(this); + scene = new QGraphicsScene; + ui->graphicsView->setScene(scene); + + +} + +Registro::~Registro() +{ + delete ui; +} + + +void Registro::on_pushButton_2_clicked() +{ + QString usuario= ui->USUARIO->text(); + QString contrasena=ui->CONTRASENA->text(); + QString nivel="1"; + QString vidas="6"; + QString llaves="0"; + QString time="313"; + QListcont_nivel={contrasena,nivel}; + QListcont2_nivel={contrasena,nivel}; + + QFile archivo ("D:/E-MEDIEVAL/E-MEDIEVAL/REGISTRO/registro.txt"); + QFile archivo1("D:/E-MEDIEVAL/E-MEDIEVAL/REGISTRO/registro.txt"); + QFile cambios("D:/E-MEDIEVAL/E-MEDIEVAL/REGISTRO/cambios.txt"); + archivo.open(QIODevice::ReadOnly | QIODevice::Text); + archivo1.open(QIODevice::WriteOnly | QIODevice::Append); + cambios.open(QIODevice::WriteOnly | QIODevice::Append); + QTextStream datosArchivo (&archivo); + QTextStream escribir (&archivo1); + QTextStream write (&cambios); + + if ((modo!="1" and modo!="2") or (usuario=="") or (contrasena=="") ) + { + QMessageBox::warning(this, tr("REGISTRO NO VÁLIDO"), + + tr("DEBE COMPLETAR TODOS LOS CAMPOS REQUERIDOS"), + QMessageBox::Cancel); + + } + + else + { + ban=1; + } + + while (!datosArchivo.atEnd()) + { + + datosArchivo>>ArchivoUsuario; //lee el usuario del archivo, la primera línea + + if (usuario==ArchivoUsuario) + { + ban=0; + QMessageBox::warning(this, tr("REGISTRO NO VÁLIDO"), + tr("EL USUARIO YA ESTÁ REGISTRADO"), + + QMessageBox::Cancel); + } + } + if (ban==1) + { + hide(); + //QMap> registro; + //QMap> registro2; + //registro[usuario]=cont_nivel; + //registro2[usuario]=cont_nivel; + //QListcont2_nivel={contrasena,nivel}; + write< +#include +#include +#include +#include +namespace Ui { +class Registro; +} + +class Registro : public QDialog +{ + Q_OBJECT + +public: + explicit Registro(QWidget *parent = nullptr); + ~Registro(); + + // QString getNivel() const; + //void setNivel(const QString &value); + +private slots: + void on_pushButton_clicked(); + + void on_pushButton_2_clicked(); + + void on_pushButton_3_clicked(); + +private: + Ui::Registro *ui; + QGraphicsScene *scene; + // QMainWindow *juego; + int ban=1; + QString ArchivoUsuario; + QString modo; + // QString nivel; + +}; + +#endif // REGISTRO_H diff --git a/registro.ui b/registro.ui new file mode 100644 index 0000000..a9f167a --- /dev/null +++ b/registro.ui @@ -0,0 +1,140 @@ + + + Registro + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 15 + 11 + 371 + 271 + + + + + + + 180 + 30 + 51 + 20 + + + + REGISTRO + + + + + + 80 + 60 + 111 + 16 + + + + NOMBRE DE USUARIO + + + + + + 80 + 100 + 71 + 16 + + + + CONTRASEÑA + + + + + + 140 + 140 + 131 + 16 + + + + ELIJA EL MODO DE JUEGO + + + + + + 80 + 180 + 75 + 23 + + + + UN JUGADOR + + + + + + 154 + 230 + 81 + 23 + + + + REGISTRARSE + + + + + + 234 + 180 + 91 + 23 + + + + MULTIJUGADOR + + + + + + 230 + 60 + 113 + 20 + + + + + + + 230 + 100 + 113 + 20 + + + + + + + diff --git a/timer.cpp b/timer.cpp new file mode 100644 index 0000000..e235e06 --- /dev/null +++ b/timer.cpp @@ -0,0 +1,32 @@ +#include "timer.h" + +#include + +Timer::Timer(QGraphicsItem *parent): QGraphicsTextItem(parent) +{ + //inicializar las vidas en 3 + time = 313; + + //ESCRIBIR EL TEXTO + setPlainText(QString("Tiempo: ")+QString::number(time)); + setDefaultTextColor(Qt::red); + setFont(QFont("times",16)); + +} + +void Timer::decrease() +{ + time--; + setPlainText(QString("Tiempo: ")+QString::number(time)); +} + +int Timer::gettime() +{ + return time; +} + +void Timer::settime(int value) +{ + time = value; + setPlainText(QString("Tiempo: ")+QString::number(time)); +} diff --git a/timer.h b/timer.h new file mode 100644 index 0000000..f96c256 --- /dev/null +++ b/timer.h @@ -0,0 +1,23 @@ +#ifndef TIMER_H +#define TIMER_H + +#include + + +class Timer: public QGraphicsTextItem +{ + +public: + + Timer(QGraphicsItem * parent=0); + + void decrease(); + int gettime(); + void settime(int value); + +private: + + int time; +}; + +#endif // TIMER_H diff --git a/usuario.cpp b/usuario.cpp new file mode 100644 index 0000000..9d44b4f --- /dev/null +++ b/usuario.cpp @@ -0,0 +1,95 @@ +#include "usuario.h" + + + + + +QString Usuario::getNombre() const +{ + return nombre; +} + +void Usuario::setNombre(QString value) +{ + nombre = value; +} + + +QString Usuario::getContrasena() const +{ + return contrasena; +} + +void Usuario::setContrasena(QString value) +{ + contrasena = value; +} + +QString Usuario::getNivel() const +{ + return nivel; +} + +void Usuario::setNivel(const QString &value) +{ + nivel = value; +} + +QString Usuario::getModoDeJuego() const +{ + return modoDeJuego; +} + +void Usuario::setModoDeJuego(const QString &value) +{ + modoDeJuego = value; +} + + +QString Usuario::getVIDAS() const +{ + return VIDAS; +} + +void Usuario::setVIDAS(const QString &value) +{ + VIDAS = value; +} + +QString Usuario::getLLAVES() const +{ + return LLAVES; +} + +void Usuario::setLLAVES(const QString &value) +{ + LLAVES = value; +} + +QString Usuario::getTIEMPO() const +{ + return TIEMPO; +} + +void Usuario::setTIEMPO(const QString &value) +{ + TIEMPO = value; +} + +Usuario::Usuario() +{ + +} + + + +Usuario::Usuario(QString name, QString pass, QString level, QString mode, QString vidas_, QString llaves_, QString tiempo_) +{ + nombre=name; + contrasena=pass; + nivel=level; + modoDeJuego=mode; + VIDAS=vidas_; + LLAVES=llaves_; + TIEMPO=tiempo_; +} diff --git a/usuario.h b/usuario.h new file mode 100644 index 0000000..646228c --- /dev/null +++ b/usuario.h @@ -0,0 +1,40 @@ +#ifndef USUARIO_H +#define USUARIO_H +#include + +class Usuario +{ + QString nombre; + QString contrasena; + QString nivel; + QString modoDeJuego; + QString VIDAS; + QString LLAVES; + QString TIEMPO; + +public: + Usuario(); + Usuario(QString name, QString pass, QString level, QString modo, QString VIDAS, QString LLAVES, QString tiempo_); + + + QString getNombre() const; + void setNombre(QString value); + QString getContrasena() const; + void setContrasena(QString value); + QString getNivel() const; + void setNivel(const QString &value); + QString getModoDeJuego() const; + void setModoDeJuego(const QString &value); + QString getVidas() const; + void setVidas(const QString &value); + QString getLlaves() const; + void setLlaves(const QString &value); + QString getVIDAS() const; + void setVIDAS(const QString &value); + QString getLLAVES() const; + void setLLAVES(const QString &value); + QString getTIEMPO() const; + void setTIEMPO(const QString &value); +}; + +#endif // USUARIO_H diff --git a/verificar.cpp b/verificar.cpp new file mode 100644 index 0000000..b9b3d0c --- /dev/null +++ b/verificar.cpp @@ -0,0 +1,106 @@ +#include "verificar.h" +#include "ui_verificar.h" + +Verificar::Verificar(QWidget *parent) : + QDialog(parent), + ui(new Ui::Verificar) +{ + ui->setupUi(this); +} + +Verificar::~Verificar() +{ + delete ui; +} + +void Verificar::on_pushButton_clicked() +{ + QString usuario= ui->USUARIO->text(); + QString contrasena=ui->CONTRASENA->text(); + QString nivel="1"; + QString vidas="6"; + QString llaves="0"; + QString tiempo="313"; + QListcont_nivel={contrasena,nivel}; +//---------------------------------ABRE REGISTRO PARA VERIFICAR EN QUE NIVEL ESTÁ + QFile archivo ("D:/E-MEDIEVAL/E-MEDIEVAL/REGISTRO/registro.txt"); + //QFile cambios("D:/E-MEDIEVAL/E-MEDIEVAL/REGISTRO/REGISTRO/cambios.txt"); + archivo.open(QIODevice::ReadOnly | QIODevice::Text); + //cambios.open(QIODevice::ReadOnly | QIODevice::Text); + + // QTextStream escribir (&archivo); + + QTextStream datosArchivo (&archivo); + + // QTextStream escribir (&cambios); + + //QTextStream datosArchivo (&cambios); + + + while (!datosArchivo.atEnd()) + { + + datosArchivo>>ArchivoUsuario>>passArchivo>>nivelUsuario>>modo>>Vidas>>Llaves>>Tiempoj>>endl; + + + + + if (usuario==ArchivoUsuario) + { + + + if (contrasena==passArchivo) + { + //qDebug()<<"NIVEL USUARIO"<setNombre(usuario); + user->setContrasena(contrasena); + user->setNivel(nivel); + user->setModoDeJuego(modo); + user->setTIEMPO(Tiempoj); + MainWindow *EM= new MainWindow (); + EM->setUser(user); + level=nivelUsuario.toInt(); + LIFE=Vidas.toInt(); + llavecita=Llaves.toInt(); + jugadores=modo.toInt(); + tiempoj=Tiempoj.toInt(); + EM->setnivel(level); + EM->SETMODO(jugadores); + EM->VIDAS(LIFE); + EM->LLAVES(llavecita); + EM->TIEMPO(tiempoj); + EM->show(); + + + + } + + + } + } + if (ban==1) + { + ban=0; + hide(); + QMessageBox::warning(this, tr("NO SE PUEDE INGRESAR"), + tr("USUARIO NO REGISTRADO"), + + QMessageBox::Cancel); + + } +} + +/*int Verificar::cargarText() +{ + return level; +}*/ diff --git a/verificar.h b/verificar.h new file mode 100644 index 0000000..8dfa99f --- /dev/null +++ b/verificar.h @@ -0,0 +1,51 @@ +#ifndef VERIFICAR_H +#define VERIFICAR_H + +#include +#include +#include +#include +#include +#include +#include +namespace Ui { +class Verificar; +} + +class Verificar : public QDialog +{ + Q_OBJECT + +public: + explicit Verificar(QWidget *parent = nullptr); + ~Verificar(); + QString passArchivo; + QString archivoUsuario; + QString nivelUsuario; + QString modo; + QString Vidas; + QString Llaves; + QString Tiempoj; + //int cargarText(); +private slots: + void on_pushButton_clicked(); + + +private: + Ui::Verificar *ui; + QGraphicsScene *scene; + // QMainWindow *juego; + int ban=1; + int level; + int LIFE; + int llavecita; + int tiempoj; + int jugadores; + //QString *nivel; + QString ArchivoUsuario; + //MainWindow *EM; + Usuario *user; + +}; + +#endif // VERIFICAR_H diff --git a/verificar.ui b/verificar.ui new file mode 100644 index 0000000..a272ee2 --- /dev/null +++ b/verificar.ui @@ -0,0 +1,101 @@ + + + Verificar + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 20 + 20 + 361 + 261 + + + + + + + 50 + 80 + 111 + 20 + + + + INGRESE EL USUARIO + + + + + + 40 + 160 + 131 + 16 + + + + INGRESE LA CONTRASEÑA + + + + + + 150 + 230 + 91 + 23 + + + + INICIAR JUEGO + + + + + + 230 + 80 + 113 + 20 + + + + + + + 230 + 160 + 113 + 20 + + + + + + + 170 + 30 + 81 + 20 + + + + VERIFICANDO + + + + + + diff --git a/vidas.cpp b/vidas.cpp new file mode 100644 index 0000000..6ff3d4d --- /dev/null +++ b/vidas.cpp @@ -0,0 +1,32 @@ +#include "vidas.h" + +#include + +vidas::vidas(QGraphicsItem *parent): QGraphicsTextItem(parent) +{ + //inicializar las vidas en 3 + life = 3; + + //ESCRIBIR EL TEXTO + setPlainText(QString("Vidas: ")+QString::number(life)); + setDefaultTextColor(Qt::red); + setFont(QFont("times",16)); + +} + +void vidas::decrease() +{ + life--; + setPlainText(QString("Vidas: ")+QString::number(life)); +} + +int vidas::getlife() +{ + return life; +} + +void vidas::setLife(int value) +{ + life = value; + setPlainText(QString("Vidas: ")+QString::number(life)); +} diff --git a/vidas.h b/vidas.h new file mode 100644 index 0000000..3b6aa5a --- /dev/null +++ b/vidas.h @@ -0,0 +1,25 @@ +#ifndef VIDAS_H +#define VIDAS_H + +#include + + +class vidas: public QGraphicsTextItem +{ + +public: + + vidas(QGraphicsItem * parent=0); + + void decrease(); + int getlife(); + + void setLife(int value); + +private: + + int life; + +}; + +#endif // VIDAS_H diff --git a/win.cpp b/win.cpp new file mode 100644 index 0000000..cd50a82 --- /dev/null +++ b/win.cpp @@ -0,0 +1,14 @@ +#include "win.h" +#include "ui_win.h" + +Win::Win(QWidget *parent) : + QDialog(parent), + ui(new Ui::Win) +{ + ui->setupUi(this); +} + +Win::~Win() +{ + delete ui; +} diff --git a/win.h b/win.h new file mode 100644 index 0000000..8503f8a --- /dev/null +++ b/win.h @@ -0,0 +1,22 @@ +#ifndef WIN_H +#define WIN_H + +#include + +namespace Ui { +class Win; +} + +class Win : public QDialog +{ + Q_OBJECT + +public: + explicit Win(QWidget *parent = 0); + ~Win(); + +private: + Ui::Win *ui; +}; + +#endif // WIN_H diff --git a/win.ui b/win.ui new file mode 100644 index 0000000..3979150 --- /dev/null +++ b/win.ui @@ -0,0 +1,36 @@ + + + Win + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 70 + 110 + 256 + 71 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:28pt;">GANASTE</span></p></body></html> + + + + + +