Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Lab 5 - Trouver le Dalek
- Programmé par : Elouan Colichet, Dylan Girard, Vincent Bradette
- Professeur : René Aubry
- */
- #include "stdafx.h"
- #include "stdio.h"
- #include <string>
- #include <iostream>
- #include <Windows.h>
- #include <time.h>
- using namespace std;
- HANDLE hConsole;
- // Constante
- #define maxvie 5
- #define departpuissance 25
- #define maxpuissance 100
- int viesRestantes = 0;
- bool _salle = false;
- int _pGauche = 0, _milieu = 0, _pDroite = 0, _porte1 = 0, _porte2 = 0, _porte3 = 0, _porte4 = 0, _porte5 = 0, _porte6 = 0, _choix = 0;
- class Personnage {
- public:
- int _position, _regeneration = 0, _puissance = 25;
- string _arme_main_droite = { "aucunes" };
- void affiPortes();
- void affiCouloirs(int position);
- void random();
- void posiPerso(int portes);
- void couloirs(int direction);
- void perdu();
- void header();
- void Salle1();
- int _nb_vies, _pGauche, _milieu, _pDroite;
- char _tab_portes[3] = { '\x0B2', '\x0B2', '\x0B2' };
- char _tabEtage[3] = { '\x0B0', '\x0B0', '\x0B0' };
- char __porte1[2] = { '\x0B0', '\x0B0' };
- char __porte2[2] = { '\x0B0', '\x0B0' };
- Personnage(int, int);
- };
- class Magicien : public Personnage
- {
- public:
- void Salle2(); // La salle des 6 _portes
- void iniPortes(); //initialisation des _portes
- void perdu2();
- int choix;
- Magicien(int, int);
- };
- Personnage::Personnage(int nb_vies, int puissance)
- {
- _nb_vies = nb_vies;
- _puissance = puissance;
- }
- Magicien::Magicien(int nb_vies, int puissance):Personnage(nb_vies, puissance)
- {
- _nb_vies = nb_vies;
- _puissance = puissance;
- }
- void Personnage::posiPerso(int portes)
- {
- random();
- if (_salle == true)
- {
- switch (portes)
- {
- case 1: {
- cout << "Vous entrez dans la porte gauche..." << endl;
- if (_pGauche == 0)
- {
- _nb_vies++;
- cout << "Vous gagnez une vie ! nb vies = " << _nb_vies << endl;
- }
- if (_pGauche == 1)
- {
- cout << "EXTERMINATE ! ..... Vous \x088tes mort...." << endl;
- system("pause");
- system("cls");
- perdu();
- }
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- cout << "Vous entrez dans la porte du milieu" << endl;
- if (_milieu == 0)
- {
- _nb_vies++;
- cout << "Vous gagnez une vie ! nb vies = " << _nb_vies << endl;
- }
- if (_milieu == 1)
- {
- cout << "EXTERMINATE ! ..... Vous \x088tes mort...." << endl;
- system("pause");
- system("cls");
- perdu();
- }
- system("pause");
- system("cls");
- break;
- }
- case 3: {
- cout << "Vous entrez dans la porte droite" << endl;
- if (_pDroite == 0)
- {
- _nb_vies++;
- cout << "Vous gagnez une vie ! nb vies = " << _nb_vies << endl;
- }
- if (_pDroite == 1)
- {
- cout << "EXTERMINATE ! ..... Vous \x088tes mort...." << endl;
- system("pause");
- system("cls");
- perdu();
- }
- break;
- }
- default:
- break;
- }
- }
- if (_salle == false)
- {
- switch (portes)
- {
- case 1: {
- cout << "Vous entrez dans la porte gauche...." << endl;
- break;
- }
- case 2: {
- cout << "Vous montez les escaliers..." << endl;
- _salle = true;
- break;
- }
- case 3: {
- cout << "Vous entrez dans la porte droite...." << endl;
- break;
- }
- default:
- break;
- }
- }
- }
- void Personnage::couloirs(int direction)
- {
- if (direction == 1)
- {
- cin >> direction;
- switch (direction)
- {
- case 1: {
- _nb_vies++;
- cout << "Vous descendez les escaliers et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- _nb_vies++;
- cout << "Vous allez au fond du couloir et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
- system("pause");
- system("cls");
- break;
- }
- default:
- cout << "OUPS ! Rechoississez" << endl;
- couloirs(direction);
- }
- Salle1();
- }
- if (direction == 3)
- {
- cin >> direction;
- switch (direction)
- {
- case 1: {
- _nb_vies++;
- cout << "Vous descendez les escaliers et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- _nb_vies++;
- cout << "Vous allez au fond du couloir et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
- system("pause");
- system("cls");
- break;
- }
- default:
- cout << "OUPS ! Rechoississez" << endl;
- couloirs(direction);
- }
- Salle1();
- }
- }
- void Personnage::perdu()
- {
- int choix = 0;
- system("cls");
- cout << "Voulez vous retenter ?" << endl;
- cout << "oui(1) non (2)" << endl;
- cin >> choix;
- if (choix == 1)
- {
- _regeneration++;
- cout << "REGENERATION numero " << _regeneration << " ! " << "Allons-Y !" << endl;
- system("pause");
- system("cls");
- _salle = false;
- Salle1();
- }
- if (choix == 2)
- {
- cout << "Ok.. les Daleks ont envahis la Terre mais bon ..." << endl;
- cout << "C'est pas comme si la Terre n'allais pas \x088tre detruite..." << endl;
- cout << "Bye !" << endl;
- system("pause");
- system("cls");
- exit(0);
- }
- }
- void Personnage::random()
- {
- srand((unsigned int)time(NULL));
- _pGauche = rand() % 2;
- _pDroite = rand() % 2;
- _milieu = rand() % 2;
- }
- void Personnage::affiCouloirs(int position)
- {
- for (int inst = 0; inst < 2; inst++)
- {
- if (position == 1)
- {
- cout << " " << __porte1[inst] << " ";
- }
- if (position == 3)
- {
- cout << " " << __porte2[inst] << " ";
- }
- }
- }
- void Personnage::affiPortes()
- {
- if (_salle == false)
- {
- for (int inst = 0; inst < 3; inst++)
- {
- cout << " " << _tab_portes[inst] << " ";
- }
- cout << endl;
- }
- if (_salle == true)
- {
- for (int inst = 0; inst < 3; inst++)
- {
- cout << " " << _tabEtage[inst] << " ";
- }
- cout << endl;
- }
- }
- void Personnage::header()
- {
- cout << "##############################################################################" << endl;
- cout << "###### Wibbly Wobbly Timey Wimey ! #########" << endl;
- cout << "##############################################################################" << endl << endl;
- cout << "Nb de vies = " << _nb_vies << endl;
- cout << "Arme = " << _arme_main_droite << endl;
- cout << "Puissance = " << _puissance << endl;
- cout << endl;
- }
- void Personnage::Salle1()
- {
- int position = 0, choixArmes = 0;
- cout << "Seigneur du temps ! bienvenue ! Vous avez \x082t\x082 contraint de vous retrouver \n sur une des lunes de SKARO," << endl;
- cout << "plan\x08Ate des Daleks, enemi de votre race. Vous tentez de leurs \x082" << "chapper mais vous devez pour cela rester discret." << endl;
- system("pause");
- system("cls");
- while (_nb_vies < 5)
- {
- if (_arme_main_droite == "aucunes")
- {
- header();
- cout << "Choississez une arme parmis ces suivantes : " << endl << "1 - Canif" << endl << "2 - Marteau" << endl << "3 - Pioche" << endl;
- cin >> choixArmes;
- if (choixArmes == 1)
- {
- _arme_main_droite = { "Canif" };
- cout << "Vous choississez donc le " << _arme_main_droite << endl;
- system("pause");
- system("cls");
- }
- if (choixArmes == 2)
- {
- _arme_main_droite = { "Marteau" };
- cout << "Vous choississez donc le " << _arme_main_droite << endl;
- system("pause");
- system("cls");
- }
- if (choixArmes == 3)
- {
- _arme_main_droite = { "Pioche" };
- cout << "Vous choississez donc le " << _arme_main_droite << endl;
- system("pause");
- system("cls");
- }
- }
- else
- {
- header();
- if (_salle == false)
- {
- affiPortes();
- cout << endl << "Quelle porte choississez vous ? input 1/2/3" << endl;
- cin >> position;
- while (position <= 0 || position > 3)
- {
- cout << "Veuillez entrer de nouveau votre choix de porte. input 1/2/3" << endl;
- cin >> position;
- }
- if (position == 1)
- {
- cout << "Quelle direction choississez vous ? Escalier (1) Couloir (2)" << endl;
- affiCouloirs(position);
- couloirs(position);
- }
- if (position == 3)
- {
- cout << "Quelle direction choississez vous ? Escalier (1) Couloir (2)" << endl;
- affiCouloirs(position);
- couloirs(position);
- }
- }
- affiPortes();
- posiPerso(position);
- system("pause");
- if (_salle == true)
- {
- system("cls");
- header();
- affiPortes();
- cout << "Vous entrez dans une grande salle dans laquelle se trouve trois portes." << endl;
- cout << "l'une d'entre elle cache un Dalek.... Bonne chance !" << endl;
- cout << "Veuillez entrer votre choix de porte de l'\x082tage input 1/2/3" << endl;
- cin >> position;
- while (position <= 0 || position > 3)
- {
- cout << "Veuillez entrer de nouveau votre choix de porte input 1/2/3" << endl;
- cin >> position;
- }
- posiPerso(position);
- system("pause");
- _salle = false;
- }
- }
- system("cls");
- }
- Magicien magicien(1,1);
- magicien.iniPortes();
- system("pause");
- }
- void Magicien::Salle2()
- {
- int choix;
- cout << "Vous \x088tes desormais un magicien accomplis," << endl;
- cout << "vous poss\x08A" << "der un b\x083ton tueur d'ennemies" << endl << endl << endl;
- system("pause");
- system("cls");
- cout << "===================================================================" << endl;
- cout << "| Salle 2 |" << endl;
- cout << "===================================================================" << endl << endl;
- cout << "Nb vies = " << _nb_vies << endl;
- cout << "Arme = " << _arme_main_droite << endl;
- cout << "Puissance = " << _puissance << endl << endl;
- cout << "Vous \x088tes dans une salle circulaire en cercle de 360" << "\xf8 " << endl << "ronde avec les coins de la piece arrondis." << endl;
- cout << "De plus, la piece est composer de 6 portes" << endl << "(placer de facon a ce que chaque porte forme un cercle )." << endl;
- cout << "Vous devez choisir une porte entre les 6 devants vous." << endl;
- cout << "Choisissez un chiffre de 1 \x085" << " 6" << endl;
- cin >> choix;
- switch (choix) {
- case 1:
- {
- if (_porte1 == 0)
- {
- _nb_vies = 0;
- perdu2();
- }
- else { _nb_vies += 1; }
- break;
- }
- case 2:
- {
- if (_porte2 == 0)
- {
- _nb_vies = 0;
- perdu();
- }
- else { _nb_vies = _nb_vies + 1; }
- break;
- }
- case 3:
- {
- if (_porte3 == 0)
- {
- _nb_vies = 0;
- perdu();
- }
- else { _nb_vies = _nb_vies + 1; }
- break;
- }
- case 4:
- {
- if (_porte4 == 0)
- {
- _nb_vies = 0;
- perdu();
- }
- else { _nb_vies = _nb_vies + 1; }
- break;
- }
- case 5:
- {
- if (_porte5 == 0)
- {
- _nb_vies = 0;
- perdu();
- }
- else { _nb_vies = _nb_vies + 1; }
- break;
- }
- case 6:
- {
- if (_porte6 == 0)
- {
- _nb_vies = 0;
- perdu();
- }
- else { _nb_vies = _nb_vies + 1; }
- break;
- }
- }
- system("cls");
- cout << "Vous avez reussi, vous sentez votre puissance augmenter" << endl;
- cout << "Vous vous retrouvez avec un b\x083ton magique disparition des obstacle" << endl;
- }
- void Magicien::perdu2()
- {
- system("cls");
- cout << "Voulez vous retenter ?" << endl;
- cout << "oui(1) non (2)" << endl;
- cin >> _choix;
- if (_choix == 1)
- {
- _regeneration++;
- cout << "REGENERATION numero " << _regeneration << " ! " << "Allons-Y !" << endl;
- system("pause");
- system("cls");
- Personnage personnage(1,1);
- personnage.Salle1();
- }
- if (_choix == 2)
- {
- cout << "Ok.. les Daleks ont envahis la Terre mais bon ..." << endl;
- cout << "C'est pas comme si la Terre n'allais pas \x088\tre detruite..." << endl;
- cout << "Bye !" << endl;
- system("pause");
- system("cls");
- exit(0);
- }
- }
- void Magicien::iniPortes() {
- srand((unsigned int)time(NULL)); // initialisation de rand
- _porte1 = rand() % 2;
- _porte2 = rand() % 2;
- _porte3 = rand() % 2;
- _porte4 = rand() % 2;
- _porte5 = rand() % 2;
- _porte6 = rand() % 2;
- Salle2();
- }
- void main()
- {
- Personnage personnage(1,1);
- personnage.Salle1();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement