コード例 #1
0
ファイル: main.cpp プロジェクト: ycrichard/Vintage-GL
void LabyClavierSpecial(int key,int x,int y)
{
	switch(key)
	{
	case GLUT_KEY_UP:{
		MonJoueur.BougerEnHaut();
					 break;}
	case GLUT_KEY_DOWN:{
		MonJoueur.BougerEnBas();
					  break;}
	case GLUT_KEY_LEFT:{
		MonJoueur.BougerAGauche();
					   break;}
	case GLUT_KEY_RIGHT:{
		MonJoueur.BougerADroite();
						break;}
	}

	EnnemiBase* pointeur=premierEnnemi;
	while(pointeur!= NULL)
	{
		pointeur->TestCollision();
		pointeur=pointeur->GetSuivant();
	}
	TestVictoire();
	glutPostRedisplay();
}
コード例 #2
0
ファイル: interface.cpp プロジェクト: xabufr/monopoly
void Interface::m_show_window_detruire()
{
    Joueur *joueur = m_plateau->getPlateau()->getJoueurTour();
    if (m_window_detruire)
    {
        m_window_detruire->ResetContener();
        int x=0;
        int y=0;
        for (CasePropriete* m_case : joueur->proprietes())
        {
            if (m_case->peutDetruire())
            {
                GuiButtonItem *button = new GuiButtonItem;
                button->SetCharacterSize(18);
                button->SetText(m_case->nom());
                button->SetData("case", m_case);
                button->SetData("this", this);
                button->SetCallBack("clicked", Interface::detruire);
                button->SetNormalColor(sf::Color(0,0,0), sf::Color(0,0,0,0));
                button->SetMouseOverColor(sf::Color(255,0,0), sf::Color(0,0,0,0));
                m_window_detruire->GetContener()->AjouterItem(button, 0, x);
                ++x;
            }
        }
        m_window_detruire->CalculerTaille();
        x = (m_engine->GetRenderWindow()->getSize().x/2)-(m_window_detruire->GetContener()->GetSize().x/2);
        y = (m_engine->GetRenderWindow()->getSize().y/2)-(m_window_detruire->GetContener()->GetSize().y/2);
        m_window_detruire->SetRelativePosition(x, y);
        m_window_detruire->SetVisible(true);
    }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: ycrichard/Vintage-GL
void OuvrirNiveau(string nom_fichier)
{
	ifstream f;
	f.open(nom_fichier.c_str());

	if(!f)
	{
		cout<< "Error when open the level file !"<<endl;
		#ifdef _WIN32
            system("pause");
        #else
            cout<<"Press enter to continue > "<<endl;
            getchar();
        #endif
		exit(0);
	}

	f>> NbColonnes;
	f>> NbLignes;

	matrice= new char* [NbLignes];
	for(int i=0;i<NbLignes;i++)
		matrice[i]= new char[NbColonnes];


	for(int i=0;i<NbLignes;i++)
		for(int j=0;j<NbColonnes;j++)
			matrice[i][j]= '0';

	for(int i=0;i<NbLignes;i++)
		for(int j=0;j<NbColonnes;j++)
		{
			f>> matrice[i][j];

			switch(matrice[i][j])
			{
			case 'j':
			case 'J':{
				MonJoueur.SetPosC(j);
				MonJoueur.SetPosL(i);
				break;}
			case 's':
			case 'S':{
				SortieC = j;
				SortieL = i;
				break;}
			case 'v':
			case 'V':{
				AddEnnemi(vert,j,i);
				break;}
			case 'r':
			case 'R':{
				AddEnnemi(rouge,j,i);
				break;}
			}
		}
	f.close();
}
コード例 #4
0
bool ShakeManager::rechercherMouvement(Score *scoreJoueur, Mat threshold, Mat HSV, Mat &cameraFeed, Rect const &fleche){

    vector <Joueur> mouvements;

    Mat temp;
    threshold.copyTo(temp);
    vector< vector<Point> > contours;
    vector<Vec4i> hierarchy;
    findContours(temp, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

    bool mouvementTrouver = false;
    if (hierarchy.size() > 0) {

        int numObjects = hierarchy.size();

        if (numObjects<MAX_MOUVEMENT){
            for (int index = 0; index >= 0; index = hierarchy[index][0]) {

                Moments moment = moments((cv::Mat)contours[index]);
                double area = moment.m00;

                if (area>MIN_OBJECT_AREA){

                    Joueur mouvement;

                    mouvement.setXPos(moment.m10 / area);
                    mouvement.setYPos(moment.m01 / area);

                    mouvements.push_back(mouvement);

                    if (mouvement.getXPos() >= fleche.x && mouvement.getXPos() < (fleche.x + 105) && mouvement.getYPos() >= fleche.y && mouvement.getYPos() < (fleche.y + 105)){
                        if(son->mediaStatus() == QMediaPlayer::PlayingState)
                            son->stop();
                        son->setMedia(QUrl("qrc:/sounds/power-up.wav"));
                        son->setVolume(5);
                        son->play();
                        scoreJoueur->addToScore(10);
                        return true;
                    }

                    mouvementTrouver = true;

                }
                else mouvementTrouver = false;

            }

            afficherMouvement(mouvements, cameraFeed);

        }
    }
    // le rectangle n'a pas été trouvé
    return false;
}
コード例 #5
0
ファイル: Objet.cpp プロジェクト: eduardok/ZeldaOLB
void Objet::draw(SDL_Surface* gpScreen) {
    int phg[2];
    phg[0] = gpJeu->getPhg(0);
    phg[1] = gpJeu->getPhg(1);
    
    Joueur* gpJoueur = gpJeu->getJoueur();
    Monde* gpMonde = gpJeu->getMonde();
    int val = gpMonde->motifValue(x+8,y+8);
    
    if (type && vie && (val<30 || val>39)) {
            
        SDL_Rect src; src.h = h; src.w = w;
        SDL_Rect dst; dst.x = x-phg[0]; dst.y = y-phg[1];    
       
        
        switch(type) {                
            case I_RUBIS_VERT : src.x = anim*16; src.y = 17; break;
            case I_RUBIS_BLEU : src.x = 48 + anim*16; src.y = 17; break;
            case I_RUBIS_ROUGE : src.x = anim*16; src.y = 34; break;
            case I_PETIT_COEUR : src.x = 48; src.y = 34; break;
            case I_FLECHE : if (gpJoueur->hasObjet(O_ARC) < 5) {src.x = 64; src.y = 34;}
                if (gpJoueur->hasObjet(O_ARC) == 5) {src.x = 208; src.y = 17;} break;
            case I_BOMBE : src.x = 0; src.y = 0; break;
            case I_MAGIE_PEU : src.x = 80; src.y = 34; break;
            case I_MAGIE_BCP : src.x = 96; src.y = 34; break;
            case I_QUART_COEUR : src.x = 80; src.y = 0; break;
            case I_COEUR : src.x = 64; src.y = 0; break;
            case I_EPEE : src.x = 96; src.y = 17; break;
            case I_CRISTAL : src.x = anim*16; src.y = 51; break;
            case I_EXCALIBUR : src.x = 160;src.y = 0; src.h = 22; src.w = 16; break;
            case I_PETITE_CLE : src.x = 32; src.y = 0; break;
            case I_TRIFORCE : src.x = 166; src.y = 26; src.h = 25;src.w = 26; break;
            case I_ARC : src.x = 144; src.y = 34; break;
        }
        
        w=src.w; h=src.h;
    
        SDL_BlitSurface(image, &src, gpScreen, &dst);
    
        if(max){    
            if(SDL_GetTicks() > lastAnimTime + vanim) {
            lastAnimTime = SDL_GetTicks();
                anim++;
                if (anim > max) anim = 0;
            }
        }
    }
    
    if (suivant != NULL) 
        if (((Objet*)suivant)->vie == 0) enleve(suivant);
    if (suivant != NULL) ((Objet*)suivant)->draw(gpScreen);
}
コード例 #6
0
ファイル: ReceptionClient.cpp プロジェクト: azazel7/Jinn
string ReceptionClient::traitementInfoJoueur()
{
    char* argument[6] = {NULL};
    int manaActuel = -1, manaMax = -1, gainMana = -1, abilite = -1, niveauAbilite = -1;
    Joueur* joueur;
    for(int i = 0; i < 7; i++)
    {
        argument[i] = strtok (NULL, SEPARATEUR_ELEMENT);
        if(argument[i] == NULL)
        {
            //Info fausse
            return "";
        }
    }

    manaActuel = atoi(argument[2]);
    manaMax = atoi(argument[3]);
    gainMana = atoi(argument[4]);
    abilite = atoi(argument[5]);
    niveauAbilite = atoi(argument[6]);

    joueur = this->partie->getJoueur(argument[0]);
    if(joueur == NULL)
    {
        joueur = new Joueur(gainMana, manaMax, niveauAbilite, argument[0], (TypeSort) abilite);
        joueur->setManaActuel(manaActuel);
        if(strcmp(argument[1], CHAMPS_VIDE) != 0)
        {
            joueur->setEquipe(this->partie->getEquipe(argument[1]));
        }
        this->partie->ajouterJoueur(joueur);
    }
    else
    {
        if(manaMax != -1)
        {
            joueur->setManaMaximum(manaMax);
        }
        if(manaActuel != -1)
        {
            joueur->setManaActuel(manaActuel);
        }
        if(gainMana != -1)
        {
            joueur->setGainMana(gainMana);
        }
        if(abilite != -1)
        {
            joueur->setAbilite((TypeSort) abilite);
        }
        if(niveauAbilite != -1)
        {
            joueur->setNiveauAbilite(niveauAbilite);
        }
    }
    return joueur->getNom();
}
コード例 #7
0
int main()
{

  Personnage* guerrier = new Guerrier();
  cout << guerrier->toString();
  Joueur* Pierre = new Joueur("Pierre", *guerrier,"test.txt");
  cout << Pierre->getDeck()->tirerCarte().toString() << endl;
  Pierre->getPersonnage().setCP(new ComportementPouvoirGuerrier());
  cout << Pierre->getPersonnage().utiliserPouvoir() << endl;
 

  return 0;
}
コード例 #8
0
ファイル: Table.cpp プロジェクト: jlagniez/serveurPoker
void Table::addJoueur(Spectateur* s, char* aConvertir){
  int place=-1;
  int jeton=-1;
  if(isServeur && convertirCharDeJoueur(aConvertir,s,place,jeton)){
    Joueur* j = new Joueur(*s, jeton);
    cout<<"Le nouveau joueur est: "<<j->getNom()<<endl;
    joueurs[place] = j;
    if(partieEnCours)
      actif[place]=true;
    else
      actif[place]=false;
    nbJoueur++;
    stringstream ss;
    ss<<place;
    string newJoueur = "NewJo";
    newJoueur+=separateur;
    newJoueur+=ss.str();
    newJoueur+=separateur;
    newJoueur+=j->getNom();
    newJoueur+=separateur;
    stringstream ssa;
    ssa<<j->getJeton();
    newJoueur+=ssa.str();
    newJoueur+=separateur;
    newJoueur+="0";
    newJoueur+=separateur;
    newJoueur+="t";
    newJoueur+=separateur;
    cout<<newJoueur<<endl;
    char nJ[100] = "";
    strcpy(nJ,newJoueur.c_str());
    for(int i=0; i<spectacteurs.size();i++){
      send(spectacteurs[i]->getDesc(),nJ, strlen(nJ),0);
    }
    char jEnPlus[]="NewJo&";
    write(descEnvoie,jEnPlus,10);
    if(!partieEnCours && nbJoueur>1){
      partieEnCours=true;
      lancerPartie();
    }
    else{
      if(!partieEnCours){
	//prochainAMiser=place;
	dealer=place;
      }
    }
  }
}
コード例 #9
0
ファイル: interface.cpp プロジェクト: xabufr/monopoly
void Interface::deshypothequer_propriete(GuiItem* g)
{
    ((CasePropriete*)g->GetData("case"))->deshypothequer();
    ((Interface*)g->GetData("this"))->m_show_window_deshypothequer();
    Joueur *joueur = ((Interface*)g->GetData("this"))->m_plateau->getPlateau()->getJoueurTour();
    int cpt=0;
    for (CasePropriete* c : joueur->proprietes())
        if (!c->estEnHypotheque())
            ++cpt;

    if (cpt == joueur->proprietes().size())
    {
        ((Interface*)g->GetData("this"))->m_window_deshypothequer->Remove();
        ((Interface*)g->GetData("this"))->m_window_deshypothequer = nullptr;
        ((Interface*)g->GetData("this"))->m_deshypothequer = false;
    }
}
コード例 #10
0
ファイル: main.cpp プロジェクト: ycrichard/Vintage-GL
void TestVictoire()
{
	if(MonJoueur.GetPosC()==SortieC && MonJoueur.GetPosL()==SortieL)
	{
		LabyAffichage();			//refraîchir la scène manuellement
		glutExit();
		LibererMemoire();
		cout<<"Congratulations! You win!"<<endl;
		#ifdef _WIN32
            system("pause");
        #else
            cout<<"Press enter to continue > "<<endl;
            getchar();
        #endif
		exit(0);
	}
}
コード例 #11
0
ファイル: interface.cpp プロジェクト: xabufr/monopoly
void Interface::detruire(GuiItem* g)
{
    Joueur *joueur = ((Interface*)g->GetData("this"))->m_plateau->getPlateau()->getJoueurTour();
    ((CaseTerrain*)g->GetData("case"))->vendre(joueur);
    ((Interface*)g->GetData("this"))->m_show_window_detruire();
    int cpt=0;
    for (CasePropriete* c : joueur->proprietes())
        if (!c->peutDetruire())
            ++cpt;

    if (cpt == joueur->proprietes().size())
    {
        ((Interface*)g->GetData("this"))->m_window_detruire->Remove();
        ((Interface*)g->GetData("this"))->m_window_detruire = nullptr;
        ((Interface*)g->GetData("this"))->m_detruire = false;
    }
}
コード例 #12
0
ファイル: Pnj.cpp プロジェクト: eduardok/ZeldaROTH
void Pnj::suit() {
    Joueur* gpJoueur = gpJeu->getJoueur();
    int pnjCX = x + gpZoneBase->getZone()->x + (gpZoneBase->getZone()->w/2);
    int pnjCY = y + gpZoneBase->getZone()->y + (gpZoneBase->getZone()->h);
    int linkCX = gpJoueur->getX() + 8;
    int linkCY = gpJoueur->getY() + 24;
    int difx = pnjCX - linkCX;
    int dify = pnjCY - linkCY;
    
    //test portée
    
    
    if ( max(abs(difx),abs(dify))>128) {
        if (gpJoueur->getAvancement()==6) gpJoueur->setAvancement(5);
        return;
    }
//    if (max(abs(difx),abs(dify))<16) return;
    if (gpJoueur->getAvancement()==5) gpJoueur->setAvancement(6);
    
    if (abs(difx) > abs(dify)) {
        if (difx>0) direction=O;
        else direction=E;
    }
    else {
        if (dify>0) direction=N;
        else direction=S;
    }
    
    if (gpJeu->getJoueur()->getX() < x) moveX(-1);
    if (gpJeu->getJoueur()->getX() > x) moveX(1);
    if (gpJeu->getJoueur()->getY() < y) moveY(-1);
    if (gpJeu->getJoueur()->getY() > y) moveY(1);
}
/*!
* \brief méthode pour détruire un quartier
* \param partie la partie
* \param joueur le joueur
*/
void ComportementCondottiereMachine::choixDestruction(Partie * partie , Joueur * joueur) {
    vector<Joueur*> tmp = partie->recupererListeJoueurs();
    vector<int> exclus;
    int i;
    Joueur * jj;
    bool trouve =false;

    while(exclus.size() < tmp.size() && !trouve) {
        i = Aleatoire::tirerEntierAvecExclusion(exclus,0,tmp.size()-1);
        jj = tmp.at(i);
        if(jj != joueur) {
            vector<Quartier*> qq= jj->recupererCite();

            for(vector<Quartier*>::iterator iter=qq.begin(); iter!=qq.end(); ++iter) {
                if(Condottiere::destruction(joueur,jj,(*iter))) {
                    trouve = true;
                }
            }
        }
    }
}
コード例 #14
0
ファイル: Puissance4.cpp プロジェクト: tsalmon/LOA
void Puissance4::newPartie (){
  Plateau *p = Partie::getPartie()->getPlateau();
  Joueur *j = Partie::getPartie()->getJoueurs();
  int choix_pos = 0;
    int i=0;
  j->next();
  do{
    j->next();
    cout << "Joueur "<< j->getCourrant()<< endl;
    affichage();
    do{
      i = 0;
      cout << "choisissez une position : " << endl;
      cin >> choix_pos;
      for(;i < nbLignes && not p->hasPion(i, choix_pos); i++){}
    }while(choix_pos < 0 || 
	   choix_pos > nbLignes || 
	   (i == 0 && p->hasPion(choix_pos, i)));
    i = (i==0)? 0 : i-1;
    if(j->getCourrant() == 0){
      p->mettrePionDansCase(pO, i, choix_pos);
    } else {
      p->mettrePionDansCase(pX, i, choix_pos);
    }
  }while(not hasP4(i, choix_pos));
  affichage();
  cout << "Le joueur " << j->getCourrant() << "a gagné "<<  endl; 
  
}
コード例 #15
0
ファイル: Pnj.cpp プロジェクト: eduardok/ZeldaROTH
bool Pnj::parle() {
    Joueur* gpJoueur = gpJeu->getJoueur();
    int difx = (gpJoueur->getX()+8)-(x+(w/2));
    int dify = (gpJoueur->getY()+16)-(y+(h/2));
    
    if (abs(difx) < 24 && abs(dify) < 24) {
        if (abs(difx) < abs(dify)) {
            if (dify < 0) direction = N;
            else direction = S;
        }
        else {
            if (difx < 0) direction = O;
            else direction = E;
        }
        return true;
    }
    return false;
    
    if (gpJeu->isLink(x + gpZoneBase->getZone()->x-8, 
    y + gpZoneBase->getZone()->y+gpZoneBase->getZone()->h-8, 1, 1)) {
        direction = O;
        return true;
    }
    if (gpJeu->isLink(x + gpZoneBase->getZone()->x+gpZoneBase->getZone()->w+7, 
    y + gpZoneBase->getZone()->y+gpZoneBase->getZone()->h-8, 1, 1)) {
        direction = E;
        return true;
    }
    if (gpJeu->isLink(x + gpZoneBase->getZone()->x, y + gpZoneBase->getZone()->y-8, 1, 1)) {
        direction = N;
        return true;
    }
    if (gpJeu->isLink(x + gpZoneBase->getZone()->x, 
    y + gpZoneBase->getZone()->y+gpZoneBase->getZone()->h+7, 1, 1)) {
        direction = S;
        return true;
    }
    return false;
}
コード例 #16
0
ファイル: Menu.cpp プロジェクト: nop90/ZeldaOLB
void Menu::drawCurseur(SDL_Surface* gpScreen) {
    int dec = 200-val;
    
    SDL_Rect src;
    SDL_Rect dst;
    
    Joueur* gpJoueur = gpJeu->getJoueur();
    
    src.w=32; src.h=32; src.y=0;
    //curseur
    if (anim==1) {
        if ((gpJoueur->getTypeAnim()<4 || gpJoueur->getTypeAnim()>20) && !gpJoueur->getOni()) 
            src.x=48; else src.x=80;
        dst.x=24+32*(gpJoueur->getObjet()%3)-dec; 
        dst.y=24+32*(gpJoueur->getObjet()/3);
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageCadre, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
}
コード例 #17
0
ファイル: jeu.cpp プロジェクト: jaysonlopez28/pentago
void Jeu::jouer()
{
        _utiliseIHM = false;
        while(true) {
                Joueur * joueur = _etat.getJoueurCourant();
                if(_etat.getProchainMouvement() == Etat::Poser) {
                        cout << "Joueur " << joueur->getNom() << " place un pion..." << endl;
                        if(joueur->placePion()) {
                                _utiliseIHM = true;
                                return;
                        }
                } else if(_etat.getProchainMouvement() == Etat::Tourner) {
                        cout << "Joueur " << joueur->getNom() << " tourne un plateau..." << endl;
                        if(joueur->tournePlateau()) {
                                _utiliseIHM = true;
                                return;
                        }
                } else { // mouvement == Termine || mouvement == Egalite
                        cout << "Partie terminee !" << endl;
                        notifieIHM();
                        return;
                }
        }
}
コード例 #18
0
ファイル: main.cpp プロジェクト: ycrichard/Vintage-GL
void LabyAffichage()
{
	glClearColor(1.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);

	DessinerNiveau();
	MonJoueur.Dessiner();

	EnnemiBase* pointeur=premierEnnemi;
	while(pointeur!= NULL)
	{
		pointeur->Dessiner();
		pointeur=pointeur->GetSuivant();
	}
	//glFlush();
	glutSwapBuffers();		//for GLUT_DOUBLE
}
コード例 #19
0
ファイル: evenement.cpp プロジェクト: Noxy/ProjetCpp
Uint32 gestionAction(Uint32 intervalle, void *arg)
{
    ObjetMap *temp, *cible;
    Unite *n;

    for(int i=0;i< m->getvec().size();i++)
    {
        temp=m->getvec()[i];
        if(temp->gettype()==PEON || temp->gettype()==LANCIER)
        {
            SDL_mutexP(mutexObjet);
            n = (Unite*)temp;
            if(n->getStatut()==DEPLACEMENT)
            {
                point coordActuel=n->getc1(), coordDesti=n->getdesti();
                if(coordActuel.x==coordDesti.x && coordActuel.y==coordDesti.y)
                {
                    n->setStatut(AFK);
                    n->setCible(NULL);
                }
                else
                {
                    deplaceToi(n, coordDesti.x, coordDesti.y);
                }

            }
            if(n->getStatut()==COLLECTE)
            {
                point coordActuel=n->getc1(), coordDesti=(n->getcible())->getc1();
                if(abs(coordActuel.x-coordDesti.x)<=1 && abs(coordActuel.y-coordDesti.y)<=1)
                {
                    cible=n->getcible();
                    cible->setpv(cible->getpv()-1);
                    if(cible->gettype()==BLE)
                    {
                        joueur1.setmiam(joueur1.getmiam()+1);
                    }
                    else
                    {
                        joueur1.setbois(joueur1.getbois()+1);
                    }
                 }
                 else
                 {
                     deplaceToi(n, coordDesti.x, coordDesti.y);
                 }
            }
            if(n->getStatut()==ATTAQUE)
            {
                point coordActuel=n->getc1(), coordDesti=(n->getcible())->getc1();
                if(abs(coordActuel.x-coordDesti.x)<=1 && abs(coordActuel.y-coordDesti.y)<=1)
                {
                    cible=n->getcible();
                    cible->setpv(cible->getpv()-n->getPa());
                 }
                 else
                 {
                     deplaceToi(n, coordDesti.x, coordDesti.y);
                 }
            }
            SDL_mutexV(mutexObjet);
        }
    }
    return intervalle;
}
コード例 #20
0
ファイル: interface.cpp プロジェクト: xabufr/monopoly
void Interface::liberer(GuiItem* g)
{
    Joueur *joueur = ((Interface*)g->GetData("this"))->m_plateau->getPlateau()->getJoueurTour();
    joueur->cartesLiberte().back()->utiliser();
}
コード例 #21
0
ファイル: interface.cpp プロジェクト: xabufr/monopoly
void Interface::achat(GuiItem* g)
{
    Joueur *joueur = ((Interface*)g->GetData("this"))->m_plateau->getPlateau()->getJoueurTour();
    joueur->estSur()->acheter(joueur);
}
コード例 #22
0
ファイル: interface.cpp プロジェクト: xabufr/monopoly
void Interface::update()
{
    int x, y;
    x=y=0;
    m_button_achat->SetVisible(false);
    m_button_hypothequer->SetVisible(false);
    m_button_deshypothequer->SetVisible(false);
    m_button_construire->SetVisible(false);
    m_button_detruire->SetVisible(false);
    m_button_liberer->SetVisible(false);
    m_button_caution->SetVisible(false);
    Joueur *joueur = m_plateau->getPlateau()->getJoueurTour();

	m_infoCase->SetText(joueur->nom()+" est sur : " + joueur->estSur()->nom()+"\n"+joueur->estSur()->description());

    if (dynamic_cast<CasePropriete*>(joueur->estSur()) && !((CasePropriete*)(joueur->estSur()))->estAchete()
        && joueur->argent() > ((CasePropriete*)(joueur->estSur()))->prixAchat())
        m_button_achat->SetVisible(true);

    if (joueur->estEnPrison() && joueur->cartesLiberte().size() != 0)
       m_button_liberer->SetVisible(true);

    if (joueur->estEnPrison() && joueur->getToursPrison() != 0)
        m_button_caution->SetVisible(true);

    for (CasePropriete *m_case : joueur->proprietes())
    {
        if (!m_case->estEnHypotheque())
            m_button_hypothequer->SetVisible(true);
        if (m_case->estEnHypotheque())
            m_button_deshypothequer->SetVisible(true);
        if (m_case->peutConstruire() && joueur->argent() > ((CasePropriete*)(joueur->estSur()))->prixAchat())
            m_button_construire->SetVisible(true);
        if (m_case->peutDetruire())
            m_button_detruire->SetVisible(true);
    }
	Carte* carte = joueur->lastCarte();
	joueur->setLastCarte(nullptr);

	if(carte && !dynamic_cast<Payer_ou_tirer*>(carte))
		m_lastInfos = joueur->nom()+":\nCarte " + carte->paquet()->nom() + "\n" + carte->description();

	if (dynamic_cast<Payer_ou_tirer*>(carte))
    {
        new MessageBox("Carte "+carte->paquet()->nom(), carte->description(), m_plateau->getPlateau(), dynamic_cast<Payer_ou_tirer*>(carte), m_button_des);
        m_button_des->SetVisible(false);
    }

    if (m_window_hypothequer && m_window_deshypothequer && m_window_construire && m_window_detruire)
    {
        if (m_window_hypothequer->IsVisible() || m_window_deshypothequer->IsVisible() || m_window_construire->IsVisible() || m_window_detruire->IsVisible())
            m_button_des->SetVisible(false);
    }
    else
        m_button_des->SetVisible(true);

    if (!m_window_hypothequer)
    {
        m_window_hypothequer = m_engine->GetGuiManager()->GetRootNode()->AddWindow();
        m_window_hypothequer->SetCharacterSizeTitle(22);
        m_window_hypothequer->SetWindowTitle("Hypotéquer");
        m_window_hypothequer->SetColorShape(sf::Color(255, 255, 255));
        m_window_hypothequer->SetColorOutlineShape(sf::Color(255, 0, 0));
        m_window_hypothequer->SetColorContener(sf::Color(255, 255, 255));
        m_window_hypothequer->SetColorOutlineContener(sf::Color(255, 0, 0));
        m_window_hypothequer->SetClosable(true);
        m_window_hypothequer->CloseItem()->SetData("this", this);
        m_window_hypothequer->CloseItem()->SetCallBack("onClosed", Interface::closeHypotheque);
        m_window_hypothequer->SetVisible(false);
    }

    if(!m_window_deshypothequer)
    {
        m_window_deshypothequer = m_engine->GetGuiManager()->GetRootNode()->AddWindow();
        m_window_deshypothequer->SetCharacterSizeTitle(22);
        m_window_deshypothequer->SetWindowTitle("Deshypothéquer");
        m_window_deshypothequer->SetColorShape(sf::Color(255, 255, 255));
        m_window_deshypothequer->SetColorOutlineShape(sf::Color(255, 0, 0));
        m_window_deshypothequer->SetColorContener(sf::Color(255, 255, 255));
        m_window_deshypothequer->SetColorOutlineContener(sf::Color(255, 0, 0));
        m_window_deshypothequer->SetClosable(true);
        m_window_deshypothequer->CloseItem()->SetData("this", this);
        m_window_deshypothequer->CloseItem()->SetCallBack("onClosed", Interface::closeDeshypotheque);
        m_window_deshypothequer->SetVisible(false);
    }

    if(!m_window_construire)
    {
        m_window_construire = m_engine->GetGuiManager()->GetRootNode()->AddWindow();
        m_window_construire->SetCharacterSizeTitle(22);
        m_window_construire->SetWindowTitle("Construire");
        m_window_construire->SetColorShape(sf::Color(255, 255, 255));
        m_window_construire->SetColorOutlineShape(sf::Color(255, 0, 0));
        m_window_construire->SetColorContener(sf::Color(255, 255, 255));
        m_window_construire->SetColorOutlineContener(sf::Color(255, 0, 0));
        m_window_construire->SetClosable(true);
        m_window_construire->CloseItem()->SetData("this", this);
        m_window_construire->CloseItem()->SetCallBack("onClosed", Interface::closeConstruire);
        m_window_construire->SetVisible(false);
    }

    if(!m_window_detruire)
    {
        m_window_detruire = m_engine->GetGuiManager()->GetRootNode()->AddWindow();
        m_window_detruire->SetCharacterSizeTitle(22);
        m_window_detruire->SetWindowTitle("Détruire");
        m_window_detruire->SetColorShape(sf::Color(255, 255, 255));
        m_window_detruire->SetColorOutlineShape(sf::Color(255, 0, 0));
        m_window_detruire->SetColorContener(sf::Color(255, 255, 255));
        m_window_detruire->SetColorOutlineContener(sf::Color(255, 0, 0));
        m_window_detruire->SetClosable(true);
        m_window_detruire->CloseItem()->SetData("this", this);
        m_window_detruire->CloseItem()->SetCallBack("onClosed", Interface::closeDetruire);
        m_window_detruire->SetVisible(false);
    }
	m_info->SetText(m_lastInfos);
}
コード例 #23
0
ファイル: Keyboard.cpp プロジェクト: eduardok/Zelda3T
void Keyboard::pollKeys(Uint8* keys) {
    Joueur* gpJoueur;
    int vit;
    int avance;
    int nbdir;
    switch (mode) {
        case 0 :
            if (gpJeu->getMonde()->isChangeTemps()) return;
            
            gpJoueur = gpJeu->getJoueur();
            
            if (keys[SDLK_RETURN] && tmp == 0) {
                if (gpJoueur->getTypeAnim() == MORT) gpJoueur->revie();
                else if (!gpJeu->getStop() && !gpJeu->getMenu()) gpJeu->setMenu(true);
                else if (gpJeu->getMenu()) gpJeu->setMenu(false);
                else if (gpJeu->getText() && !gpJeu->getTransition()) 
                    gpJeu->setText(gpJeu->getTexte()->suite());
                tmp = 1;
            }
            if ((!keys[SDLK_RETURN] && !gpJeu->getMenu()) || (gpJeu->getMenu() 
            && !keys[SDLK_RETURN] && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] 
            && !keys[SDLK_UP] && !keys[SDLK_DOWN])) tmp=0;
            
            if (gpJeu->getText() && gpJeu->getTexte()->isFinished()) {
                if(tmpt==0){
                    tmpt=1;
                    switch (gpJeu->getTexte()->getId()) {
                        case 77 : case 80 : case 83 : case 86 : case 89 : case 92 : case 96 :
                        case 99 : case 102 : case 107 : case 126 : case 129 : case 132 : 
                        case 135 : case 138 : case 141 : case 144 : case 147 : case 150 :
                        case 159 : case 162 : case 165 : case 168 : case 171 : case 180 :
                        case 191 : case 204 : case 215 : case 218 : case 220 : case 222 :
                        case 228 : case 230 : case 232 : case 234 : case 240 : case 245 :
                        case 251 : case 265 : case 268 : case 271 : case 273 : case 278 : 
                        case 281 : case 290 : case 299 : case 309 : case 351 : case 356 : 
                        case 368 : case 370 : case 376 : case 378 : case 380 : case 383 : 
                        case 387 : case 390 : case 393 : case 395 : case 398 : case 400 : 
                        case 403 : case 413 : case 415 : case 426 : case 433 : case 447 :
                        case 451 : case 461 : case 464 : case 467 : case 470 : case 473 : 
                        case 506 : case 524 : case 530 : case 555 : case 561 : case 569 : 
                        case 576 : case 581 : case 586 : case 593 : case 600 : case 605 : 
                        case 614 : case 641 : case 643 : case 645 : case 647 : case 649 : 
                        case 678 : case 680 : case 688 : case 701 : case 706 : case 721 : 
                        case 728 : case 734 : case 740 : case 750 : case 752 : case 754 : 
                        case 756 : case 758 : case 767 : case 769 : case 780 : case 789 : 
                        case 823 : case 834 : case 859 : case 888 : case 896 : case 908 : 
                        case 916 : case 1048: case 1085: case 1114: case 1120: case 1126:
                        case 1132: case 1139: case 1141: case 1145: case 1154: case 1158:
                        case 1162: case 1166: case 1170: case 1174: case 1178: case 1182: 
                        case 1186: case 1190: case 1194: case 1198: case 1202: case 1206: 
                        case 1210: case 1214: case 1218: case 1222: case 1226: case 1230: 
                        case 1234: case 1238: case 1242: case 1246: case 1250: case 1254: 
                        case 1258: case 1262: case 1266: case 1270: case 1274: case 1278: 
                        case 1282: case 1286: case 1290: case 1294: case 1298: case 1302: 
                        case 1306: case 1310: case 1314: case 1327:
                            if (keys[SDLK_LEFT] || keys[SDLK_RIGHT]) {
                                gpJeu->getAudio()->playSound(3);
                                gpJeu->getTexte()->changeId(gpJeu->getTexte()->getId()+1);
                            }
                            break;
                        case 78 : case 81 : case 84 : case 87 : case 90 : case 93 : case 97 :
                        case 100 : case 103 : case 108 : case 127 : case 130 : case 133 :
                        case 136 : case 139 : case 142 : case 145 : case 148 : case 151 :
                        case 160 : case 163 : case 166 : case 169 : case 172 : case 181 :
                        case 192 : case 205 : case 216 : case 219 : case 221 : case 223 :
                        case 229 : case 231 : case 233 : case 235 : case 241 : case 246 :
                        case 252 : case 266 : case 269 : case 272 : case 274 : case 279 : 
                        case 282 : case 291 : case 300 : case 310 : case 352 : case 357 : 
                        case 369 : case 371 : case 377 : case 379 : case 381 : case 384 : 
                        case 388 : case 391 : case 394 : case 396 : case 399 : case 401 : 
                        case 404 : case 414 : case 416 : case 427 : case 434 : case 448 :
                        case 452 : case 462 : case 465 : case 468 : case 471 : case 474 : 
                        case 507 : case 525 : case 531 : case 556 : case 562 : case 570 : 
                        case 577 : case 582 : case 587 : case 594 : case 601 : case 606 : 
                        case 615 : case 642 : case 644 : case 646 : case 648 : case 650 : 
                        case 679 : case 681 : case 689 : case 702 : case 707 : case 722 : 
                        case 729 : case 735 : case 741 : case 751 : case 753 : case 755 : 
                        case 757 : case 759 : case 768 : case 770 : case 781 : case 790 : 
                        case 824 : case 835 : case 860 : case 889 : case 897 : case 909 : 
                        case 917 : case 1049: case 1086: case 1115: case 1121: case 1127:
                        case 1133: case 1140: case 1142: case 1146: case 1155: case 1159:
                        case 1163: case 1167: case 1171: case 1175: case 1179: case 1183: 
                        case 1187: case 1191: case 1195: case 1199: case 1203: case 1207: 
                        case 1211: case 1215: case 1219: case 1223: case 1227: case 1231: 
                        case 1235: case 1239: case 1243: case 1247: case 1251: case 1255: 
                        case 1259: case 1263: case 1267: case 1271: case 1275: case 1279: 
                        case 1283: case 1287: case 1291: case 1295: case 1299: case 1303: 
                        case 1307: case 1311: case 1315: case 1328:
                            if (keys[SDLK_LEFT] || keys[SDLK_RIGHT]) {
                                gpJeu->getAudio()->playSound(3);
                                gpJeu->getTexte()->changeId(gpJeu->getTexte()->getId()-1);
                            }
                            break;
                        case 48 : case 49 : case 50 : case 51 : case 52 : case 53 :
                        case 54 : case 55 : case 56 : case 57 : case 58 : case 59 :
                        case 60 : case 61 : case 62 : case 63 : case 64 : case 65 : 
                        case 66 : case 199 : case 200 : case 410 : case 411 : case 412 : 
                        case 421 : case 422 : case 423 : case 513 : case 514 : case 515 : 
                        case 516 : case 564 : case 565 : case 566 : case 608 : case 609 : 
                        case 610 : case 675 : case 676 : case 677 : case 709 : case 710 : 
                        case 711 : case 764 : case 765 : case 766 : 
                            if (gpJeu->getTexte()->getId()!=49 
                            && gpJeu->getTexte()->getId()!=52 && gpJeu->getTexte()->getId()!=56 
                            && gpJeu->getTexte()->getId()!=58 && gpJeu->getTexte()->getId()!=60
                            && gpJeu->getTexte()->getId()!=63 && gpJeu->getTexte()->getId()!=66 
                            && gpJeu->getTexte()->getId()!=200 
                            && gpJeu->getTexte()->getId()!=217
                            && gpJeu->getTexte()->getId()!=412
                            && gpJeu->getTexte()->getId()!=423
                            && gpJeu->getTexte()->getId()!=516
                            && gpJeu->getTexte()->getId()!=566
                            && gpJeu->getTexte()->getId()!=610
                            && gpJeu->getTexte()->getId()!=677
                            && gpJeu->getTexte()->getId()!=711
                            && gpJeu->getTexte()->getId()!=766) {
                                if (keys[SDLK_DOWN]) {
                                    gpJeu->getAudio()->playSound(3);
                                    gpJeu->getTexte()->changeId(gpJeu->getTexte()->getId()+1);
                                }
                            }
                            if (gpJeu->getTexte()->getId()!=48 
                            && gpJeu->getTexte()->getId()!=50 && gpJeu->getTexte()->getId()!=53 
                            && gpJeu->getTexte()->getId()!=57 && gpJeu->getTexte()->getId()!=59
                            && gpJeu->getTexte()->getId()!=61 && gpJeu->getTexte()->getId()!=64 
                            && gpJeu->getTexte()->getId()!=199
                            && gpJeu->getTexte()->getId()!=215
                            && gpJeu->getTexte()->getId()!=410
                            && gpJeu->getTexte()->getId()!=421
                            && gpJeu->getTexte()->getId()!=513
                            && gpJeu->getTexte()->getId()!=564
                            && gpJeu->getTexte()->getId()!=608
                            && gpJeu->getTexte()->getId()!=675
                            && gpJeu->getTexte()->getId()!=709
                            && gpJeu->getTexte()->getId()!=764) {
                                if (keys[SDLK_UP]) {
                                    gpJeu->getAudio()->playSound(3);
                                    gpJeu->getTexte()->changeId(gpJeu->getTexte()->getId()-1);
                                }
                            }
                            break;
                    }
                }
                if (!keys[SDLK_RETURN] && !keys[SDLK_RETURN] && !keys[SDLK_LEFT] 
                && !keys[SDLK_RIGHT] && !keys[SDLK_UP] && !keys[SDLK_DOWN]) tmpt=0;
            }
            
            nbdir=0;
            if (keys[SDLK_UP]) nbdir++;
            if (keys[SDLK_DOWN]) nbdir++;
            if (keys[SDLK_LEFT]) nbdir++;
            if (keys[SDLK_RIGHT]) nbdir++;
            
            int vitesse;
            if ((keys[SDLK_CAPSLOCK] || keys[SDLK_LSHIFT]) && !gpJeu->getStop() 
            && gpJoueur->hasObjet(O_BOTTES) && gpJoueur->hasObjet(O_TROC1)!=2) vitesse=4; 
            else vitesse=2;
    
            avance=0;
            
            //marche
            if (!keys[SDLK_LCTRL] && (
            gpJoueur->getTypeAnim()==AUCUNE || gpJoueur->getTypeAnim()==MARCHE 
            || gpJoueur->getTypeAnim()==PORTE || gpJoueur->getTypeAnim()==EMMENE
            || gpJoueur->getTypeAnim()==NAGE || gpJoueur->getTypeAnim()==FLOTTE
            || gpJoueur->getTypeAnim()==RAME || gpJoueur->getTypeAnim()==BARQUE) 
            && !gpJeu->getStop() && !gpJeu->getTransition() && !gpJoueur->getImmo()) {
                gpJoueur->savePrec();
                if ((keys[SDLK_LEFT] && !gpJoueur->isIvre()) 
                || (keys[SDLK_RIGHT] && gpJoueur->isIvre())) {
                    if(!gpJoueur->getCharge() 
                    && (!keys[SDLK_UP] || gpJoueur->getDirection()!=N) 
                    && (!keys[SDLK_DOWN] || gpJoueur->getDirection()!=S))
                        gpJoueur->setDirection(O);
                    if (gpJoueur->getX()%4==2) vit=2; else vit = vitesse;
                    //gpJeu->moveJoueurX(-vit, nbdir);
                    gpJoueur->moveX(-vit, nbdir);
                    avance = 1;
                }
                if ((keys[SDLK_RIGHT] && !gpJoueur->isIvre()) 
                || (keys[SDLK_LEFT] && gpJoueur->isIvre())) {
                    if(!gpJoueur->getCharge() 
                    && (!keys[SDLK_UP] || gpJoueur->getDirection()!=N) 
                    && (!keys[SDLK_DOWN] || gpJoueur->getDirection()!=S))
                        gpJoueur->setDirection(E);
                    if (gpJoueur->getX()%4==2) vit=2; else vit = vitesse;
                    //gpJeu->moveJoueurX(vit, nbdir);
                    gpJoueur->moveX(vit, nbdir);
                    avance=1;
                }
                if ((keys[SDLK_UP] && !gpJoueur->isIvre())
                || (keys[SDLK_DOWN] && gpJoueur->isIvre())) {
                    if(!gpJoueur->getCharge()
                    && (!keys[SDLK_LEFT] || gpJoueur->getDirection()!=O) 
                    && (!keys[SDLK_RIGHT] || gpJoueur->getDirection()!=E))
                        gpJoueur->setDirection(N);
                    if (gpJoueur->getY()%4!=0) vit=2; else vit = vitesse;
                    //gpJeu->moveJoueurY(-vit, nbdir);
                    gpJoueur->moveY(-vit, nbdir);
                    avance=1;
                }
                if ((keys[SDLK_DOWN] && !gpJoueur->isIvre())
                || (keys[SDLK_UP] && gpJoueur->isIvre())) {
                    if(!gpJoueur->getCharge()
                    && (!keys[SDLK_LEFT] || gpJoueur->getDirection()!=O) 
                    && (!keys[SDLK_RIGHT] || gpJoueur->getDirection()!=E))
                        gpJoueur->setDirection(S);
                    if (gpJoueur->getY()%4!=0) vit=2; else vit = vitesse;
                    //gpJeu->moveJoueurY(vit, nbdir);
                    gpJoueur->moveY(vit, nbdir);
                    avance=1;
                }
                if (gpJeu->getVueHorz()>0) {
                    if (gpJeu->getVueHorz()>=4) gpJeu->setVueHorz(gpJeu->getVueHorz()-4);
                    else gpJeu->setVueHorz(0);
                }
                if (gpJeu->getVueHorz()<0) {
                    if (gpJeu->getVueHorz()<=-4) gpJeu->setVueHorz(gpJeu->getVueHorz()+4);
                    else gpJeu->setVueHorz(0);
                }
                if (gpJeu->getVueVert()>0) {
                    if (gpJeu->getVueVert()>=4) gpJeu->setVueVert(gpJeu->getVueVert()-4);
                    else gpJeu->setVueVert(0);
                }
                if (gpJeu->getVueVert()<0) {
                    if (gpJeu->getVueVert()<=-4) gpJeu->setVueVert(gpJeu->getVueVert()+4);
                    else gpJeu->setVueVert(0);
                }
            }
            if (keys[SDLK_LCTRL] && !gpJoueur->getImmo()) {
                if (keys[SDLK_LEFT] && gpJeu->getVueHorz()>-64)
                    gpJeu->setVueHorz(gpJeu->getVueHorz()-2);
                if (keys[SDLK_RIGHT] && gpJeu->getVueHorz()<64)
                    gpJeu->setVueHorz(gpJeu->getVueHorz()+2);
                if (keys[SDLK_UP] && gpJeu->getVueVert()>-64)
                    gpJeu->setVueVert(gpJeu->getVueVert()-2);
                if (keys[SDLK_DOWN] && gpJeu->getVueVert()<64)
                    gpJeu->setVueVert(gpJeu->getVueVert()+2);
            }
            
            if (avance == 1) {
                if (gpJoueur->getTypeAnim()==AUCUNE) gpJoueur->setTypeAnim(MARCHE);
                if (gpJoueur->getTypeAnim()==FLOTTE) gpJoueur->setTypeAnim(NAGE);
                if (gpJoueur->getTypeAnim()==PORTE) gpJoueur->setTypeAnim(EMMENE);
                if (gpJoueur->getTypeAnim()==BARQUE) gpJoueur->setTypeAnim(RAME);
                gpJeu->testFin();
            }
            else {
                if (gpJoueur->getTypeAnim()==MARCHE && !gpJeu->getStop()) 
                    gpJoueur->setTypeAnim(AUCUNE);
                if (gpJoueur->getTypeAnim()==NAGE && !gpJeu->getStop()) 
                    gpJoueur->setTypeAnim(FLOTTE);
                if (gpJoueur->getTypeAnim()==EMMENE && !gpJeu->getStop()) 
                    gpJoueur->setTypeAnim(PORTE);
                if (gpJoueur->getTypeAnim()==RAME && !gpJeu->getStop()) 
                    gpJoueur->setTypeAnim(BARQUE);
            }
            
            
            //épée
            if ((gpJoueur->getTypeAnim()==AUCUNE || gpJoueur->getTypeAnim()==MARCHE) 
            && !gpJoueur->getCharge() && gpJoueur->getEpee() && !gpJeu->getStop()
            && !gpJoueur->isLapin() && !gpJoueur->getImmo()) {
                if ((keys[SDLK_z] || keys[SDLK_w]) && !tmpw) {
                    gpJoueur->setTypeAnim(EPEE);
                    gpJoueur->chargeSpin();
                    tmpw=1;
                }
                if (!keys[SDLK_z] && !keys[SDLK_w] && tmpw) tmpw=0;
            }
            if (!keys[SDLK_z] && !keys[SDLK_w] && gpJoueur->getCharge() && !gpJeu->getStop() 
            && !gpJoueur->isLapin()) {
                if (gpJoueur->getCharge() >= 20) gpJoueur->setTypeAnim(SPIN);
                gpJoueur->dechargeSpin();
            }
            
            
            //curseur menu
            if (gpJeu->getMenu() && !gpJoueur->getOni() &&
            (gpJoueur->getTypeAnim()<4 || gpJoueur->getTypeAnim()==NAGE || gpJoueur->getTypeAnim()==FLOTTE ||
            (gpJoueur->getTypeAnim()>20 && gpJoueur->getTypeAnim()<25)) && tmp==0) {
                if (keys[SDLK_LEFT]) {
                    int obj = gpJoueur->getObjet();
                    if (obj%4 == 0) gpJoueur->setObjet(obj+3);
                    else gpJoueur->setObjet(obj-1);
                    gpJeu->getAudio()->playSound(3);
                    tmp=1;
                }
                if (keys[SDLK_RIGHT]) {
                    int obj = gpJoueur->getObjet();
                    if (obj%4 == 3) gpJoueur->setObjet(obj-3);
                    else gpJoueur->setObjet(obj+1);
                    gpJeu->getAudio()->playSound(3);
                    tmp=1;
                }
                if (keys[SDLK_UP]) {
                    int obj = gpJoueur->getObjet();
                    if (obj/4 == 0) gpJoueur->setObjet(obj+12);
                    else gpJoueur->setObjet(obj-4);
                    gpJeu->getAudio()->playSound(3);
                    tmp=1;
                }
                if (keys[SDLK_DOWN]) {
                    int obj = gpJoueur->getObjet();
                    if (obj/4 == 3) gpJoueur->setObjet(obj-12);
                    else gpJoueur->setObjet(obj+4);
                    gpJeu->getAudio()->playSound(3);
                    tmp=1;
                }
            }
            
            
            
            if (keys[SDLK_x] && (
            gpJoueur->getTypeAnim()==AUCUNE || gpJoueur->getTypeAnim()==MARCHE || 
            gpJoueur->getTypeAnim()==PECHE) 
            && !gpJeu->getStop() && !gpJoueur->getImmo()
            && gpJoueur->getVie()>0 && !gpJoueur->getCharge() && !gpJoueur->isLapin() 
            && !gpJoueur->getOni() && !tmpx) {
                tmpx=1;
                switch(gpJoueur->getObjet()) {
                    case 0 : //arc
                        if (gpJoueur->hasObjet(O_ARC)) gpJoueur->setTypeAnim(ARC);
                        break;
                    case 1 : //grappin
                        if (gpJoueur->hasObjet(O_GRAPPIN)) gpJoueur->setTypeAnim(GRAPPIN);
                        break;
                    case 2 : //bombe
                        if (gpJoueur->hasObjet(O_SAC_BOMBES) && gpJoueur->getBombe()) 
                            gpJoueur->setTypeAnim(BOMBE);
                        break;
                    case 3 : //flèche feu ou troc 1
                        if (gpJoueur->hasObjet(O_FFEU)) {
                            if (gpJoueur->hasObjet(O_ARC)) gpJoueur->setTypeAnim(ARC);
                        }
                        else if (gpJoueur->hasObjet(O_TROC1))
                            gpJeu->ecrit(1);
                        break;
                    case 4 : //baguette de feu
                        if (gpJoueur->hasObjet(O_BFEU)) gpJoueur->setTypeAnim(BFEU);
                        break;
                    case 5 : //baguette de glace
                        if (gpJoueur->hasObjet(O_BGLACE)) gpJoueur->setTypeAnim(BGLACE);
                        break;
                    case 6 : //lanterne
                        if (gpJoueur->hasObjet(O_LANTERNE) && gpJoueur->getMagie() >= 2) 
                            gpJoueur->setTypeAnim(LANTERNE);
                        break;
                    case 7 : //troc 2
                        if (gpJoueur->hasObjet(O_FGLACE)) {
                            if (gpJoueur->hasObjet(O_ARC)) gpJoueur->setTypeAnim(ARC);
                        }
                        else if (gpJoueur->hasObjet(O_TROC2))
                            gpJeu->ecrit(1);
                        break;
                    case 8 : //marteau
                        if (gpJoueur->hasObjet(O_MARTEAU)) gpJoueur->setTypeAnim(MARTEAU);
                        break;
                    case 9 : //ocarina
                        if (gpJoueur->hasObjet(O_OCARINA)) {
                            gpJoueur->setTypeAnim(JOUE);
                            gpJeu->ecrit(47);}
                        break;
                    case 10 : //canne à pêche
                        if (gpJoueur->getTypeAnim()==PECHE) gpJoueur->finPeche();
                        else gpJoueur->peche();
                        break;
                    case 11 : //troc 3
                        if (gpJoueur->hasObjet(O_FLUM)) {
                            if (gpJoueur->hasObjet(O_ARC)) gpJoueur->setTypeAnim(ARC);
                        }
                        else if (gpJoueur->hasObjet(O_TROC3))
                            gpJeu->ecrit(1);
                        break;
                    case 12 : // flacon
                    case 13 :
                    case 14 :
                    case 15 :
                        if (gpJoueur->hasBouteille(gpJoueur->getObjet()-12)) 
                            gpJoueur->setTypeAnim(BOIRE);
                        else if (gpJoueur->getObjet()==15 && gpJoueur->hasObjet(O_TROC4))
                            gpJeu->ecrit(1);
                        break;
                }
            }
            
            if (!keys[SDLK_x] && tmpx) tmpx=0;
            
            if (keys[SDLK_c] && !tmpc && !gpJoueur->getCharge() && gpJoueur->getVie()>0
            && !gpJoueur->isLapin() && !gpJeu->getStop() && !gpJoueur->getImmo()) {
                if (gpJoueur->getTypeAnim()==AUCUNE || gpJoueur->getTypeAnim()==MARCHE)
                    gpJeu->ramasse();
                else if (gpJoueur->getTypeAnim()==PORTE || gpJoueur->getTypeAnim()==EMMENE)
                    gpJoueur->setTypeAnim(LANCE);
            }
            
            if (!keys[SDLK_c] && tmpc) tmpc=0;
            
            if (keys[SDLK_SPACE] && !gpJeu->getStop() && gpJoueur->getVie() && 
            (gpJoueur->getTypeAnim()==AUCUNE || gpJoueur->getTypeAnim()==MARCHE
            || gpJoueur->getTypeAnim()==PORTE || gpJoueur->getTypeAnim()==EMMENE
            || gpJoueur->getTypeAnim()==FLOTTE || gpJoueur->getTypeAnim()==NAGE
            || gpJoueur->getTypeAnim()==BARQUE || gpJoueur->getTypeAnim()==RAME) 
             && !gpJoueur->getImmo()) {
                gpJeu->lire();
            }
            
            if (keys[SDLK_p] && (gpJoueur->hasObjet(O_CARTE) || gpJeu->isDonjon()) && 
            (gpJeu->isDehors() || gpJeu->isDonjon())
            && !gpJeu->getStop() && gpJoueur->getVie()>0 && !tmpp) {
                mode = 12;
                gpJeu->getAudio()->playSound(1);
                gpCarte->init();
                tmpp=1;
            }
            
            if (!keys[SDLK_p] && tmpp) tmpp=0;
            
            if ((keys[SDLK_m] || keys[SDLK_SEMICOLON]) && gpJoueur->hasObjet(O_ENCYCL)
            && !gpJeu->getStop() && gpJoueur->getVie()>0 && gpJoueur->nbEnnemis() && !tmpm) {
                mode = 13;
                gpJeu->getAudio()->playSound(1);
                gpEncyclopedie->setPage(0);
                gpEncyclopedie->init();
                tmpm=1;
            }
            
            if (!(keys[SDLK_m] || keys[SDLK_SEMICOLON]) && tmpm) tmpm=0;
            
            if (keys[SDLK_o] && gpJoueur->hasObjet(O_MASQUE) && !gpJoueur->isLapin() && !tmpo
            && !gpJeu->getStop() && !gpJoueur->getImmo() && gpJoueur->getVie()>0) {
                if (gpJoueur->getOni()) {
                    gpJeu->getAudio()->playSound(2);gpJoueur->setOni(false);}
                else {gpJeu->getAudio()->playSound(1); gpJoueur->setOni(true);}
                tmpo=1;
            }
            
            if (!(keys[SDLK_o]) && tmpo) tmpo=0;
            
            
            if (keys[SDLK_t] && gpJoueur->getOni() && !gpJoueur->isLapin()
            && gpJeu->isDonjon() && !tmptp
            && !gpJeu->getStop() && !gpJoueur->getImmo() && gpJoueur->getVie()>0) {
                gpJeu->getAudio()->playSound(5);
                SDL_Delay(1000);
                gpJeu->getAudio()->stopSpecial();
                gpJoueur->restoreEmpl();
                tmptp=1;
            }
            
            if (!(keys[SDLK_t]) && tmptp) tmptp=0;
            
            
            // liste poissons
            if (keys[SDLK_l] && gpJoueur->hasObjet(O_POISSONS) && gpJoueur->nbPoissons() && !tmpl
            && !gpJeu->getStop() && !gpJoueur->getImmo() && gpJoueur->getVie()>0) {
                mode = 23;
                gpJeu->getAudio()->playSound(1);
                gpPoissons->setPage(0);
                gpPoissons->init();
                tmpl=1;
            }
            
            if (!keys[SDLK_l] && tmpl) tmpl=0;
            
            // liste items troc
            if (keys[SDLK_i] && gpJoueur->hasObjet(O_SAC_TROC) && !tmpi
            && !gpJeu->getStop() && !gpJoueur->getImmo() && gpJoueur->getVie()>0) {
                mode = 25;
                gpJeu->getAudio()->playSound(1);
                gpJeu->getGenerique()->initTroc();
                tmpi=1;
            }
            
            if (!keys[SDLK_i] && tmpi) tmpi=0;
            
            break;
        case 1 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                mode = 2;
                gpJeu->getGenerique()->initLogo();
                gpJeu->getAudio()->playSound(1);
                tmp = 1;
            }
            if (!keys[SDLK_RETURN]) tmp=0;
            break;
        case 2 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                mode = 3;
                gpJeu->getGenerique()->initTitre();
                gpJeu->getAudio()->playSound(1);
                gpJeu->getAudio()->playMusic(180);
                tmp = 1;
            }
            if (!keys[SDLK_RETURN]) tmp=0;
            break;
        case 3 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                mode = 4; colonne=0;
                gpJeu->getGenerique()->initSelection();
                gpJeu->getAudio()->playSound(1);
                gpJeu->getAudio()->playMusic(190);
                tmp = 1;
            }
            if (!keys[SDLK_RETURN]) tmp=0;
            break;
        case 4 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                if (ligne < 3) {
                    if (save[ligne]) {
                        mode = 7; ligneVal=0;
                        gpJeu->getGenerique()->initCharger();
                    }
                    else {
                        mode = 8; intro = 0; gpJeu->getGenerique()->initIntro();
                        gpJeu->getAudio()->playMusic(200);
                    }
                }
                if (ligne == 3 && colonne == 0) {
                    mode = 6; ligneOption=2;
                    gpJeu->getGenerique()->initOption();
                }
                if (ligne == 3 && colonne == 1) {
                    mode = 15; ligneRecord=3; colonneRecord=0;
                    gpJeu->getGenerique()->initRecord();
                }
                tmp=1; gpJeu->getAudio()->playSound(1);
            }
            
            if (keys[SDLK_UP] && !tmp) {
                ligne--; if (ligne<0) ligne=3; tmp=1; 
                if (ligne!=3) colonne=0;
                gpJeu->getAudio()->playSound(3);}
            if (keys[SDLK_DOWN] && !tmp) {
                ligne++; if (ligne>3) ligne=0; tmp=1;
                if (ligne!=3) colonne=0;
                gpJeu->getAudio()->playSound(3);}
            if (keys[SDLK_LEFT] && !tmp && ligne==3) {
                colonne--; if (colonne<0) colonne=1; tmp=1;
                gpJeu->getAudio()->playSound(3);}
            if (keys[SDLK_RIGHT] && !tmp && ligne==3) {
                colonne++; if (colonne>1) colonne=0; tmp=1;
                gpJeu->getAudio()->playSound(3);}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_UP] && !keys[SDLK_DOWN] 
                && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] && tmp) tmp=0;
            break;
        case 6 :
            if (keys[SDLK_RETURN] && tmp == 0 && ligneOption == 2) {
                mode = 4;
                gpJeu->getGenerique()->initSelection();
                gpJeu->getAudio()->playSound(2);
                tmp = 1;
                saveP();
            }
            
            if (keys[SDLK_UP] && !tmp) {
                ligneOption--; if (ligneOption<0) ligneOption=2; tmp=1; 
                gpJeu->getAudio()->playSound(3);}
            if (keys[SDLK_DOWN] && !tmp) {
                ligneOption++; if (ligneOption>2) ligneOption=0; tmp=1;
                gpJeu->getAudio()->playSound(3);}
            if (keys[SDLK_LEFT] && !tmp) {
                if (ligneOption == 0) {
                    volume-=8; if (volume < 0) volume = 0; tmp=1;
                    gpJeu->getAudio()->setVolume(volume); gpJeu->getAudio()->playSound(3);}
                if (ligneOption == 1) {
                    volson-=8; if (volson < 0) volson = 0; tmp=1;
                    gpJeu->getAudio()->setVolson(volson); gpJeu->getAudio()->playSound(3);}}
            if (keys[SDLK_RIGHT] && !tmp) {
                if (ligneOption == 0) {
                    volume+=8; if (volume > 64) volume = 64; tmp=1;
                    gpJeu->getAudio()->setVolume(volume);gpJeu->getAudio()->playSound(3);}
                if (ligneOption == 1) {
                    volson+=8; if (volson > 64) volson = 64; tmp=1;
                    gpJeu->getAudio()->setVolson(volson);gpJeu->getAudio()->playSound(3);}}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_UP] && !keys[SDLK_DOWN] 
                && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] && tmp) tmp=0;
            break;
        case 7 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                if (ligneVal==0) {
                    mode = 0;
                    gpJeu->init(ligne+1);
                }
                if (ligneVal==1) {
                    mode = 9; ligneVal=1;
                    gpJeu->getGenerique()->initEffacer();
                    gpJeu->getAudio()->playSound(1);
                }
                if (ligneVal==2) {
                    mode = 4; gpJeu->getGenerique()->initSelection();
                    gpJeu->getAudio()->playSound(2);
                }    
                tmp = 1;
            }
            
            if (keys[SDLK_UP] && !tmp) {
                if (--ligneVal<0) ligneVal=2; tmp=1; 
                gpJeu->getAudio()->playSound(3);}
            if (keys[SDLK_DOWN] && !tmp) {
                if (++ligneVal>2) ligneVal=0; tmp=1;
                gpJeu->getAudio()->playSound(3);}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_UP] && !keys[SDLK_DOWN] && tmp) tmp=0;
            break;
        case 8 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                int old;
                old = gpJeu->getTexte()->getId();
                if (!gpJeu->getTexte()->suite()) {
                    mode = 10; gpJeu->getGenerique()->initNuit();
                    gpJeu->getAudio()->stopMusic();
                }
                else if (old != gpJeu->getTexte()->getId()) intro++;
                tmp = 1;
            }
            if (!keys[SDLK_RETURN] && tmp) tmp=0;
            break;
        case 9 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                if (ligneVal==0) {
                    ostringstream oss; oss << (ligne+1);
                    remove(("data/save/3t" + oss.str() + ".dat").c_str());
                    mode = 4; gpJeu->getGenerique()->initSelection();
                    gpJeu->getAudio()->playSound(2);
                }
                else {
                    mode = 7; gpJeu->getGenerique()->initCharger();
                    gpJeu->getAudio()->playSound(1);
                }
                tmp = 1;
            }
            
            if ((keys[SDLK_UP] || keys[SDLK_DOWN]) && !tmp) {
                ligneVal ? ligneVal=0 : ligneVal = 1; tmp=1;
                gpJeu->getAudio()->playSound(3);}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_UP] && !keys[SDLK_DOWN] && tmp) tmp=0;
            break;
        case 10 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                if (gpJeu->getText()) gpJeu->setText(gpJeu->getTexte()->suite());
                if (!gpJeu->getText()) {
                    //gpJeu->getAudio()->playSound(5);
                    //SDL_Delay(2500);
                    mode = 0; gpJeu->init(ligne+1);
                    gpJeu->ecrit(1367);
                }
                tmp = 1;
            }
            if (!keys[SDLK_RETURN] && tmp) tmp=0;
            break;
        case 11 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                gpJeu->setText(gpJeu->getTexte()->suite());
                tmp = 1;
            }
            if (!keys[SDLK_RETURN]) tmp=0;
            break;
        case 12 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            
            if (keys[SDLK_UP] && !tmp) {
                gpCarte->moveLevel(N);
                tmp=1;
            }
            if (keys[SDLK_DOWN] && !tmp) {
                gpCarte->moveLevel(S);
                tmp=1;
            }
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_UP] && !keys[SDLK_DOWN] && tmp) tmp=0;
            break;
        case 13 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            
            if (keys[SDLK_LEFT] && !tmp) {
                gpJeu->getAudio()->playSound(3);
                gpEncyclopedie->moveL();
                tmp=1;
            }
            if (keys[SDLK_RIGHT] && !tmp) {
                gpJeu->getAudio()->playSound(3);
                gpEncyclopedie->moveR();
                tmp=1;
            }
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] && tmp) tmp=0;
            break;
        case 14 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                mode = 2; gpJeu->getAudio()->playSound(1);
                gpJeu->getGenerique()->initLogo();
                tmp = 1;
            }
            if (!keys[SDLK_RETURN] && tmp) tmp=0;
            break;
        case 15 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                if (ligneRecord==3) {
                    if (colonneRecord == 0) {
                        mode = 4;
                        gpJeu->getGenerique()->initSelection();
                        gpJeu->getAudio()->playSound(2);
                    }
                    else {
                        mode = 16; ligneVal=1;
                        gpJeu->getGenerique()->initEffacer();
                        gpJeu->getAudio()->playSound(1);
                    }
                }
                else {
                    mode = 19 + ligneRecord;
                    gpJeu->getGenerique()->initRang(ligneRecord);
                    gpJeu->getAudio()->playSound(1);
                }
                tmp = 1;
            }
            
            if (keys[SDLK_UP] && !tmp) {
                ligneRecord--; if (ligneRecord<0) ligneRecord=3; tmp=1; 
                colonneRecord=0; gpJeu->getAudio()->playSound(3);}
            if (keys[SDLK_DOWN] && !tmp) {
                ligneRecord++; if (ligneRecord>3) ligneRecord=0; tmp=1;
                colonneRecord=0; gpJeu->getAudio()->playSound(3);}
            
            if ((keys[SDLK_LEFT] || keys[SDLK_RIGHT]) && ligneRecord==3 && !tmp) {
                if (colonneRecord == 0) colonneRecord=1;
                else colonneRecord=0; tmp=1;
                gpJeu->getAudio()->playSound(3);}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_UP] && !keys[SDLK_DOWN] 
                && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] && tmp) tmp=0;
            break;
        case 16 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                mode = 15;
                if (ligneVal==0) {
                    gpJeu->getAudio()->playSound(2);
                    temps=0; for (int i = 0; i < 3; i++) rang[6+i]=0; saveP();
                }
                else gpJeu->getAudio()->playSound(1);
                gpJeu->getGenerique()->initRecord();
                tmp = 1;
            }
            
            if ((keys[SDLK_UP] || keys[SDLK_DOWN]) && !tmp) {
                ligneVal ? ligneVal=0 : ligneVal = 1; tmp=1;
                gpJeu->getAudio()->playSound(3);}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_UP] && !keys[SDLK_DOWN] && tmp) tmp=0;
            break;
        case 17 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            if (keys[SDLK_RIGHT] && !tmp) {
                mode = 18; gpJeu->getGenerique()->initAide2();
                gpJeu->getAudio()->playSound(3); tmp=1;}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_RIGHT] && tmp) tmp=0;
            break;
        case 18 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            if (keys[SDLK_LEFT] && !tmp) {
                mode = 17; gpJeu->getGenerique()->initAide1();
                gpJeu->getAudio()->playSound(3); tmp=1;}
            if (keys[SDLK_RIGHT] && !tmp) {
                if (gpJeu->getGenerique()->initAide3()) {
                    mode = 24;
                    gpJeu->getAudio()->playSound(3); tmp=1;}}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] && tmp) tmp=0;
            break;
        case 24 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            if (keys[SDLK_LEFT] && !tmp) {
                mode = 18; gpJeu->getGenerique()->initAide2();
                gpJeu->getAudio()->playSound(3); tmp=1;}
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_LEFT] && tmp) tmp=0;
            break;
        case 19 :
        case 20 :
        case 21 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 15; gpJeu->getGenerique()->initRecord();
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            if (!keys[SDLK_RETURN] && tmp) tmp=0;
            break;
        case 22 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(5);
                SDL_Delay(2500);
                gpJeu->teleporte(telep);
                tmp=1;
            }
            if (keys[SDLK_LEFT] && !tmp) {
                telep--; if (telep<0) telep=8;
                gpJeu->getAudio()->playSound(3); tmp=1;}
            if (keys[SDLK_RIGHT] && !tmp) {
                telep++; if (telep>8) telep=0;
                gpJeu->getAudio()->playSound(3); tmp=1;}
            if ((keys[SDLK_1] || keys[SDLK_KP1]
            || keys[SDLK_2] || keys[SDLK_KP2]
            || keys[SDLK_3] || keys[SDLK_KP3]
            || keys[SDLK_4] || keys[SDLK_KP4]
            || keys[SDLK_5] || keys[SDLK_KP5]
            || keys[SDLK_6] || keys[SDLK_KP6]
            || keys[SDLK_7] || keys[SDLK_KP7]
            || keys[SDLK_8] || keys[SDLK_KP8]
            || keys[SDLK_9] || keys[SDLK_KP9]
            ) && !tmp) {
                if (keys[SDLK_1] || keys[SDLK_KP1])telep=0;
                if (keys[SDLK_2] || keys[SDLK_KP2])telep=1;
                if (keys[SDLK_3] || keys[SDLK_KP3])telep=2;
                if (keys[SDLK_4] || keys[SDLK_KP4])telep=3;
                if (keys[SDLK_5] || keys[SDLK_KP5])telep=4;
                if (keys[SDLK_6] || keys[SDLK_KP6])telep=5;
                if (keys[SDLK_7] || keys[SDLK_KP7])telep=6;
                if (keys[SDLK_8] || keys[SDLK_KP8])telep=7;
                if (keys[SDLK_9] || keys[SDLK_KP9])telep=8;
                gpJeu->getAudio()->playSound(3); tmp=1;
            }
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] 
            && !keys[SDLK_1] && !keys[SDLK_2] && !keys[SDLK_3]
            && !keys[SDLK_4] && !keys[SDLK_5] && !keys[SDLK_6]
            && !keys[SDLK_7] && !keys[SDLK_8] && !keys[SDLK_9]
            && !keys[SDLK_KP1] && !keys[SDLK_KP2] && !keys[SDLK_KP3]
            && !keys[SDLK_KP4] && !keys[SDLK_KP5] && !keys[SDLK_KP6]
            && !keys[SDLK_KP7] && !keys[SDLK_KP8] && !keys[SDLK_KP9]
            && tmp) tmp=0;
            break;
        case 23 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            
            if (keys[SDLK_LEFT] && !tmp) {
                gpJeu->getAudio()->playSound(3);
                gpPoissons->moveL();
                tmp=1;
            }
            if (keys[SDLK_RIGHT] && !tmp) {
                gpJeu->getAudio()->playSound(3);
                gpPoissons->moveR();
                tmp=1;
            }
            
            if (!keys[SDLK_RETURN] && !keys[SDLK_LEFT] && !keys[SDLK_RIGHT] && tmp) tmp=0;
            break;
        case 25 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 0;
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            if (!keys[SDLK_RETURN] && tmp) tmp=0;
            break;
        case 26 :
        case 27 :
            if (keys[SDLK_RETURN] && tmp == 0) {
                gpJeu->setText(gpJeu->getTexte()->suite());
                tmp = 1;
            }
            if (!keys[SDLK_RETURN]) tmp=0;
            break;
        case 28 :
            if (keys[SDLK_RETURN] && !tmp) {
                mode = 14;
                gpJeu->getAudio()->stopSpecial();
                gpJeu->getAudio()->stopMusic(); 
                gpJeu->getGenerique()->initScore();
                gpJeu->setZone(79);
                gpJeu->getJoueur()->setVie(gpJeu->getJoueur()->getVieMax());
                gpJeu->getJoueur()->setXDep(152);
                gpJeu->getJoueur()->setYDep(72);
                gpJeu->getJoueur()->setDirDep(S);
                gpJeu->getJoueur()->save();
                gpJeu->getAudio()->playSound(2);
                tmp=1;
            }
            if (!keys[SDLK_RETURN] && tmp) tmp=0;
            break;
    }
}
コード例 #24
0
ファイル: Projectile.cpp プロジェクト: nop90/ZeldaROTH
void Projectile::testAgrippe() {
    if (hauteur>0) return;
    
    Monde* gpMonde = gpJeu->getMonde();
    Joueur* gpJoueur = gpJeu->getJoueur();
    
    //SDL_Rect* z = gpJoueur->getZoneBase()->getZone();
    
    switch (direction) {
        case N:
            if(gpMonde->murValue(x+zx+(zw/2), y+zy) == BOIS) {
                vie=0;
                gpJoueur->setY(y+zy-3-4-4);
                while (!gpJoueur->verifZone()) gpJoueur->moveY(2);
                gpJoueur->setTypeAnim(AUCUNE);
                return;
            }
            break;
        case S:
            if(gpMonde->murValue(x+zx+(zw/2), y+zy+zh-1) == BOIS) {
                vie=0;
                gpJoueur->setY(y+zy-17);
                while (!gpJoueur->verifZone()) gpJoueur->moveY(-2);
                gpJoueur->setTypeAnim(AUCUNE);
                return;
            }
            break;
        case O:
            if(gpMonde->murValue(x+zx, y+zy+(zh/2)) == BOIS) {
                vie=0;
                gpJoueur->setX(x+zx+1);
                while (!gpJoueur->verifZone()) gpJoueur->moveX(2);
                gpJoueur->setTypeAnim(AUCUNE);
                return;
            }
            break;
        case E:
            if(gpMonde->murValue(x+zx+zw-1, y+zy+(zh/2)) == BOIS) {
                vie=0;
                gpJoueur->setX(x+zx-9);
                while (!gpJoueur->verifZone()) gpJoueur->moveX(-2);
                gpJoueur->setTypeAnim(AUCUNE);
                return;
            }
            break;
    }
}
コード例 #25
0
ファイル: Menu.cpp プロジェクト: nop90/ZeldaOLB
void Menu::drawStatut(SDL_Surface* gpScreen) {
    int dec = 200-val;
    std::ostringstream oss;
    
    Joueur* gpJoueur = gpJeu->getJoueur();
    
    int i = 36;
    if (!gpJoueur->hasObjet(O_LANTERNE) || !gpJoueur->getOnilink()) i+=8;
    
switch(getLanguage()) {
case 2: // French
    gpJeu->affiche(gpScreen, "STATUT:", 148,20-dec);
break;

case 4: // Italian
    gpJeu->affiche(gpScreen, "STATO:", 148,20-dec);
break;

case 5: // Spanish
    gpJeu->affiche(gpScreen, "ESTATUTO:", 148,20-dec);
break;

default:
    gpJeu->affiche(gpScreen, "STATUS:", 148,20-dec);
break;	
}

    int v = gpJoueur->getVie();
    int vm = gpJoueur->getVieMax();
    if (v < 10) oss<<"0"; oss << v << "/";
    if (vm < 10) oss<<"0"; oss << vm;
switch(getLanguage()) {
case 2: // French
    gpJeu->affiche(gpScreen, "VIE       : " + oss.str(), 148,36-dec+8);
break;

case 4: // Italian
    gpJeu->affiche(gpScreen, "VITA      : " + oss.str(), 148,36-dec+8);
break;

case 5: // Spanish
    gpJeu->affiche(gpScreen, "VIDA      : " + oss.str(), 148,36-dec+8);
break;

default:
    gpJeu->affiche(gpScreen, "LIFE      : " + oss.str(), 148,36-dec+8);
break;	
}
    i+=16;
    
    
    if (gpJoueur->hasObjet(O_LANTERNE)) {
        oss.str("");
        int m = gpJoueur->getMagie();
        int mm = gpJoueur->getMagieMax();
        if (m < 10) oss<<"0"; oss << m << "/";
        if (mm < 10) oss<<"0"; oss << mm;
switch(getLanguage()) {
case 2: // French
        gpJeu->affiche(gpScreen, "MAGIE     : " + oss.str(), 148,i-dec);
break;

case 4: // Italian
        gpJeu->affiche(gpScreen, "MAGIA     : " + oss.str(), 148,i-dec);
break;

case 5: // Spanish
        gpJeu->affiche(gpScreen, "MAGIA     : " + oss.str(), 148,i-dec);
break;

default:
        gpJeu->affiche(gpScreen, "MAGIC     : " + oss.str(), 148,i-dec);
break;	
}
        i+=16;
    }
    
    if (gpJoueur->getOnilink()) {
        oss.str("");
        int o = gpJoueur->getOnijauge();
        int oo = gpJoueur->getOnimax();
        if (o < 10) oss<<"0"; oss << o << "/";
        if (oo < 10) oss<<"0"; oss << oo;
        gpJeu->affiche(gpScreen, "ONI LINK  : " + oss.str(), 148,i-dec);
        i+=16;
    }
    
    oss.str("");
    oss << gpJoueur->getForce();
switch(getLanguage()) {
case 2: // French
    gpJeu->affiche(gpScreen, "FORCE     : " + oss.str(), 148,i-dec);
break;

case 4: // Italian
    gpJeu->affiche(gpScreen, "FORZA     : " + oss.str(), 148,i-dec);
break;

case 5: // Spanish
    gpJeu->affiche(gpScreen, "STRENGTH  : " + oss.str(), 148,i-dec);
break;

default:
    gpJeu->affiche(gpScreen, "STRENGTH  : " + oss.str(), 148,i-dec);
break;	
}
    i+=16;
    oss.str("");
    oss << gpJoueur->getDefense();
switch(getLanguage()) {
case 2: // French
    gpJeu->affiche(gpScreen, "DEFENSE   : " + oss.str(), 148,i-dec);
break;


case 4: // Italian
    gpJeu->affiche(gpScreen, "DIFESA    : " + oss.str(), 148,i-dec);
break;

case 5: // Spanish
    gpJeu->affiche(gpScreen, "DEFENSA   : " + oss.str(), 148,i-dec);
break;

default:
    gpJeu->affiche(gpScreen, "DEFENSE   : " + oss.str(), 148,i-dec);
break;	
}
    i+=16;
    oss.str("");
    int h = gpJoueur->getTemps(2);
    int m = gpJoueur->getTemps(1);
    int s = gpJoueur->getTemps(0);
    if (h < 10) oss<<"0"; oss << h << ":";
    if (m < 10) oss<<"0"; oss << m << ":";
    if (s < 10) oss<<"0"; oss << s;
switch(getLanguage()) {
case 2: // French
    gpJeu->affiche(gpScreen, "TEMPS     : " + oss.str(), 148,i-dec);
break;

case 4: // Italian
    gpJeu->affiche(gpScreen, "TEMPO     : " + oss.str(), 148,i-dec);
break;

case 5: // Spanish
    gpJeu->affiche(gpScreen, "TIEMPO    : " + oss.str(), 148,i-dec);
break;

default:
    gpJeu->affiche(gpScreen, "TIME      : " + oss.str(), 148,i-dec);
break;	
}

    SDL_Rect src;
    SDL_Rect dst;
    
    src.y=0; src.w=16; src.h=16; dst.y=136-dec;
    
    //épée
    if (gpJoueur->getEpee()) {
        src.x = 16 * (gpJoueur->getEpee()-1); dst.x=156;
        if (gpJoueur->getOni()) {
            if (gpJoueur->hasObjet(O_MASQUE)==2) src.x=162;
            else src.x=112;
        }
        if (dst.y > -15) {
            if (dst.y < 0) {src.y -= dst.y; src.h+= dst.y; dst.y = 0;}
            SDL_BlitSurface(imageObjets, &src, gpScreen, &dst);
            if (src.h < 16) {src.y -= (16-src.h); dst.y-= (16-src.h); src.h = 16;}
        }
    }
    //bouclier
    if (gpJoueur->getBouclier()) {
        src.x = 16 * (gpJoueur->getBouclier()-1); src.y=16; dst.x=176;
        if (gpJoueur->getOni()) {
            if (gpJoueur->hasObjet(O_MASQUE)==2) src.x=162;
            else {src.x=96; src.y=0;}
        }
        if (dst.y > -15) {
            if (dst.y < 0) {src.y -= dst.y; src.h+= dst.y; dst.y = 0;}
            SDL_BlitSurface(imageObjets, &src, gpScreen, &dst);
            if (src.h < 16) {src.y -= (16-src.h); dst.y-= (16-src.h); src.h = 16;}
        }
    }
    //tunique
    if (gpJoueur->getTunique()) {
        src.x = 48 + 16 * (gpJoueur->getTunique()-1); src.y=16; dst.x=196;
        if (gpJoueur->getOni()) src.x=96;
        if (dst.y > -15) {
            if (dst.y < 0) {src.y -= dst.y; src.h+= dst.y; dst.y = 0;}
            SDL_BlitSurface(imageObjets, &src, gpScreen, &dst);
            if (src.h < 16) {src.y -= (16-src.h); dst.y-= (16-src.h); src.h = 16;}
        }
    }
    //bottes
    if (gpJoueur->hasObjet(O_BOTTES)) {
        src.x = 80; src.y=0; dst.x=216;
        if (dst.y > -15) {
            if (dst.y < 0) {src.y -= dst.y; src.h+= dst.y; dst.y = 0;}
            SDL_BlitSurface(imageObjets, &src, gpScreen, &dst);
            if (src.h < 16) {src.y -= (16-src.h); dst.y-= (16-src.h); src.h = 16;}
        }
    }
    //gants
    if (gpJoueur->hasObjet(O_GANTS)) {
        src.x=32; dst.x=236;
        if (gpJoueur->hasObjet(O_GANTS)==2)src.y=34; else src.y=85;
        if (dst.y > -15) {
            if (dst.y < 0) {src.y -= dst.y; src.h+= dst.y; dst.y = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.h < 16) {src.y -= (16-src.h); dst.y-= (16-src.h); src.h = 16;}
        }
    }
    //palmes
    if (gpJoueur->hasObjet(O_PALMES)) {
        src.x=16; src.y=34; dst.x=256;
        if (dst.y > -15) {
            if (dst.y < 0) {src.y -= dst.y; src.h+= dst.y; dst.y = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.h < 16) {src.y -= (16-src.h); dst.y-= (16-src.h); src.h = 16;}
        }
    }
    //sac de bombes
    if (gpJoueur->hasObjet(O_SAC_BOMBES)) {
        src.x = 112; src.y = 16; dst.x=276;
        if (dst.y > -15) {
            if (dst.y < 0) {src.y -= dst.y; src.h+= dst.y; dst.y = 0;}
            SDL_BlitSurface(imageObjets, &src, gpScreen, &dst);
            if (src.h < 16) {src.y -= (16-src.h); dst.y-= (16-src.h); src.h = 16;}
        }
    }
}
コード例 #26
0
ファイル: Menu.cpp プロジェクト: nop90/ZeldaOLB
void Menu::drawInventaire(SDL_Surface* gpScreen) {
    int dec = 200-val;
    
    Joueur* gpJoueur = gpJeu->getJoueur();
    
    gpJeu->affiche(gpScreen, "Y", 20-dec,20);

    SDL_Rect src;
    SDL_Rect dst;
    
    src.w=16; src.h=17;
    
    //arc
    if (gpJoueur->hasObjet(O_ARC)) {
        src.x=0; dst.x=32-dec; dst.y=32;
        if (gpJoueur->hasObjet(O_ARC)==5)src.y=0; else {src.x=16; src.y=102;}
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //grappin
    if (gpJoueur->hasObjet(O_GRAPPIN)) {
        src.x=16; src.y=0; dst.x=64-dec; dst.y=32;
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //bombes
    if (gpJoueur->hasObjet(O_SAC_BOMBES) && gpJoueur->getBombe()>0) {
        src.x=32; src.y=0; dst.x=96-dec; dst.y=32;
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //baguette de feu
    if (gpJoueur->hasObjet(O_BFEU)) {
        src.x=0; src.y=17; dst.x=32-dec; dst.y=64;
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //baguette de glace
    if (gpJoueur->hasObjet(O_BGLACE)) {
        src.x=16; src.y=17; dst.x=64-dec; dst.y=64;
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //lanterne
    if (gpJoueur->hasObjet(O_LANTERNE)) {
        src.x=32; src.y=17; dst.x=96-dec; dst.y=64;
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //marteau
    if (gpJoueur->hasObjet(O_MARTEAU)) {
        src.x=0; src.y=34; dst.x=32-dec; dst.y=96;
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //flute
    if (gpJoueur->hasObjet(O_OCARINA)) {
        src.x=0; src.y=85; dst.x=64-dec; dst.y=96;
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //masque
    if (gpJoueur->hasObjet(O_MASQUE)) {
        src.x=0; src.y=102; dst.x=96-dec; dst.y=96;
        if (gpJoueur->hasObjet(O_MASQUE)==2) {src.x=16;src.y=85;}
        if (dst.x > -15) {
            if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
            SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
            if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
        }
    }
    
    //bouteilles
    for (int i = 0; i < 3; i++) {
        if (gpJoueur->hasBouteille(i)) {
            dst.x=32*(i+1)-dec; dst.y=128;
            switch (gpJoueur->hasBouteille(i)) {
                case 1 : src.x=0; src.y=68; break;
                case 2 : src.x=0; src.y=51; break;
                case 3 : src.x=16; src.y=51; break;
                case 4 : src.x=32; src.y=51; break;
            }    
            if (dst.x > -15) {
                if (dst.x < 0) {src.x -= dst.x; src.w+= dst.x; dst.x = 0;}
                SDL_BlitSurface(imageInventaire, &src, gpScreen, &dst);
                if (src.w < 16) {src.x -= (16-src.w); dst.x-= (16-src.w); src.w = 16;}
            }
        }
    }
    
}
コード例 #27
0
ファイル: evenement.cpp プロジェクト: Noxy/ProjetCpp
void gestionCliqueG(int cliqueX, int cliqueY)
{
    Position positionVue;
    SDL_mutexP(mutexInput);
        positionVue.offsetCaseX=maPosition.offsetCaseX;
        positionVue.offsetCaseY=maPosition.offsetCaseY;
        positionVue.offsetPositionX=maPosition.offsetPositionX;
        positionVue.offsetPositionY=maPosition.offsetPositionY;
    SDL_mutexV(mutexInput);

    bool rien=true;

    if(cliqueY<maxH-MENU_H)//si on est hors du menu
    {
        int cliqueXTemp=(int)(cliqueX+positionVue.offsetPositionX)/TILE_SIZE+positionVue.offsetCaseX;
        int cliqueYTemp=(int)(cliqueY+positionVue.offsetPositionY)/TILE_SIZE+positionVue.offsetCaseY;


        if(objetReadyToDrop !=0)
        {
            int taille = ObjetMap::gettilesize(objetReadyToDrop);
            bool nocollision = true;
            int coutb = ObjetMap::coutbois(objetReadyToDrop);
            int coutm = ObjetMap::coutmiam(objetReadyToDrop);

            SDL_mutexP(mutexObjet);

            if(joueur1.getbois() >= coutb && joueur1.getmiam() >= coutm)
            {
                joueur1.setbois(joueur1.getbois()-coutb);
                joueur1.setmiam(joueur1.getmiam()-coutm);
                for(int i=cliqueXTemp;i<=cliqueXTemp+taille;i++)
                {
                    for(int j=cliqueYTemp;j<=cliqueYTemp+taille;j++)
                    {
                        if(m->getMap()[i][j] != 0)
                        {
                            nocollision = false;
                        }
                    }
                }
                if(nocollision)
                {
                    for(int i=cliqueXTemp;i<=cliqueXTemp+taille;i++)
                    {
                        for(int j=cliqueYTemp;j<=cliqueYTemp+taille;j++)
                        {
                            m->setMap(i,j,1);
                        }
                    }

                    vector<int> *tab = new vector<int>;
                    ObjetMap *n;
                    tab->clear();
                    switch(objetReadyToDrop)
                    {
                        case 4://forum
                            tab->push_back(6);
                            n = new Forum(cliqueXTemp,cliqueYTemp,12,4,100,0,*tab);
                            break;
                        case 5://caserne
                            tab->push_back(7);
                            n = new Caserne(cliqueXTemp,cliqueYTemp,12,5,100,0,*tab);
                            break;
                        case 6://peon
                            tab->push_back(4);
                            tab->push_back(5);
                            n = new Peon(cliqueXTemp,cliqueYTemp,1,6,10,1,0,*tab);
                            break;
                        case 7://lancier
                            n = new Lancier(cliqueXTemp,cliqueYTemp,1,7,10,1,0,*tab);
                            break;
                    }

                   vector<ObjetMap*> v = m->getvec();
                   v.push_back(n);
                   m->setvec(v);
                   objetReadyToDrop = 0;

                }
            }
            SDL_mutexV(mutexObjet);
        }
        else
        {
            ObjetMap *temp;
            for(int i=0;i< m->getvec().size();i++)
            {
                temp=m->getvec()[i];
                if(cliqueXTemp>=((point)temp->getc1()).x  && cliqueXTemp<=(((point)temp->getc1()).x+temp->getnum()) && cliqueYTemp>=((point)temp->getc1()).y  && cliqueYTemp<=(((point)temp->getc1()).y+temp->getnum()) )
                {
                    rien=false;
                    currentObj=temp;
                }
            }
        }
    }
    else if(currentObj->getcamp()==0)//si on est dans le menu et que l'objet est à nous
    {
        SDL_Rect position;
        int taille;
        position.x = 30;

        for(int i = 0;i<currentObj->getcanDo().size();i++)
        {
            taille=(ObjetMap::gettilesize(currentObj->getcanDo()[i]))*TILE_SIZE;
            position.y = (maxH - MENU_H) + (MENU_H - taille)/2;

            if(cliqueX>=position.x && cliqueX<=position.x+taille && cliqueY>=position.y && cliqueY<=position.y+taille)
            {
                rien=false;
                objetReadyToDrop=currentObj->getcanDo()[i];
            }
            position.x += taille + 30;
        }

    }

    if(rien)
    {
        objetReadyToDrop=0;
        currentObj=NULL;
    }
}
コード例 #28
0
ファイル: Objet.cpp プロジェクト: eduardok/ZeldaOLB
void Objet::ramasse() {
    Joueur* gpJoueur = gpJeu->getJoueur();
    switch(type) {                
        case I_RUBIS_VERT : 
            gpJoueur->setRubis(gpJoueur->getRubis()+1); 
            gpJeu->getAudio()->playSound(14);
            break;
        case I_RUBIS_BLEU : 
            gpJoueur->setRubis(gpJoueur->getRubis()+5); 
            gpJeu->getAudio()->playSound(14);
            break;
        case I_RUBIS_ROUGE : 
            gpJoueur->setRubis(gpJoueur->getRubis()+20); 
            gpJeu->getAudio()->playSound(14);
            break;
        case I_PETIT_COEUR : 
            gpJoueur->setBoostVie(gpJoueur->getBoostVie()+2);
            if (gpJoueur->getVie()==gpJoueur->getVieMax()) gpJeu->getAudio()->playSound(15);
            break;
        case I_FLECHE : 
            gpJoueur->setFleche(gpJoueur->getFleche()+5); 
            gpJeu->getAudio()->playSound(13);
            break;
        case I_BOMBE : 
            gpJoueur->setBombe(gpJoueur->getBombe()+1); 
            gpJeu->getAudio()->playSound(13);
            break;
        case I_MAGIE_PEU : 
            gpJoueur->setBoostMagie(gpJoueur->getBoostMagie()+gpJoueur->getMagieMax()/8);
            //if (gpJoueur->getMagie()<gpJoueur->getMagieMax())
            gpJeu->getAudio()->playSound(13);
            break;
        case I_MAGIE_BCP :
            gpJoueur->setBoostMagie(gpJoueur->getBoostMagie()+gpJoueur->getMagieMax()/4);
            if (gpJoueur->getMagie()<gpJoueur->getMagieMax())
                gpJeu->getAudio()->playSound(37);
            else gpJeu->getAudio()->playSound(13);
            break;
        case I_QUART_COEUR : gpJoueur->setCoeur(id); gpJeu->trouve(C_QUART_COEUR); break;
        case I_COEUR : gpJoueur->setCoeur(gpJeu->getZone()-15); gpJeu->trouve(C_COEUR); break;
        case I_EPEE : gpJeu->trouve(C_EPEE); break;
        case I_CRISTAL : 
            switch (gpJeu->getZone()) {
                case 15 : gpJoueur->setCristal(0); break;
                case 17 : gpJoueur->setCristal(1); break;
                case 19 : gpJoueur->setCristal(2); break;
                case 21 : gpJoueur->setCristal(3); break;
                case 22 : gpJoueur->setCristal(4); break;
                default : vie = 0; return;
            }gpJeu->trouve(C_CRISTAL); break;
        case I_EXCALIBUR : gpJeu->trouve(C_EXCALIBUR); gpJoueur->setCoeur(7); break;
        case I_TRIFORCE : gpJeu->trouve(C_TRIFORCE); break;
        case I_ARC : gpJeu->trouve(C_ARC); break;
        case I_PETITE_CLE : 
            gpJeu->trouve(C_CLE); 
            int zone; zone = gpJeu->getZone();
            int region[2]; 
            region[0] = gpJeu->getMonde()->regionValue(0);
            region[1] = gpJeu->getMonde()->regionValue(1);
            if (zone==16 && region[0]==120*16 && region[1]==15*16) gpJoueur->setCoffre(1,28); 
            if (zone==16 && region[0]==280*16 && region[1]==60*16) gpJoueur->setCoffre(1,29); 
            if (zone==20 && region[0]==0 && region[1]==45*16) gpJoueur->setCoffre(5,1); 
            if (zone==20 && region[0]==20*16 && region[1]==0) gpJoueur->setCoffre(5,3); 
            if (zone==20 && region[0]==60*16 && region[1]==45*16) gpJoueur->setCoffre(5,4); 
            if (zone==20 && region[0]==60*16 && region[1]==60*16) gpJoueur->setCoffre(5,5); 
            if (zone==20 && region[0]==80*16 && region[1]==45*16) gpJoueur->setCoffre(5,6); 
            if (zone==20 && region[0]==100*16 && region[1]==45*16) gpJoueur->setCoffre(5,7); 
            if (zone==20 && region[0]==100*16 && region[1]==60*16) gpJoueur->setCoffre(5,8); 
            if (zone==20 && region[0]==120*16 && region[1]==15*16) gpJoueur->setCoffre(5,9); 
            if (zone==20 && region[0]==120*16 && region[1]==75*16) gpJoueur->setCoffre(5,10); 
            if (zone==20 && region[0]==160*16 && region[1]==0) gpJoueur->setCoffre(5,11); 
            if (zone==20 && region[0]==160*16 && region[1]==60*16) gpJoueur->setCoffre(5,12); 
            if (zone==20 && region[0]==220*16 && region[1]==0) gpJoueur->setCoffre(5,13); 
            if (zone==20 && region[0]==220*16 && region[1]==60*16) gpJoueur->setCoffre(5,14); 
            if (zone==23) gpJoueur->setCoffre(8,16); 
            if (zone==28) gpJoueur->setCoffre(13,8);
            break;
        /*case I_PETITE_CLE : src.x = 32; src.y = 0; break;
        case I_TRIFORCE : src.x = 166; src.y = 26; src.h = 25;src.w = 26; break;
        case I_ARC : src.x = 144; src.y = 34; break;*/
    }
    vie=0;
}
コード例 #29
0
ファイル: HUD.cpp プロジェクト: xchopin/KSpree
	void static dessinerHUD(sf::RenderWindow& window, sf::Clock& temps, Joueur j,int manche) {
		
		// Boite
		sf::RectangleShape boite(sf::Vector2f(window.getSize().x -60, 70));
		boite.setPosition(0, window.getSize().y - 65);
		boite.setFillColor(sf::Color(0, 0, 0));
		window.draw(boite);

		// Texte
		sf::Text kill;
		sf::Text round;
		sf::Text munition;
		sf::Text texteVie;
		sf::Font font;
		if (!font.loadFromFile("./assets/arial.ttf")) { std::cout << "Erreur de chargement de la police arial.ttf" << std::endl; }

		kill.setFont(font);
		kill.setCharacterSize(12);
		kill.setColor(sf::Color::Red);
		kill.setStyle(sf::Text::Bold);
		kill.setString("KILLS: " + to_string(j.m_kill));
		kill.setPosition(window.getSize().x / 2 - 30, 1);
		window.draw(kill);

		// Manche 

		round.setFont(font);
		round.setCharacterSize(14);
		round.setColor(sf::Color::Red);
		round.setStyle(sf::Text::Bold);
		round.setString("MANCHE: " + to_string(manche));
		round.setPosition(window.getSize().x / 2 - 30, window.getSize().y - 60);
		window.draw(round);


		// Munition
		munition.setFont(font);
		munition.setCharacterSize(12);
		munition.setColor(sf::Color::White);
		munition.setStyle(sf::Text::Bold);
		munition.setString("P226: " + to_string(j.getMunition()) + " / UNL");
		munition.setPosition(50, window.getSize().y - 35);
		window.draw(munition);

		// La vie
		sf::RectangleShape vie(sf::Vector2f(j.getVie() * 1.5, 7));
		vie.setPosition(32, window.getSize().y - 50);
		vie.setFillColor(sf::Color(255, 0, 0));
		window.draw(vie);


		// image

		sf::Texture texture_joueur;
		texture_joueur.loadFromFile("./assets/player_face.png");
		sf::Sprite sprite_joueur(texture_joueur);
		sprite_joueur.setPosition(7, window.getSize().y - 65);
		
		window.draw(sprite_joueur);

	

		// Le temps
		sf::Text chrono;
		chrono.setFont(font);
		chrono.setCharacterSize(15);
		chrono.setColor(sf::Color::White);
		chrono.setStyle(sf::Text::Bold);
		int time = int(temps.getElapsedTime().asSeconds());
		int minutes = time / 60;
		int secondes = time;
		if (secondes >= 60) {
			int retirer = 60 * minutes;
			secondes = time - retirer;
		}


		chrono.setString(to_string(minutes) + " : " + to_string(secondes));
		chrono.setPosition(window.getSize().x / 2, window.getSize().y - 25);
		window.draw(chrono);


	}
コード例 #30
0
ファイル: affichage.cpp プロジェクト: Noxy/ProjetCpp
Uint32 drawMap(Uint32 intervalle, void *arg)
{
    Position positionVue;
    SDL_mutexP(mutexInput);
        positionVue.offsetCaseX=maPosition.offsetCaseX;
        positionVue.offsetCaseY=maPosition.offsetCaseY;
        positionVue.offsetPositionX=maPosition.offsetPositionX;
        positionVue.offsetPositionY=maPosition.offsetPositionY;
    SDL_mutexV(mutexInput);

    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
    SDL_Rect position;

    int iMax=((maxH-MENU_H)/TILE_SIZE)+1, jMax=(maxW/TILE_SIZE)+1; //optimisation
    for(int i=0;i<iMax;i++)
    {
        for(int j=0;j<jMax;j++)
        {
            position.x = j*TILE_SIZE-positionVue.offsetPositionX;
            position.y = i*TILE_SIZE-positionVue.offsetPositionY;

            SDL_BlitSurface(m->getT()->getTexture(0), NULL, screen, &position);//on blit de l'herbe
        }
    }

    point temp;

    SDL_mutexP(mutexObjet);
        for(int i=0;i< m->getvec().size();i++)
        {
            temp=m->getvec()[i]->getc1();
            if( (temp.x >= positionVue.offsetCaseX-12) && (temp.x <= (positionVue.offsetCaseX+maxW/TILE_SIZE+12)) && (temp.y >= positionVue.offsetCaseY-12) && (temp.y <= (positionVue.offsetCaseY+maxH/TILE_SIZE+12)) )
            {
                position.x = (temp.x-positionVue.offsetCaseX)*TILE_SIZE-positionVue.offsetPositionX;
                position.y = (temp.y-positionVue.offsetCaseY)*TILE_SIZE-positionVue.offsetPositionY;
                SDL_BlitSurface(m->getT()->getTexture(m->getvec()[i]->gettype()),NULL,screen,&position);
            }
        }
    SDL_mutexV(mutexObjet);

    //Affichage du fond du menu en bas
    SDL_Surface *fondMenu = NULL;
    fondMenu=SDL_CreateRGBSurface(SDL_HWSURFACE, maxW, MENU_H, 32, 0, 0, 0, 0);
    SDL_FillRect(fondMenu, NULL, SDL_MapRGB(fondMenu->format, 200, 200, 200));
    position.x=0;
    position.y=maxH-MENU_H;
    SDL_BlitSurface(fondMenu, NULL, screen, &position);
    SDL_FreeSurface(fondMenu);

    if(TTF_Init() == -1)
    {
        cout << TTF_GetError() << endl;
        exit(EXIT_FAILURE);
    }

    SDL_Color color;
    color.b = 255;
    color.g = 255;
    color.r = 255;
    TTF_Font *font = TTF_OpenFont("arial.ttf", 65);

    ostringstream out;
    string s;


    //barre menu
    fondMenu=SDL_CreateRGBSurface(SDL_HWSURFACE, 5, MENU_H, 32, 0, 0, 0, 0);
    SDL_FillRect(fondMenu, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
    position.x = maxW/4;
    position.y = (maxH - MENU_H);
    SDL_BlitSurface(fondMenu, NULL, screen, &position);
    position.x = 3*maxW/4;
    SDL_BlitSurface(fondMenu, NULL, screen, &position);
    SDL_FreeSurface(fondMenu);

    //Affichage elem menu
    if(currentObj != NULL)
    {
        position.x = 30;
        //optimisation inclure var nbr batiment max dans map
        for(int i = 0;i<currentObj->getcanDo().size();i++)
        {//objet productible
            position.y = (maxH - MENU_H) + (MENU_H - ObjetMap::gettilesize(currentObj->getcanDo()[i])*10)/2;
            SDL_BlitSurface(m->getT()->getTexture(currentObj->getcanDo()[i]),NULL,screen,&position);
            position.x += ObjetMap::gettilesize(currentObj->getcanDo()[i])*10 + 30;
        }


        //info objet

        out <<currentObj->getpv();

        s = ObjetMap::getnom(currentObj->gettype()) +"      "+ out.str();
        position.x = maxW/4+10;

        fondMenu = TTF_RenderText_Solid(font,s.c_str(),color);
        SDL_BlitSurface(fondMenu, NULL, screen, &position);
        SDL_FreeSurface(fondMenu);
    }
    //ressources
    position.x = 3*maxW/4 +10;
    position.y = (maxH - MENU_H);

    out.str("");
    out << joueur1.getbois();
    s = "Bois : " + out.str();
    fondMenu = TTF_RenderText_Solid(font,s.c_str(),color);
    SDL_BlitSurface(fondMenu, NULL, screen, &position);
    SDL_FreeSurface(fondMenu);

    position.y = (maxH - MENU_H) + MENU_H/2;
    position.x = 3*maxW/4;

    out.str("");
    out << joueur1.getmiam();
    s= " Miam : " + out.str();
    fondMenu = TTF_RenderText_Solid(font,s.c_str(),color);
    SDL_BlitSurface(fondMenu, NULL, screen, &position);
    SDL_FreeSurface(fondMenu);

    //drag and drop!

    position.x = souris.offsetCaseX;
    position.y = souris.offsetCaseY;
    if(objetReadyToDrop != 0)
    {
        SDL_BlitSurface(m->getT()->getTexture(objetReadyToDrop), NULL, screen, &position);
    }

    //victoire ?
    if(Victoire != -1)
    {
        s = "Win";
        fondMenu = TTF_RenderText_Solid(font,s.c_str(),color);
        position.x = (maxW-fondMenu->w)/2;
        position.y = (maxH-fondMenu->h)/2;
        SDL_BlitSurface(fondMenu, NULL, screen, &position);
        SDL_FreeSurface(fondMenu);
    }

    TTF_CloseFont(font);

    TTF_Quit();

    SDL_Flip(screen);


    return intervalle;
}