Bläddra i källkod

Replace CrLf by Lf

Remove this ugly Windows legacy.
DricomDragon 4 år sedan
förälder
incheckning
6ed67017b8
21 ändrade filer med 1227 tillägg och 1227 borttagningar
  1. 51 51
      Bouton.cpp
  2. 30 30
      Bouton.h
  3. 46 46
      ChampDeBataille.cpp
  4. 31 31
      ChampDeBataille.h
  5. 20 20
      Cliquable.cpp
  6. 25 25
      Cliquable.h
  7. 39 39
      Ennemy.cpp
  8. 29 29
      Ennemy.h
  9. 142 142
      Helico.cpp
  10. 44 44
      Helico.h
  11. 45 45
      Icones.cpp
  12. 32 32
      Icones.h
  13. 201 201
      Joueur.cpp
  14. 72 72
      Joueur.h
  15. 133 133
      eventLoop.cpp
  16. 18 18
      eventLoop.h
  17. 58 58
      main.cpp
  18. 147 147
      menuFire.cpp
  19. 17 17
      menuFire.h
  20. 28 28
      takeRand.cpp
  21. 19 19
      takeRand.h

+ 51 - 51
Bouton.cpp

@@ -1,51 +1,51 @@
-#include "Bouton.h"
-
-
-
-
-
-Bouton::Bouton(int x, int y, int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur) : m_ecran(ecran),proprio(lanceur),m_armeAssignee(armeAssignee)
-{
-    m_positionIcone.x=x;
-    m_positionIcone.y=y;
-    switch (choixArme)
-    {
-        case 0:
-            imageIcone=SDL_LoadBMP("Images/IconeBaroudeur.bmp");
-            break;
-        case 1:
-            imageIcone=SDL_LoadBMP("Images/IconeUsiane.bmp");
-            break;
-        case 2:
-            imageIcone=SDL_LoadBMP("Images/IconeTriphaseur.bmp");
-            break;
-    }
-
-}
-Bouton::~Bouton()
-{
-    SDL_FreeSurface(imageIcone);
-}
-
-void Bouton::afficher()
-{
-    if (Cliquable::m_tempsFire==0)
-    {
-        this->clic();
-    }
-    SDL_BlitSurface(imageIcone,0,m_ecran,&m_positionIcone);
-}
-
-void Bouton::clic()
-{
-    /*Teste si le click est sur l'icone, puis fait l'assignation de l'arme.*/
-    if (Cliquable::m_yFire>m_positionIcone.y)
-    {
-        if (Cliquable::m_xFire>m_positionIcone.x&&Cliquable::m_xFire<(m_positionIcone.x+140))
-        {
-            proprio->setArme(m_armeAssignee);
-        }
-    }
-
-
-}
+#include "Bouton.h"
+
+
+
+
+
+Bouton::Bouton(int x, int y, int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur) : m_ecran(ecran),proprio(lanceur),m_armeAssignee(armeAssignee)
+{
+    m_positionIcone.x=x;
+    m_positionIcone.y=y;
+    switch (choixArme)
+    {
+        case 0:
+            imageIcone=SDL_LoadBMP("Images/IconeBaroudeur.bmp");
+            break;
+        case 1:
+            imageIcone=SDL_LoadBMP("Images/IconeUsiane.bmp");
+            break;
+        case 2:
+            imageIcone=SDL_LoadBMP("Images/IconeTriphaseur.bmp");
+            break;
+    }
+
+}
+Bouton::~Bouton()
+{
+    SDL_FreeSurface(imageIcone);
+}
+
+void Bouton::afficher()
+{
+    if (Cliquable::m_tempsFire==0)
+    {
+        this->clic();
+    }
+    SDL_BlitSurface(imageIcone,0,m_ecran,&m_positionIcone);
+}
+
+void Bouton::clic()
+{
+    /*Teste si le click est sur l'icone, puis fait l'assignation de l'arme.*/
+    if (Cliquable::m_yFire>m_positionIcone.y)
+    {
+        if (Cliquable::m_xFire>m_positionIcone.x&&Cliquable::m_xFire<(m_positionIcone.x+140))
+        {
+            proprio->setArme(m_armeAssignee);
+        }
+    }
+
+
+}

+ 30 - 30
Bouton.h

@@ -1,30 +1,30 @@
-#ifndef BOUTON_H_INCLUDED
-#define BOUTON_H_INCLUDED
-
-/*Description:
-Permet de creer des icones d'arme cliquables.
-Un clic sur l'une d'entre elles permet le changement d'arme.
-*/
-
-#include <SDL/SDL.h>
-#include "Cliquable.h"
-#include "Joueur.h"
-
-class Bouton : public Cliquable
-{
-    public:
-    Bouton(int x, int y,int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur);
-    ~Bouton();
-    void afficher();//Affiche l'icone et appelle "clic" si le clic gauche vient d'être effectué
-    void clic();//Attribue l'arme associée au joueur proprio si le clic est bien sur l'icone.
-
-    private:
-    SDL_Surface* m_ecran;//Pour les blits
-    SDL_Surface* imageIcone;
-    SDL_Rect m_positionIcone;
-    Joueur* proprio;
-    //Limite autre héritage
-    std::string m_armeAssignee;
-};
-
-#endif // BOUTON_H_INCLUDED
+#ifndef BOUTON_H_INCLUDED
+#define BOUTON_H_INCLUDED
+
+/*Description:
+Permet de creer des icones d'arme cliquables.
+Un clic sur l'une d'entre elles permet le changement d'arme.
+*/
+
+#include <SDL/SDL.h>
+#include "Cliquable.h"
+#include "Joueur.h"
+
+class Bouton : public Cliquable
+{
+    public:
+    Bouton(int x, int y,int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur);
+    ~Bouton();
+    void afficher();//Affiche l'icone et appelle "clic" si le clic gauche vient d'être effectué
+    void clic();//Attribue l'arme associée au joueur proprio si le clic est bien sur l'icone.
+
+    private:
+    SDL_Surface* m_ecran;//Pour les blits
+    SDL_Surface* imageIcone;
+    SDL_Rect m_positionIcone;
+    Joueur* proprio;
+    //Limite autre héritage
+    std::string m_armeAssignee;
+};
+
+#endif // BOUTON_H_INCLUDED

+ 46 - 46
ChampDeBataille.cpp

@@ -1,46 +1,46 @@
-#include "ChampDeBataille.h"
-
-
-ChampDeBataille::ChampDeBataille(Joueur* cible,SDL_Surface* ecran,int niveauDeDifficulte):m_niveauDeDifficulte(niveauDeDifficulte),m_ecran(ecran)
-{
-    for (int i(0);i<30;i++)
-    {
-        m_slotsHelico[i]=0;//Pour la sécurité des pointeurs
-    }
-    for (int i(0);i<10+optionsFire::difficulte*10;i++)
-    {
-        m_slotsHelico[i]= new Helico(ecran,10,i);
-    }
-    m_bossOne= new BossOne(ecran,cible);
-    m_cible=cible;
-}
-
-ChampDeBataille::~ChampDeBataille()
-{
-    for (int i(0);i<10+optionsFire::difficulte*10;i++)
-    {
-        delete(m_slotsHelico[i]);
-    }
-    delete (m_bossOne);
-}
-
-void ChampDeBataille::afficher()
-{
-    int nbVivant(0);
-    for (int i(0);i<10+optionsFire::difficulte*10;i++)
-    {
-        if (m_slotsHelico[i]->estVivant())
-        {
-            m_slotsHelico[i]->afficher();
-            nbVivant++;
-        }
-    }
-    if ((nbVivant!=0 )&&( !takeRand(70-2*nbVivant,SDL_GetTicks())))
-    {
-        m_cible->recevoirDegats(1+optionsFire::difficulte);
-    }
-    if (!nbVivant && m_bossOne->estVivant())
-    {
-        m_bossOne->afficher();
-    }
-}
+#include "ChampDeBataille.h"
+
+
+ChampDeBataille::ChampDeBataille(Joueur* cible,SDL_Surface* ecran,int niveauDeDifficulte):m_niveauDeDifficulte(niveauDeDifficulte),m_ecran(ecran)
+{
+    for (int i(0);i<30;i++)
+    {
+        m_slotsHelico[i]=0;//Pour la sécurité des pointeurs
+    }
+    for (int i(0);i<10+optionsFire::difficulte*10;i++)
+    {
+        m_slotsHelico[i]= new Helico(ecran,10,i);
+    }
+    m_bossOne= new BossOne(ecran,cible);
+    m_cible=cible;
+}
+
+ChampDeBataille::~ChampDeBataille()
+{
+    for (int i(0);i<10+optionsFire::difficulte*10;i++)
+    {
+        delete(m_slotsHelico[i]);
+    }
+    delete (m_bossOne);
+}
+
+void ChampDeBataille::afficher()
+{
+    int nbVivant(0);
+    for (int i(0);i<10+optionsFire::difficulte*10;i++)
+    {
+        if (m_slotsHelico[i]->estVivant())
+        {
+            m_slotsHelico[i]->afficher();
+            nbVivant++;
+        }
+    }
+    if ((nbVivant!=0 )&&( !takeRand(70-2*nbVivant,SDL_GetTicks())))
+    {
+        m_cible->recevoirDegats(1+optionsFire::difficulte);
+    }
+    if (!nbVivant && m_bossOne->estVivant())
+    {
+        m_bossOne->afficher();
+    }
+}

+ 31 - 31
ChampDeBataille.h

@@ -1,31 +1,31 @@
-#ifndef CHAMPDEBATAILLE_H_INCLUDED
-#define CHAMPDEBATAILLE_H_INCLUDED
-
-/*Description:
-Le champ de bataille contient et gère tous les ennemis
-présents.
-*/
-
-#include <iostream>
-#include <SDL/SDL.h>
-#include "Helico.h"
-#include "Joueur.h"
-#include "takeRand.h"
-#include "menuFire.h"
-
-class ChampDeBataille
-{
-    public:
-    ChampDeBataille(Joueur* cible,SDL_Surface* ecran,int niveauDeDifficulte);
-    ~ChampDeBataille();
-    void afficher();
-
-    private:
-    SDL_Surface* m_ecran;
-    Joueur* m_cible;
-    int m_niveauDeDifficulte;
-    Helico* m_slotsHelico[30];
-    BossOne* m_bossOne;
-};
-
-#endif // CHAMPDEBATAILLE_H_INCLUDED
+#ifndef CHAMPDEBATAILLE_H_INCLUDED
+#define CHAMPDEBATAILLE_H_INCLUDED
+
+/*Description:
+Le champ de bataille contient et gère tous les ennemis
+présents.
+*/
+
+#include <iostream>
+#include <SDL/SDL.h>
+#include "Helico.h"
+#include "Joueur.h"
+#include "takeRand.h"
+#include "menuFire.h"
+
+class ChampDeBataille
+{
+    public:
+    ChampDeBataille(Joueur* cible,SDL_Surface* ecran,int niveauDeDifficulte);
+    ~ChampDeBataille();
+    void afficher();
+
+    private:
+    SDL_Surface* m_ecran;
+    Joueur* m_cible;
+    int m_niveauDeDifficulte;
+    Helico* m_slotsHelico[30];
+    BossOne* m_bossOne;
+};
+
+#endif // CHAMPDEBATAILLE_H_INCLUDED

+ 20 - 20
Cliquable.cpp

@@ -1,20 +1,20 @@
-#include "Cliquable.h"
-
-
-int Cliquable::m_tempsFire = 0;//Attribution des attributs statiques
-int Cliquable::m_xFire = 0;
-int Cliquable::m_yFire = 0;
-int Cliquable::m_typeFire = 0;
-
-void Cliquable::getFire(int x,int y,unsigned int typeTir)
-{
-    Cliquable::m_xFire=x;
-    Cliquable::m_yFire=y;
-    Cliquable::m_tempsFire=0;
-    Cliquable::m_typeFire=typeTir;
-}
-
-void Cliquable::upFire()
-{
-    Cliquable::m_tempsFire++;
-}
+#include "Cliquable.h"
+
+
+int Cliquable::m_tempsFire = 0;//Attribution des attributs statiques
+int Cliquable::m_xFire = 0;
+int Cliquable::m_yFire = 0;
+int Cliquable::m_typeFire = 0;
+
+void Cliquable::getFire(int x,int y,unsigned int typeTir)
+{
+    Cliquable::m_xFire=x;
+    Cliquable::m_yFire=y;
+    Cliquable::m_tempsFire=0;
+    Cliquable::m_typeFire=typeTir;
+}
+
+void Cliquable::upFire()
+{
+    Cliquable::m_tempsFire++;
+}

+ 25 - 25
Cliquable.h

@@ -1,25 +1,25 @@
-#ifndef CLIQUABLE_H_INCLUDED
-#define CLIQUABLE_H_INCLUDED
-
-/*Description:
-Permet de créer des objets cliquables avec le clic gauche.
-*/
-
-#include <iostream>
-#include <SDL/SDL.h>
-
-
-class Cliquable
-{
-    public:
-    static void getFire(int x,int y,unsigned int typeTir);//Met à jour le dernier tir effectué
-    static void upFire();//Rajoute un temps depuis le dernier tir
-
-    protected:
-    static int m_xFire;//Contient la coordonnée x d'un tir
-    static int m_yFire;//Contient la coordonnée y d'un tir
-    static int m_tempsFire;//Contient le nb de boucles depuis le dernier tir (0=en cours; 5=il y a 5 boucles)
-    static int m_typeFire;//Contient le type de l'arme qui a tiré
-};
-
-#endif // CLIQUABLE_H_INCLUDED
+#ifndef CLIQUABLE_H_INCLUDED
+#define CLIQUABLE_H_INCLUDED
+
+/*Description:
+Permet de créer des objets cliquables avec le clic gauche.
+*/
+
+#include <iostream>
+#include <SDL/SDL.h>
+
+
+class Cliquable
+{
+    public:
+    static void getFire(int x,int y,unsigned int typeTir);//Met à jour le dernier tir effectué
+    static void upFire();//Rajoute un temps depuis le dernier tir
+
+    protected:
+    static int m_xFire;//Contient la coordonnée x d'un tir
+    static int m_yFire;//Contient la coordonnée y d'un tir
+    static int m_tempsFire;//Contient le nb de boucles depuis le dernier tir (0=en cours; 5=il y a 5 boucles)
+    static int m_typeFire;//Contient le type de l'arme qui a tiré
+};
+
+#endif // CLIQUABLE_H_INCLUDED

+ 39 - 39
Ennemy.cpp

@@ -1,39 +1,39 @@
-#include "Ennemy.h"
-
-Ennemy::Ennemy(Joueur* cible,SDL_Surface* ecran) : m_vie(6)
-{
-    m_ecran=ecran;
-    m_cible=cible;
-}
-
-Ennemy::Ennemy(Joueur* cible,SDL_Surface* ecran,int vie) : m_vie(vie)
-{
-    m_ecran=ecran;
-    m_cible=cible;
-}
-
-void Ennemy::recevoirDegats(int degats)
-{
-    m_vie-=degats;
-    if (m_vie<0)
-    {
-        m_vie=0;
-    }
-}
-
-void Ennemy::ressuciter()
-{
-    m_vie=60;
-}
-
-bool Ennemy::estVivant()
-{
-    if (m_vie==0)
-    {
-        return false;
-    }
-    else
-    {
-        return true;
-    }
-}
+#include "Ennemy.h"
+
+Ennemy::Ennemy(Joueur* cible,SDL_Surface* ecran) : m_vie(6)
+{
+    m_ecran=ecran;
+    m_cible=cible;
+}
+
+Ennemy::Ennemy(Joueur* cible,SDL_Surface* ecran,int vie) : m_vie(vie)
+{
+    m_ecran=ecran;
+    m_cible=cible;
+}
+
+void Ennemy::recevoirDegats(int degats)
+{
+    m_vie-=degats;
+    if (m_vie<0)
+    {
+        m_vie=0;
+    }
+}
+
+void Ennemy::ressuciter()
+{
+    m_vie=60;
+}
+
+bool Ennemy::estVivant()
+{
+    if (m_vie==0)
+    {
+        return false;
+    }
+    else
+    {
+        return true;
+    }
+}

+ 29 - 29
Ennemy.h

@@ -1,29 +1,29 @@
-#ifndef ENNEMY_H_INCLUDED
-#define ENNEMY_H_INCLUDED
-
-/*Description:
-Classe abstraite, la classe ennemi est héritée par
-tous les ennemis qui peuvent mourir et touchés par le joueur.
-*/
-
-#include <SDL/SDL.h>
-#include <iostream>
-#include "Cliquable.h"
-#include "Joueur.h"
-
-class Ennemy : public Cliquable
-{
-    public:
-    Ennemy(Joueur* cible,SDL_Surface* ecran);
-    Ennemy(Joueur* cible,SDL_Surface* ecran,int vie);
-    void recevoirDegats(int degats);
-    void ressuciter();
-    bool estVivant();
-
-    protected:
-    int m_vie;
-    SDL_Surface* m_ecran;
-    Joueur* m_cible;
-};
-
-#endif // ENNEMY_H_INCLUDED
+#ifndef ENNEMY_H_INCLUDED
+#define ENNEMY_H_INCLUDED
+
+/*Description:
+Classe abstraite, la classe ennemi est héritée par
+tous les ennemis qui peuvent mourir et touchés par le joueur.
+*/
+
+#include <SDL/SDL.h>
+#include <iostream>
+#include "Cliquable.h"
+#include "Joueur.h"
+
+class Ennemy : public Cliquable
+{
+    public:
+    Ennemy(Joueur* cible,SDL_Surface* ecran);
+    Ennemy(Joueur* cible,SDL_Surface* ecran,int vie);
+    void recevoirDegats(int degats);
+    void ressuciter();
+    bool estVivant();
+
+    protected:
+    int m_vie;
+    SDL_Surface* m_ecran;
+    Joueur* m_cible;
+};
+
+#endif // ENNEMY_H_INCLUDED

+ 142 - 142
Helico.cpp

@@ -1,142 +1,142 @@
-#include "Helico.h"
-
-Helico::Helico(SDL_Surface* ecran) : Ennemy(0,ecran),m_vitesse(5+takeRand(5))
-{
-    m_helico = SDL_LoadBMP("Images/Helicopter.bmp");
-    SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
-    m_positionHelico.x=takeRand(620);
-    m_positionHelico.y=40+takeRand(350);
-}
-
-Helico::Helico(SDL_Surface* ecran,int vie) : Ennemy(0,ecran,vie),m_vitesse(5+takeRand(5))
-{
-    m_helico=SDL_LoadBMP("Images/Helicopter.bmp");
-    SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
-}
-
-Helico::Helico(SDL_Surface* ecran, int vie, int antiLatence) : Ennemy(0,ecran,vie),m_vitesse(5+takeRand(5,antiLatence))
-{
-    m_helico = SDL_LoadBMP("Images/Helicopter.bmp");
-    SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
-    m_positionHelico.x=takeRand(620,antiLatence);
-    m_positionHelico.y=40+takeRand(350,antiLatence);
-}
-
-Helico::~Helico()
-{
-    SDL_FreeSurface(m_helico);
-}
-
-void Helico::afficher()
-{
-    if (m_positionHelico.x<640)
-    {
-        m_positionHelico.x=m_positionHelico.x+=m_vitesse;
-    }
-    else
-    {
-        m_positionHelico.x=0;
-    }
-    SDL_BlitSurface(m_helico,NULL,m_ecran,&m_positionHelico);
-
-    if (m_tempsFire==0)
-    {
-        if (m_positionHelico.x+64>m_xFire&&m_xFire>m_positionHelico.x && m_positionHelico.y+32>m_yFire&&m_yFire>m_positionHelico.y)
-        {
-            switch(m_typeFire)
-            {
-                case 0:
-                    this->recevoirDegats(11);
-                    break;
-                case 1:
-                    this->recevoirDegats(5);
-                    break;
-                case 2:
-                    this->recevoirDegats(3);
-                    break;
-            }//Switch
-        }//Verification position
-    }//Si tir
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-BossOne::BossOne(SDL_Surface* ecran,Joueur* cible) : Ennemy(cible,ecran,100)
-{
-    m_bossOne=SDL_LoadBMP("Images/HelicopterBossUn.bmp");
-    m_tir=SDL_LoadBMP("Images/HelicopterBossUnTir.bmp");
-    SDL_SetColorKey(m_bossOne,SDL_SRCCOLORKEY,SDL_MapRGB(m_bossOne->format,255,255,255));
-    SDL_SetColorKey(m_tir,SDL_SRCCOLORKEY,SDL_MapRGB(m_tir->format,255,255,255));
-    m_positionBoss.x=100;
-    m_positionBoss.y=50;
-    m_vaVersLeBas=true;
-    m_vaVersLaDroite=true;
-    m_armeCycle=100;
-}
-
-BossOne::~BossOne()
-{
-    SDL_FreeSurface(m_bossOne);
-}
-
-void BossOne::afficher()
-{
-    //Deplacement
-    if (m_vaVersLeBas)
-    {
-        m_positionBoss.y++;
-        if (m_positionBoss.y>324)//480-76-80
-        {
-            m_vaVersLeBas=false;
-        }
-    }
-    else
-    {
-        m_positionBoss.y--;
-        if (m_positionBoss.y<0)
-        {
-            m_vaVersLeBas=true;
-        }
-    }
-    if (m_vaVersLaDroite)
-    {
-        m_positionBoss.x++;
-        if (m_positionBoss.x>512)
-        {
-            m_vaVersLaDroite=false;
-        }
-    }
-    else
-    {
-        m_positionBoss.x--;
-        if (m_positionBoss.x<0)
-        {
-            m_vaVersLaDroite=true;
-        }
-    }
-    //Collage
-    SDL_BlitSurface(m_bossOne,NULL,m_ecran,&m_positionBoss);
-    //Gestion des tirs du joueur
-    if (m_tempsFire==0)
-    {
-        if (m_positionBoss.x+128>m_xFire&&m_xFire>m_positionBoss.x && m_positionBoss.y+80>m_yFire&&m_yFire>m_positionBoss.y)
-        {
-            this->recevoirDegats(10);
-        }
-    }
-    //Gestion des tirs d'helico
-    if (!takeRand(50,m_armeCycle))
-    {
-        m_armeCycle=0;
-        m_cible->recevoirDegats(1);
-    }
-    if (m_armeCycle<5)
-    {
-        SDL_Rect positionTir;
-        positionTir.x=m_positionBoss.x+m_bossOne->w/2-m_tir->w/2;
-        positionTir.y=m_positionBoss.y+m_bossOne->h/2-m_tir->h/2;
-        SDL_BlitSurface(m_tir,NULL,m_ecran,&positionTir);
-    }
-    m_armeCycle++;
-}
-
+#include "Helico.h"
+
+Helico::Helico(SDL_Surface* ecran) : Ennemy(0,ecran),m_vitesse(5+takeRand(5))
+{
+    m_helico = SDL_LoadBMP("Images/Helicopter.bmp");
+    SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
+    m_positionHelico.x=takeRand(620);
+    m_positionHelico.y=40+takeRand(350);
+}
+
+Helico::Helico(SDL_Surface* ecran,int vie) : Ennemy(0,ecran,vie),m_vitesse(5+takeRand(5))
+{
+    m_helico=SDL_LoadBMP("Images/Helicopter.bmp");
+    SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
+}
+
+Helico::Helico(SDL_Surface* ecran, int vie, int antiLatence) : Ennemy(0,ecran,vie),m_vitesse(5+takeRand(5,antiLatence))
+{
+    m_helico = SDL_LoadBMP("Images/Helicopter.bmp");
+    SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
+    m_positionHelico.x=takeRand(620,antiLatence);
+    m_positionHelico.y=40+takeRand(350,antiLatence);
+}
+
+Helico::~Helico()
+{
+    SDL_FreeSurface(m_helico);
+}
+
+void Helico::afficher()
+{
+    if (m_positionHelico.x<640)
+    {
+        m_positionHelico.x=m_positionHelico.x+=m_vitesse;
+    }
+    else
+    {
+        m_positionHelico.x=0;
+    }
+    SDL_BlitSurface(m_helico,NULL,m_ecran,&m_positionHelico);
+
+    if (m_tempsFire==0)
+    {
+        if (m_positionHelico.x+64>m_xFire&&m_xFire>m_positionHelico.x && m_positionHelico.y+32>m_yFire&&m_yFire>m_positionHelico.y)
+        {
+            switch(m_typeFire)
+            {
+                case 0:
+                    this->recevoirDegats(11);
+                    break;
+                case 1:
+                    this->recevoirDegats(5);
+                    break;
+                case 2:
+                    this->recevoirDegats(3);
+                    break;
+            }//Switch
+        }//Verification position
+    }//Si tir
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+BossOne::BossOne(SDL_Surface* ecran,Joueur* cible) : Ennemy(cible,ecran,100)
+{
+    m_bossOne=SDL_LoadBMP("Images/HelicopterBossUn.bmp");
+    m_tir=SDL_LoadBMP("Images/HelicopterBossUnTir.bmp");
+    SDL_SetColorKey(m_bossOne,SDL_SRCCOLORKEY,SDL_MapRGB(m_bossOne->format,255,255,255));
+    SDL_SetColorKey(m_tir,SDL_SRCCOLORKEY,SDL_MapRGB(m_tir->format,255,255,255));
+    m_positionBoss.x=100;
+    m_positionBoss.y=50;
+    m_vaVersLeBas=true;
+    m_vaVersLaDroite=true;
+    m_armeCycle=100;
+}
+
+BossOne::~BossOne()
+{
+    SDL_FreeSurface(m_bossOne);
+}
+
+void BossOne::afficher()
+{
+    //Deplacement
+    if (m_vaVersLeBas)
+    {
+        m_positionBoss.y++;
+        if (m_positionBoss.y>324)//480-76-80
+        {
+            m_vaVersLeBas=false;
+        }
+    }
+    else
+    {
+        m_positionBoss.y--;
+        if (m_positionBoss.y<0)
+        {
+            m_vaVersLeBas=true;
+        }
+    }
+    if (m_vaVersLaDroite)
+    {
+        m_positionBoss.x++;
+        if (m_positionBoss.x>512)
+        {
+            m_vaVersLaDroite=false;
+        }
+    }
+    else
+    {
+        m_positionBoss.x--;
+        if (m_positionBoss.x<0)
+        {
+            m_vaVersLaDroite=true;
+        }
+    }
+    //Collage
+    SDL_BlitSurface(m_bossOne,NULL,m_ecran,&m_positionBoss);
+    //Gestion des tirs du joueur
+    if (m_tempsFire==0)
+    {
+        if (m_positionBoss.x+128>m_xFire&&m_xFire>m_positionBoss.x && m_positionBoss.y+80>m_yFire&&m_yFire>m_positionBoss.y)
+        {
+            this->recevoirDegats(10);
+        }
+    }
+    //Gestion des tirs d'helico
+    if (!takeRand(50,m_armeCycle))
+    {
+        m_armeCycle=0;
+        m_cible->recevoirDegats(1);
+    }
+    if (m_armeCycle<5)
+    {
+        SDL_Rect positionTir;
+        positionTir.x=m_positionBoss.x+m_bossOne->w/2-m_tir->w/2;
+        positionTir.y=m_positionBoss.y+m_bossOne->h/2-m_tir->h/2;
+        SDL_BlitSurface(m_tir,NULL,m_ecran,&positionTir);
+    }
+    m_armeCycle++;
+}
+

+ 44 - 44
Helico.h

@@ -1,44 +1,44 @@
-#ifndef HELICO_H_INCLUDED
-#define HELICO_H_INCLUDED
-
-/*Description:
-Ennemi standard: un petit helicopter qui se deplace à l'horizontal.
-*/
-
-#include <iostream>
-#include <SDL/SDL.h>
-#include "Ennemy.h"
-#include "takeRand.h"
-
-class Helico : public Ennemy
-{
-    public:
-    Helico(SDL_Surface* ecran);//Constructeur standard
-    Helico(SDL_Surface* ecran,int vie);//Constructeur vital
-    Helico(SDL_Surface* ecran,int vie,int antiLatence);//Constructeur de chaîne
-    ~Helico();
-    void afficher();
-
-    private:
-    SDL_Surface* m_helico;
-    SDL_Rect m_positionHelico;
-    int m_vitesse;
-};
-
-class BossOne : public Ennemy
-{
-    public:
-    BossOne(SDL_Surface* ecran,Joueur* cible);
-    ~BossOne();
-    void afficher();
-
-    private:
-    SDL_Surface* m_bossOne;
-    SDL_Surface* m_tir;
-    SDL_Rect m_positionBoss;
-    bool m_vaVersLeBas;
-    bool m_vaVersLaDroite;
-    int m_armeCycle;
-};
-
-#endif // HELICO_H_INCLUDED
+#ifndef HELICO_H_INCLUDED
+#define HELICO_H_INCLUDED
+
+/*Description:
+Ennemi standard: un petit helicopter qui se deplace à l'horizontal.
+*/
+
+#include <iostream>
+#include <SDL/SDL.h>
+#include "Ennemy.h"
+#include "takeRand.h"
+
+class Helico : public Ennemy
+{
+    public:
+    Helico(SDL_Surface* ecran);//Constructeur standard
+    Helico(SDL_Surface* ecran,int vie);//Constructeur vital
+    Helico(SDL_Surface* ecran,int vie,int antiLatence);//Constructeur de chaîne
+    ~Helico();
+    void afficher();
+
+    private:
+    SDL_Surface* m_helico;
+    SDL_Rect m_positionHelico;
+    int m_vitesse;
+};
+
+class BossOne : public Ennemy
+{
+    public:
+    BossOne(SDL_Surface* ecran,Joueur* cible);
+    ~BossOne();
+    void afficher();
+
+    private:
+    SDL_Surface* m_bossOne;
+    SDL_Surface* m_tir;
+    SDL_Rect m_positionBoss;
+    bool m_vaVersLeBas;
+    bool m_vaVersLaDroite;
+    int m_armeCycle;
+};
+
+#endif // HELICO_H_INCLUDED

+ 45 - 45
Icones.cpp

@@ -1,45 +1,45 @@
-#include "Icones.h"
-
-Icones::Icones(int x, int y, int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur) : m_ecran(ecran),proprio(lanceur),m_armeAssignee(armeAssignee)
-{
-    m_positionIcone.x=x;
-    m_positionIcone.y=y;
-    switch (choixArme)
-    {
-        case 0:
-            imageIcone=SDL_LoadBMP("IconeBaroudeur.bmp");
-            break;
-        case 1:
-            imageIcone=SDL_LoadBMP("IconeUsiane.bmp");
-            break;
-        case 2:
-            imageIcone=SDL_LoadBMP("IconeTriphaseur.bmp");
-            break;
-    }
-
-}
-Icones::~Icones()
-{
-    SDL_FreeSurface(imageIcone);
-}
-
-void Icones::afficher()
-{
-    if (Cliquable::m_tempsFire==0)
-    {
-        this->clic();
-    }
-    SDL_BlitSurface(imageIcone,0,m_ecran,&m_positionIcone);
-}
-
-void Icones::clic()
-{
-    /*Teste si le click est sur l'icone, puis fait l'assignation de l'arme.*/
-    if (Cliquable::m_yFire>m_positionIcone.y&&Cliquable::m_yFire<(m_positionIcone.y+m_positionIcone.h))
-    {
-        if (Cliquable::m_xFire>m_positionIcone.x&&Cliquable::m_xFire<(m_positionIcone.x+m_positionIcone.w))
-        {
-            proprio->setArme(m_armeAssignee);
-        }
-    }
-}
+#include "Icones.h"
+
+Icones::Icones(int x, int y, int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur) : m_ecran(ecran),proprio(lanceur),m_armeAssignee(armeAssignee)
+{
+    m_positionIcone.x=x;
+    m_positionIcone.y=y;
+    switch (choixArme)
+    {
+        case 0:
+            imageIcone=SDL_LoadBMP("IconeBaroudeur.bmp");
+            break;
+        case 1:
+            imageIcone=SDL_LoadBMP("IconeUsiane.bmp");
+            break;
+        case 2:
+            imageIcone=SDL_LoadBMP("IconeTriphaseur.bmp");
+            break;
+    }
+
+}
+Icones::~Icones()
+{
+    SDL_FreeSurface(imageIcone);
+}
+
+void Icones::afficher()
+{
+    if (Cliquable::m_tempsFire==0)
+    {
+        this->clic();
+    }
+    SDL_BlitSurface(imageIcone,0,m_ecran,&m_positionIcone);
+}
+
+void Icones::clic()
+{
+    /*Teste si le click est sur l'icone, puis fait l'assignation de l'arme.*/
+    if (Cliquable::m_yFire>m_positionIcone.y&&Cliquable::m_yFire<(m_positionIcone.y+m_positionIcone.h))
+    {
+        if (Cliquable::m_xFire>m_positionIcone.x&&Cliquable::m_xFire<(m_positionIcone.x+m_positionIcone.w))
+        {
+            proprio->setArme(m_armeAssignee);
+        }
+    }
+}

+ 32 - 32
Icones.h

@@ -1,32 +1,32 @@
-#ifndef ICONES_H_INCLUDED
-#define ICONES_H_INCLUDED
-
-/*Description:
-Permet de créer des icones cliquables.
-*/
-
-#include <iostream>
-#include <string>
-#include <SDL/SDL.h>
-#include "Cliquable.h"
-#include "Joueur.h"//Include pour utiliser l'objet Joueur
-
-class Icones : public Cliquable
-{
-    public:
-    Icones(int x, int y,int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur);
-    ~Icones();
-    void afficher();//Affiche l'icone et appelle "clic" si le clic gauche vient d'être effectué
-    void clic();//Attribue l'arme associée au joueur proprio si le clic est bien sur l'icone.
-
-    private:
-    SDL_Surface* m_ecran;//Pour les blits
-    SDL_Surface* imageIcone;
-    SDL_Rect m_positionIcone;
-    Joueur* proprio;
-    //Limite autre héritage
-    std::string m_armeAssignee;
-};
-
-
-#endif // ICONES_H_INCLUDED
+#ifndef ICONES_H_INCLUDED
+#define ICONES_H_INCLUDED
+
+/*Description:
+Permet de créer des icones cliquables.
+*/
+
+#include <iostream>
+#include <string>
+#include <SDL/SDL.h>
+#include "Cliquable.h"
+#include "Joueur.h"//Include pour utiliser l'objet Joueur
+
+class Icones : public Cliquable
+{
+    public:
+    Icones(int x, int y,int choixArme,std::string armeAssignee, SDL_Surface* ecran, Joueur* lanceur);
+    ~Icones();
+    void afficher();//Affiche l'icone et appelle "clic" si le clic gauche vient d'être effectué
+    void clic();//Attribue l'arme associée au joueur proprio si le clic est bien sur l'icone.
+
+    private:
+    SDL_Surface* m_ecran;//Pour les blits
+    SDL_Surface* imageIcone;
+    SDL_Rect m_positionIcone;
+    Joueur* proprio;
+    //Limite autre héritage
+    std::string m_armeAssignee;
+};
+
+
+#endif // ICONES_H_INCLUDED

+ 201 - 201
Joueur.cpp

@@ -1,201 +1,201 @@
-#include "Joueur.h"
-
-Arme::Arme(SDL_Surface* ecran,unsigned int IDarme,int xCalibreExpl,int yCalibreExpl, int recul) : m_ecran(ecran),m_xCalibreExpl(xCalibreExpl),m_yCalibreExpl(yCalibreExpl),m_IDarme(IDarme),m_recul(recul)
-{//Constructeur
-
-	if (IDarme==0)
-	{
-		//Assignation necessaire au baroudeur
-		m_viseur=SDL_LoadBMP("Images/ViseurBaroudeur.bmp");
-		m_arme=SDL_LoadBMP("Images/Baroudeur.bmp");
-		m_tir=SDL_LoadBMP("Images/TirBaroudeur.bmp");
-		m_impact=SDL_LoadBMP("Images/ImpactBaroudeur.bmp");
-		m_munitionsRestantes=10;
-	}
-	else if (IDarme==1)
-	{
-		//Assignation necessaire à l'Usiane
-		m_viseur=SDL_LoadBMP("Images/ViseurUsiane.bmp");
-		m_arme=SDL_LoadBMP("Images/Usiane.bmp");
-		m_tir=SDL_LoadBMP("Images/TirUsiane.bmp");
-		m_impact=SDL_LoadBMP("Images/ImpactUsiane.bmp");
-		m_munitionsRestantes=25;
-	}
-	else
-	{
-		//Assignation néecessaire au triphaseur
-		m_viseur=SDL_LoadBMP("Images/ViseurTriphaseur.bmp");
-		m_arme=SDL_LoadBMP("Images/Triphaseur.bmp");
-		m_tir=SDL_LoadBMP("Images/TirTriphaseur.bmp");
-		m_impact=SDL_LoadBMP("Images/ImpactTriphaseur.bmp");
-		m_munitionsRestantes=125;
-	}
-}
-
-Arme::~Arme()
-{
-	SDL_FreeSurface(m_viseur);
-	SDL_FreeSurface(m_arme);
-	SDL_FreeSurface(m_tir);
-	SDL_FreeSurface(m_impact);
-}
-
-void Arme::afficher(bool tir, SDL_Rect* positionViseur)//Test du tir pris en charge par le joueur proprio
-{
-    //Traitement transparence
-    SDL_SetColorKey(m_viseur,SDL_SRCCOLORKEY,SDL_MapRGB(m_viseur->format,255,255,255));//On met le fond (blanc) en invisible !
-    SDL_SetColorKey(m_tir,SDL_SRCCOLORKEY,SDL_MapRGB(m_tir->format,255,255,255));
-    SDL_SetColorKey(m_impact,SDL_SRCCOLORKEY,SDL_MapRGB(m_impact->format,255,255,255));
-    SDL_SetColorKey(m_arme,SDL_SRCCOLORKEY,SDL_MapRGB(m_arme->format,255,255,255));
-    SDL_SetAlpha(m_viseur,SDL_SRCALPHA,128);//On met le viseur en translucide !
-    SDL_SetAlpha(m_impact,SDL_SRCALPHA,128);
-    //Réglage de position
-    SDL_Rect positionTir;
-    SDL_Rect positionBrasDroit;
-    positionBrasDroit.x=430+((positionViseur->x-positionViseur->x%10)/10);//420
-    positionBrasDroit.y=265+((positionViseur->y-positionViseur->y%20)/20);//260
-	if (tir && m_munitionsRestantes>0)
-	{
-	    //Calculs
-        SDL_Rect positionImpact;
-		positionTir.x=positionBrasDroit.x+m_xCalibreExpl;//Affichage de l'impact
-        positionTir.y=positionBrasDroit.y+m_yCalibreExpl;
-        positionBrasDroit.x=positionBrasDroit.x+m_recul;//Recul
-        positionBrasDroit.y=positionBrasDroit.y+m_recul;
-        positionImpact.x=positionViseur->x+16;//Centre sur le viseur
-        positionImpact.y=positionViseur->y+16;
-        //Affichage de tir
-        SDL_BlitSurface(m_impact,0,m_ecran,&positionImpact);
-        SDL_BlitSurface(m_tir,0,m_ecran,&positionTir);//Collage tir
-	}
-    //Affichage défaut
-    SDL_BlitSurface(m_arme,0,m_ecran,&positionBrasDroit);
-    SDL_BlitSurface(m_viseur,0,m_ecran,positionViseur);
-}
-
-void Arme::tir()
-{
-    //Retrait de muntion
-    m_munitionsRestantes--;
-}
-
-unsigned int Arme::getTypeWeapon()
-{
-    return m_IDarme;
-}
-
-/*void Arme::recharger
-{
-	//Pleins de trucs interessants...
-}*/
-
-
-////////////////////////////////////////////////////////////
-///////////////////////Changement de def////////////////////
-////////////////////////////////////////////////////////////
-
-
-Joueur::Joueur(SDL_Surface* ecran):m_ecran(ecran),m_armeCycle(0),m_tirInstant(false)
-{
-    m_armeOne=new Arme(ecran,0,80,85,5);
-    m_armeTwo=new Arme(ecran,1,50,60,2);
-    m_armeThree=new Arme(ecran,2,70,60,0);
-
-    m_interVie=SDL_LoadBMP("Images/InterVie.bmp");
-    m_positionInterVie.x=420;
-    m_positionInterVie.y=403;
-    for (int i(0);i<60;i++)
-    {
-        m_jaugeVie[i]=SDL_CreateRGBSurface(SDL_HWSURFACE,29,1,32,0,0,0,0);
-        SDL_FillRect(m_jaugeVie[i],NULL,SDL_MapRGB(m_ecran->format,255,255-2*i,0));
-    }
-    m_variableVie=60;
-}
-
-Joueur::~Joueur()//Destructeur
-{
-    delete(m_armeOne);
-    delete(m_armeTwo);
-    delete(m_armeThree);
-    SDL_FreeSurface(m_interVie);
-}
-
-void Joueur::afficher()
-{
-
-    if (m_armeCycle<4)//Si un tir vient d'être effectué
-    {
-        m_tirInstant=true;
-    }
-    else
-    {
-        m_tirInstant=false;
-    }
-    m_armeCycle++;
-    SDL_BlitSurface(m_interVie,0,m_ecran,&m_positionInterVie);
-
-    SDL_Rect positionJaugeVie;
-    positionJaugeVie.x=429;//420+9
-    positionJaugeVie.y=412;//403+9
-    for (int i(0); i<m_variableVie; i++)
-    {
-            positionJaugeVie.y=472-i;//412+60
-            SDL_BlitSurface(m_jaugeVie[i],NULL,m_ecran,&positionJaugeVie);
-    }
-    m_armeSelect->afficher(m_tirInstant,&m_positionViseur);
-}
-
-void Joueur::setArme(std::string choixArme)
-{
-    if (choixArme=="Baroudeur")
-    {
-        m_armeSelect=m_armeOne;
-    }
-    else if (choixArme=="Usiane")
-    {
-        m_armeSelect=m_armeTwo;
-    }
-    else if (choixArme=="Triphaseur")
-    {
-        m_armeSelect=m_armeThree;
-    }
-}
-
-void Joueur::giveMousePosition(int x, int y)
-{
-    m_positionViseur.x=x-32;
-    m_positionViseur.y=y-32;
-}
-
-void Joueur::tir()
-{
-    m_armeCycle=0;
-    m_armeSelect->tir();
-}
-
-void Joueur::recevoirDegats(int degats)
-{
-    m_variableVie=m_variableVie-degats;
-    if (m_variableVie<0)
-    {
-        m_variableVie=0;
-    }
-}
-
-bool Joueur::estVivant()
-{
-    if (m_variableVie>0)
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-unsigned int Joueur::getTypeWeapon()
-{
-    return m_armeSelect->getTypeWeapon();
-}
-
+#include "Joueur.h"
+
+Arme::Arme(SDL_Surface* ecran,unsigned int IDarme,int xCalibreExpl,int yCalibreExpl, int recul) : m_ecran(ecran),m_xCalibreExpl(xCalibreExpl),m_yCalibreExpl(yCalibreExpl),m_IDarme(IDarme),m_recul(recul)
+{//Constructeur
+
+	if (IDarme==0)
+	{
+		//Assignation necessaire au baroudeur
+		m_viseur=SDL_LoadBMP("Images/ViseurBaroudeur.bmp");
+		m_arme=SDL_LoadBMP("Images/Baroudeur.bmp");
+		m_tir=SDL_LoadBMP("Images/TirBaroudeur.bmp");
+		m_impact=SDL_LoadBMP("Images/ImpactBaroudeur.bmp");
+		m_munitionsRestantes=10;
+	}
+	else if (IDarme==1)
+	{
+		//Assignation necessaire à l'Usiane
+		m_viseur=SDL_LoadBMP("Images/ViseurUsiane.bmp");
+		m_arme=SDL_LoadBMP("Images/Usiane.bmp");
+		m_tir=SDL_LoadBMP("Images/TirUsiane.bmp");
+		m_impact=SDL_LoadBMP("Images/ImpactUsiane.bmp");
+		m_munitionsRestantes=25;
+	}
+	else
+	{
+		//Assignation néecessaire au triphaseur
+		m_viseur=SDL_LoadBMP("Images/ViseurTriphaseur.bmp");
+		m_arme=SDL_LoadBMP("Images/Triphaseur.bmp");
+		m_tir=SDL_LoadBMP("Images/TirTriphaseur.bmp");
+		m_impact=SDL_LoadBMP("Images/ImpactTriphaseur.bmp");
+		m_munitionsRestantes=125;
+	}
+}
+
+Arme::~Arme()
+{
+	SDL_FreeSurface(m_viseur);
+	SDL_FreeSurface(m_arme);
+	SDL_FreeSurface(m_tir);
+	SDL_FreeSurface(m_impact);
+}
+
+void Arme::afficher(bool tir, SDL_Rect* positionViseur)//Test du tir pris en charge par le joueur proprio
+{
+    //Traitement transparence
+    SDL_SetColorKey(m_viseur,SDL_SRCCOLORKEY,SDL_MapRGB(m_viseur->format,255,255,255));//On met le fond (blanc) en invisible !
+    SDL_SetColorKey(m_tir,SDL_SRCCOLORKEY,SDL_MapRGB(m_tir->format,255,255,255));
+    SDL_SetColorKey(m_impact,SDL_SRCCOLORKEY,SDL_MapRGB(m_impact->format,255,255,255));
+    SDL_SetColorKey(m_arme,SDL_SRCCOLORKEY,SDL_MapRGB(m_arme->format,255,255,255));
+    SDL_SetAlpha(m_viseur,SDL_SRCALPHA,128);//On met le viseur en translucide !
+    SDL_SetAlpha(m_impact,SDL_SRCALPHA,128);
+    //Réglage de position
+    SDL_Rect positionTir;
+    SDL_Rect positionBrasDroit;
+    positionBrasDroit.x=430+((positionViseur->x-positionViseur->x%10)/10);//420
+    positionBrasDroit.y=265+((positionViseur->y-positionViseur->y%20)/20);//260
+	if (tir && m_munitionsRestantes>0)
+	{
+	    //Calculs
+        SDL_Rect positionImpact;
+		positionTir.x=positionBrasDroit.x+m_xCalibreExpl;//Affichage de l'impact
+        positionTir.y=positionBrasDroit.y+m_yCalibreExpl;
+        positionBrasDroit.x=positionBrasDroit.x+m_recul;//Recul
+        positionBrasDroit.y=positionBrasDroit.y+m_recul;
+        positionImpact.x=positionViseur->x+16;//Centre sur le viseur
+        positionImpact.y=positionViseur->y+16;
+        //Affichage de tir
+        SDL_BlitSurface(m_impact,0,m_ecran,&positionImpact);
+        SDL_BlitSurface(m_tir,0,m_ecran,&positionTir);//Collage tir
+	}
+    //Affichage défaut
+    SDL_BlitSurface(m_arme,0,m_ecran,&positionBrasDroit);
+    SDL_BlitSurface(m_viseur,0,m_ecran,positionViseur);
+}
+
+void Arme::tir()
+{
+    //Retrait de muntion
+    m_munitionsRestantes--;
+}
+
+unsigned int Arme::getTypeWeapon()
+{
+    return m_IDarme;
+}
+
+/*void Arme::recharger
+{
+	//Pleins de trucs interessants...
+}*/
+
+
+////////////////////////////////////////////////////////////
+///////////////////////Changement de def////////////////////
+////////////////////////////////////////////////////////////
+
+
+Joueur::Joueur(SDL_Surface* ecran):m_ecran(ecran),m_armeCycle(0),m_tirInstant(false)
+{
+    m_armeOne=new Arme(ecran,0,80,85,5);
+    m_armeTwo=new Arme(ecran,1,50,60,2);
+    m_armeThree=new Arme(ecran,2,70,60,0);
+
+    m_interVie=SDL_LoadBMP("Images/InterVie.bmp");
+    m_positionInterVie.x=420;
+    m_positionInterVie.y=403;
+    for (int i(0);i<60;i++)
+    {
+        m_jaugeVie[i]=SDL_CreateRGBSurface(SDL_HWSURFACE,29,1,32,0,0,0,0);
+        SDL_FillRect(m_jaugeVie[i],NULL,SDL_MapRGB(m_ecran->format,255,255-2*i,0));
+    }
+    m_variableVie=60;
+}
+
+Joueur::~Joueur()//Destructeur
+{
+    delete(m_armeOne);
+    delete(m_armeTwo);
+    delete(m_armeThree);
+    SDL_FreeSurface(m_interVie);
+}
+
+void Joueur::afficher()
+{
+
+    if (m_armeCycle<4)//Si un tir vient d'être effectué
+    {
+        m_tirInstant=true;
+    }
+    else
+    {
+        m_tirInstant=false;
+    }
+    m_armeCycle++;
+    SDL_BlitSurface(m_interVie,0,m_ecran,&m_positionInterVie);
+
+    SDL_Rect positionJaugeVie;
+    positionJaugeVie.x=429;//420+9
+    positionJaugeVie.y=412;//403+9
+    for (int i(0); i<m_variableVie; i++)
+    {
+            positionJaugeVie.y=472-i;//412+60
+            SDL_BlitSurface(m_jaugeVie[i],NULL,m_ecran,&positionJaugeVie);
+    }
+    m_armeSelect->afficher(m_tirInstant,&m_positionViseur);
+}
+
+void Joueur::setArme(std::string choixArme)
+{
+    if (choixArme=="Baroudeur")
+    {
+        m_armeSelect=m_armeOne;
+    }
+    else if (choixArme=="Usiane")
+    {
+        m_armeSelect=m_armeTwo;
+    }
+    else if (choixArme=="Triphaseur")
+    {
+        m_armeSelect=m_armeThree;
+    }
+}
+
+void Joueur::giveMousePosition(int x, int y)
+{
+    m_positionViseur.x=x-32;
+    m_positionViseur.y=y-32;
+}
+
+void Joueur::tir()
+{
+    m_armeCycle=0;
+    m_armeSelect->tir();
+}
+
+void Joueur::recevoirDegats(int degats)
+{
+    m_variableVie=m_variableVie-degats;
+    if (m_variableVie<0)
+    {
+        m_variableVie=0;
+    }
+}
+
+bool Joueur::estVivant()
+{
+    if (m_variableVie>0)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+unsigned int Joueur::getTypeWeapon()
+{
+    return m_armeSelect->getTypeWeapon();
+}
+

+ 72 - 72
Joueur.h

@@ -1,72 +1,72 @@
-#ifndef ARME_H_INCLUDED
-#define ARME_H_INCLUDED
-
-//Notes temporaires: La gérance du clic d'icone se fera par le joueur.
-/*La classe arme permet de gerer tous
-les attributs de l'arme, y compris le viseur associé.*/
-
-#include <iostream>
-#include <SDL/SDL.h>
-#include "menuFire.h"
-
-class Arme
-{
-	public:
-	Arme(SDL_Surface* ecran,unsigned int IDarme,int xCalibreExpl, int yCalibreExpl, int recul);
-	~Arme();
-	void afficher(bool tir, SDL_Rect* positionViseur);
-	void tir();
-    unsigned int getTypeWeapon();
-	//void recharger();
-
-	protected:
-	SDL_Surface* m_ecran;//Pour blits
-	const int m_IDarme;//Permet d'ajuster la position de l'icone, et determinant facilement l'arme. Note:0=Baroudeur, 1=Usiane, 2=TriPhaseur
-    SDL_Surface* m_arme;//Image de l'arme
-    SDL_Surface* m_viseur;//Image du viseur
-    SDL_Surface* m_tir;//Image de l'explosion lors du tir
-    SDL_Surface* m_impact;//Image de l'impact
-    const int m_recul;
-	const int m_xCalibreExpl;
-	const int m_yCalibreExpl;
-
-    int m_munitionsRestantes;
-	//int m_tempsRecharge const;//Afaire
-	//int m_ResteTempsRecharge;//Afaire
-};
-
-/*Description:
-Permet de creer l'interface du joueur.
-*/
-
-class Joueur
-{
-    public:
-    Joueur(SDL_Surface* ecran);
-    ~Joueur();
-    void afficher();
-    void setArme(std::string choixArme);
-    void giveMousePosition(int x,int y);
-    void tir();
-    void recevoirDegats(int degats);
-    bool estVivant();
-    unsigned int getTypeWeapon();
-
-    protected:
-    //Ecran en attribut pour les blits
-    SDL_Surface* m_ecran;
-    //Nombre de boucles depuis le début du programme
-    int m_armeCycle;
-    int m_variableVie;
-    SDL_Rect m_positionViseur;
-    SDL_Rect m_positionInterVie;
-    SDL_Surface* m_interVie;
-    SDL_Surface* m_jaugeVie[60];
-    bool m_tirInstant;
-    Arme* m_armeSelect;
-    Arme* m_armeOne;
-    Arme* m_armeTwo;
-    Arme* m_armeThree;
-};
-
-#endif // ARME_H_INCLUDED
+#ifndef ARME_H_INCLUDED
+#define ARME_H_INCLUDED
+
+//Notes temporaires: La gérance du clic d'icone se fera par le joueur.
+/*La classe arme permet de gerer tous
+les attributs de l'arme, y compris le viseur associé.*/
+
+#include <iostream>
+#include <SDL/SDL.h>
+#include "menuFire.h"
+
+class Arme
+{
+	public:
+	Arme(SDL_Surface* ecran,unsigned int IDarme,int xCalibreExpl, int yCalibreExpl, int recul);
+	~Arme();
+	void afficher(bool tir, SDL_Rect* positionViseur);
+	void tir();
+    unsigned int getTypeWeapon();
+	//void recharger();
+
+	protected:
+	SDL_Surface* m_ecran;//Pour blits
+	const int m_IDarme;//Permet d'ajuster la position de l'icone, et determinant facilement l'arme. Note:0=Baroudeur, 1=Usiane, 2=TriPhaseur
+    SDL_Surface* m_arme;//Image de l'arme
+    SDL_Surface* m_viseur;//Image du viseur
+    SDL_Surface* m_tir;//Image de l'explosion lors du tir
+    SDL_Surface* m_impact;//Image de l'impact
+    const int m_recul;
+	const int m_xCalibreExpl;
+	const int m_yCalibreExpl;
+
+    int m_munitionsRestantes;
+	//int m_tempsRecharge const;//Afaire
+	//int m_ResteTempsRecharge;//Afaire
+};
+
+/*Description:
+Permet de creer l'interface du joueur.
+*/
+
+class Joueur
+{
+    public:
+    Joueur(SDL_Surface* ecran);
+    ~Joueur();
+    void afficher();
+    void setArme(std::string choixArme);
+    void giveMousePosition(int x,int y);
+    void tir();
+    void recevoirDegats(int degats);
+    bool estVivant();
+    unsigned int getTypeWeapon();
+
+    protected:
+    //Ecran en attribut pour les blits
+    SDL_Surface* m_ecran;
+    //Nombre de boucles depuis le début du programme
+    int m_armeCycle;
+    int m_variableVie;
+    SDL_Rect m_positionViseur;
+    SDL_Rect m_positionInterVie;
+    SDL_Surface* m_interVie;
+    SDL_Surface* m_jaugeVie[60];
+    bool m_tirInstant;
+    Arme* m_armeSelect;
+    Arme* m_armeOne;
+    Arme* m_armeTwo;
+    Arme* m_armeThree;
+};
+
+#endif // ARME_H_INCLUDED

+ 133 - 133
eventLoop.cpp

@@ -1,133 +1,133 @@
-#include "eventLoop.h"
-
-int eventLoop(SDL_Surface* ecran)
-{
-    int check(0);//Variable d'erreur; 0=Ok, -1=probleme
-    // Charges des images
-    SDL_Surface* mort = SDL_LoadBMP("Images/GameOver.bmp");
-    SDL_SetColorKey(mort,SDL_SRCCOLORKEY,SDL_MapRGB(mort->format,0,255,255));
-
-    Joueur joueur(ecran);
-    joueur.setArme("Baroudeur");
-    Bouton iconeOne(0,0,0,"Baroudeur", ecran, &joueur);//Précédent 0/404
-    Bouton iconeTwo(0,76,1,"Usiane", ecran, &joueur);//Précédent 140/404
-    Bouton iconeThree(0,152,2,"Triphaseur", ecran, &joueur);//Précédent 280/404
-    ChampDeBataille arena(&joueur,ecran,10);
-
-    if (!mort)//Recherche d'erreurs
-    {
-        printf("Unable to load bitmap: %s\n", SDL_GetError());
-        check=-1;
-        return check;
-    }
-
-    // Coordonnées des surfaces
-    SDL_Rect position;
-    position.x = 0;
-    position.y = 0;
-    //Mise au point du tir sans répétition due à la mémoire de l'evenement.
-    bool latence(true);
-    // program main loop
-    bool done = false;
-    SDL_ShowCursor(SDL_DISABLE);
-    //Gérance du temps
-    int tempsPrecedent(0);
-    int tempsActuel(0);
-    while (!done && optionsFire::continuer)
-    {
-            // message processing loop
-        SDL_Event event;
-        SDL_PollEvent(&event);
-            // activation du fps (fréquence à 50Hz)
-        tempsActuel=SDL_GetTicks();
-        if (tempsActuel-tempsPrecedent>20)
-        {//Fps
-
-            // check for messages
-        switch (event.type)
-        {
-            // exit if the window is closed
-        case SDL_QUIT:
-            optionsFire::continuer=false;
-            done = true;
-            break;
-        case SDL_KEYDOWN:
-            switch(event.key.keysym.sym)
-            {
-            case SDLK_ESCAPE:
-                done = true;
-                break;
-            case SDLK_b:
-                joueur.setArme("Baroudeur");
-                break;
-            case SDLK_u:
-                joueur.setArme("Usiane");
-                break;
-            case SDLK_t:
-                joueur.setArme("Triphaseur");
-                break;
-            }
-            break;
-        case SDL_MOUSEMOTION:
-            joueur.giveMousePosition(event.motion.x,event.motion.y);
-            break;
-        case SDL_MOUSEBUTTONDOWN:
-            switch (event.button.button)
-                {
-                case SDL_BUTTON_LEFT:
-                    if(latence==true)
-                    {
-                        Cliquable::getFire(event.button.x,event.button.y,joueur.getTypeWeapon());
-                        joueur.tir();
-                    }
-                    latence=false;//Empeche de tirer en continu.
-                    break;
-                }//SDL_MOUSEBUTTONDOWN
-            break;
-        case SDL_MOUSEBUTTONUP:
-            switch (event.button.button)
-                {
-                case SDL_BUTTON_LEFT:
-                    latence=true;
-                    break;
-                }
-
-
-        } //EVENT end switch event loop
-        // DRAWING STARTS HERE
-
-        // clear screen
-        SDL_FillRect(ecran, 0, SDL_MapRGB(ecran->format, 0, 0, 0));
-        // draw bitmap
-        SDL_BlitSurface(optionsFire::level, 0, ecran, &position);
-
-            //Gestion du temps
-            tempsActuel=tempsPrecedent;
-            if (joueur.estVivant())
-            {
-                iconeOne.afficher();
-                iconeTwo.afficher();
-                iconeThree.afficher();
-                arena.afficher();
-                joueur.afficher();
-            }
-            else
-            {
-                SDL_BlitSurface(mort, 0, ecran, &position);
-                SDL_ShowCursor(SDL_ENABLE);
-            }
-            // DRAWING ENDS HERE
-            Cliquable::upFire();
-        }//End fps
-
-        // finally, update the screen :)
-        SDL_Flip(ecran);
-    } //MAIN end main loop
-
-
-    // free loaded bitmap
-    SDL_FreeSurface(optionsFire::level);//Fond
-    optionsFire::level=0;//On pointe le pointeur sur lui, pour la securité
-
-    return check;
-}
+#include "eventLoop.h"
+
+int eventLoop(SDL_Surface* ecran)
+{
+    int check(0);//Variable d'erreur; 0=Ok, -1=probleme
+    // Charges des images
+    SDL_Surface* mort = SDL_LoadBMP("Images/GameOver.bmp");
+    SDL_SetColorKey(mort,SDL_SRCCOLORKEY,SDL_MapRGB(mort->format,0,255,255));
+
+    Joueur joueur(ecran);
+    joueur.setArme("Baroudeur");
+    Bouton iconeOne(0,0,0,"Baroudeur", ecran, &joueur);//Précédent 0/404
+    Bouton iconeTwo(0,76,1,"Usiane", ecran, &joueur);//Précédent 140/404
+    Bouton iconeThree(0,152,2,"Triphaseur", ecran, &joueur);//Précédent 280/404
+    ChampDeBataille arena(&joueur,ecran,10);
+
+    if (!mort)//Recherche d'erreurs
+    {
+        printf("Unable to load bitmap: %s\n", SDL_GetError());
+        check=-1;
+        return check;
+    }
+
+    // Coordonnées des surfaces
+    SDL_Rect position;
+    position.x = 0;
+    position.y = 0;
+    //Mise au point du tir sans répétition due à la mémoire de l'evenement.
+    bool latence(true);
+    // program main loop
+    bool done = false;
+    SDL_ShowCursor(SDL_DISABLE);
+    //Gérance du temps
+    int tempsPrecedent(0);
+    int tempsActuel(0);
+    while (!done && optionsFire::continuer)
+    {
+            // message processing loop
+        SDL_Event event;
+        SDL_PollEvent(&event);
+            // activation du fps (fréquence à 50Hz)
+        tempsActuel=SDL_GetTicks();
+        if (tempsActuel-tempsPrecedent>20)
+        {//Fps
+
+            // check for messages
+        switch (event.type)
+        {
+            // exit if the window is closed
+        case SDL_QUIT:
+            optionsFire::continuer=false;
+            done = true;
+            break;
+        case SDL_KEYDOWN:
+            switch(event.key.keysym.sym)
+            {
+            case SDLK_ESCAPE:
+                done = true;
+                break;
+            case SDLK_b:
+                joueur.setArme("Baroudeur");
+                break;
+            case SDLK_u:
+                joueur.setArme("Usiane");
+                break;
+            case SDLK_t:
+                joueur.setArme("Triphaseur");
+                break;
+            }
+            break;
+        case SDL_MOUSEMOTION:
+            joueur.giveMousePosition(event.motion.x,event.motion.y);
+            break;
+        case SDL_MOUSEBUTTONDOWN:
+            switch (event.button.button)
+                {
+                case SDL_BUTTON_LEFT:
+                    if(latence==true)
+                    {
+                        Cliquable::getFire(event.button.x,event.button.y,joueur.getTypeWeapon());
+                        joueur.tir();
+                    }
+                    latence=false;//Empeche de tirer en continu.
+                    break;
+                }//SDL_MOUSEBUTTONDOWN
+            break;
+        case SDL_MOUSEBUTTONUP:
+            switch (event.button.button)
+                {
+                case SDL_BUTTON_LEFT:
+                    latence=true;
+                    break;
+                }
+
+
+        } //EVENT end switch event loop
+        // DRAWING STARTS HERE
+
+        // clear screen
+        SDL_FillRect(ecran, 0, SDL_MapRGB(ecran->format, 0, 0, 0));
+        // draw bitmap
+        SDL_BlitSurface(optionsFire::level, 0, ecran, &position);
+
+            //Gestion du temps
+            tempsActuel=tempsPrecedent;
+            if (joueur.estVivant())
+            {
+                iconeOne.afficher();
+                iconeTwo.afficher();
+                iconeThree.afficher();
+                arena.afficher();
+                joueur.afficher();
+            }
+            else
+            {
+                SDL_BlitSurface(mort, 0, ecran, &position);
+                SDL_ShowCursor(SDL_ENABLE);
+            }
+            // DRAWING ENDS HERE
+            Cliquable::upFire();
+        }//End fps
+
+        // finally, update the screen :)
+        SDL_Flip(ecran);
+    } //MAIN end main loop
+
+
+    // free loaded bitmap
+    SDL_FreeSurface(optionsFire::level);//Fond
+    optionsFire::level=0;//On pointe le pointeur sur lui, pour la securité
+
+    return check;
+}

+ 18 - 18
eventLoop.h

@@ -1,18 +1,18 @@
-#ifndef EVENTLOOP_H_INCLUDED
-#define EVENTLOOP_H_INCLUDED
-
-/*Description:
-Cette boucle evenemntielle contient le jeu en lui même.
-*/
-
-#include <iostream>
-#include <SDL/SDL.h>
-#include "Joueur.h"
-#include "Cliquable.h"
-#include "Bouton.h"
-#include "ChampDeBataille.h"
-#include "menuFire.h"
-
-int eventLoop(SDL_Surface* ecran);
-
-#endif // EVENTLOOP_H_INCLUDED
+#ifndef EVENTLOOP_H_INCLUDED
+#define EVENTLOOP_H_INCLUDED
+
+/*Description:
+Cette boucle evenemntielle contient le jeu en lui même.
+*/
+
+#include <iostream>
+#include <SDL/SDL.h>
+#include "Joueur.h"
+#include "Cliquable.h"
+#include "Bouton.h"
+#include "ChampDeBataille.h"
+#include "menuFire.h"
+
+int eventLoop(SDL_Surface* ecran);
+
+#endif // EVENTLOOP_H_INCLUDED

+ 58 - 58
main.cpp

@@ -1,58 +1,58 @@
-#include <iostream>
-#include <cstdlib>
-#include <SDL/SDL.h>
-#include "eventLoop.h"
-#include "menuFire.h"
-
-int main ( int argc, char** argv )
-{
-    int error(0);
-    while (optionsFire::continuer)
-/* */{
-    //Menu
-    error=menuFire();
-
-    // Initialisation de la SDL
-    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
-    {
-        printf( "Unable to init SDL: %s\n", SDL_GetError() );
-        error=1;
-    }
-
-    // Lorsque le programme ferme, la SDL se ferme automatiquement.
-    atexit(SDL_Quit);
-
-    // create a new window
-    SDL_WM_SetIcon(SDL_LoadBMP("Images/Icone Prog D.bmp"),NULL);//Icone en haut à droite de la fenêtre.
-    SDL_Surface* screen =0;
-    if(optionsFire::pleinEcran)
-    {
-        screen = SDL_SetVideoMode(640, 480, 32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);//Création de la fenêtre plein ecran
-    }
-    else
-    {
-        screen = SDL_SetVideoMode(640, 480, 32,SDL_HWSURFACE|SDL_DOUBLEBUF);//Création de la fenêtre
-    }
-
-    SDL_WM_SetCaption("Fire !!!",NULL);//Nom de la fenêtre
-    if ( !screen )
-    {
-        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
-        error=1;
-    }
-
-    if (!error)
-    {
-        eventLoop(screen);
-    }
-    else if(error==2)
-    {
-        error=0;
-    }
-
-/* */}
-
-    // all is well ;)
-    printf("Exited cleanly\n");
-    return error;
-}
+#include <iostream>
+#include <cstdlib>
+#include <SDL/SDL.h>
+#include "eventLoop.h"
+#include "menuFire.h"
+
+int main ( int argc, char** argv )
+{
+    int error(0);
+    while (optionsFire::continuer)
+/* */{
+    //Menu
+    error=menuFire();
+
+    // Initialisation de la SDL
+    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
+    {
+        printf( "Unable to init SDL: %s\n", SDL_GetError() );
+        error=1;
+    }
+
+    // Lorsque le programme ferme, la SDL se ferme automatiquement.
+    atexit(SDL_Quit);
+
+    // create a new window
+    SDL_WM_SetIcon(SDL_LoadBMP("Images/Icone Prog D.bmp"),NULL);//Icone en haut à droite de la fenêtre.
+    SDL_Surface* screen =0;
+    if(optionsFire::pleinEcran)
+    {
+        screen = SDL_SetVideoMode(640, 480, 32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);//Création de la fenêtre plein ecran
+    }
+    else
+    {
+        screen = SDL_SetVideoMode(640, 480, 32,SDL_HWSURFACE|SDL_DOUBLEBUF);//Création de la fenêtre
+    }
+
+    SDL_WM_SetCaption("Fire !!!",NULL);//Nom de la fenêtre
+    if ( !screen )
+    {
+        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
+        error=1;
+    }
+
+    if (!error)
+    {
+        eventLoop(screen);
+    }
+    else if(error==2)
+    {
+        error=0;
+    }
+
+/* */}
+
+    // all is well ;)
+    printf("Exited cleanly\n");
+    return error;
+}

+ 147 - 147
menuFire.cpp

@@ -1,147 +1,147 @@
-#include "menuFire.h"
-bool optionsFire::continuer=true;
-unsigned int optionsFire::difficulte=0;
-bool optionsFire::pleinEcran=false;
-SDL_Surface* optionsFire::level=0;
-
-int menuFire()
-{
-    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
-    {
-        printf( "Unable to init SDL: %s\n", SDL_GetError() );
-        return 1;
-    }
-
-    // Lorsque le programme ferme, la SDL se ferme automatiquement.
-    atexit(SDL_Quit);
-
-    // create a new window
-    SDL_WM_SetIcon(SDL_LoadBMP("Images/Icone Prog D.bmp"),NULL);//Icone en haut à droite de la fenêtre.
-    SDL_Surface* ecran = SDL_SetVideoMode(640, 480, 16,SDL_HWSURFACE|SDL_DOUBLEBUF);//Création de la fenêtre
-    SDL_WM_SetCaption("Fire !!!",NULL);//Nom de la fenêtre
-    if ( !ecran )
-    {
-        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
-        return 1;
-    }
-
-    int quit(0);
-    SDL_ShowCursor(SDL_ENABLE);
-    //EVENT LOOP***********************************
-    SDL_Surface* bmp = SDL_LoadBMP("Images/Hiver.bmp");
-    SDL_Surface* bmpDeux = SDL_LoadBMP("Images/Collines.bmp");
-    SDL_Surface* bmpTrois = SDL_LoadBMP("Images/Soleil.bmp");
-    SDL_Surface* bmpSelect = bmp;//Choix par defaut
-    int choice(0);
-    SDL_Surface* indication = SDL_LoadBMP("Images/MenuFire.bmp");
-    SDL_SetColorKey(indication,SDL_SRCCOLORKEY,SDL_MapRGB(indication->format,255,255,255));
-    if (!bmp)//Recherche d'erreurs
-    {
-        printf("Unable to load bitmap: %s\n", SDL_GetError());
-        return 1;
-    }
-
-    // Coordonnées des surfaces
-    SDL_Rect position;  SDL_Rect positionIndication;
-    position.x = 0;     positionIndication.x = 160;
-    position.y = 0;     positionIndication.y = 120;
-
-    bool done = false;
-    while (!done)
-    {
-        // message processing loop
-        SDL_Event event;
-        SDL_WaitEvent(&event);
-            // check for messages
-        switch (event.type)
-        {
-            // exit if the window is closed
-        case SDL_QUIT:
-            optionsFire::continuer=false;
-            done = true;
-            quit = 2;//Signifie que le joueur quitte pour de bon.
-            break;
-
-            // check for keypresses
-        case SDL_KEYDOWN:
-            switch(event.key.keysym.sym)
-            {
-                case SDLK_ESCAPE://Touche Echape
-                    done = true;
-                    break;
-                case SDLK_LEFT://Petit ecran
-                    optionsFire::pleinEcran=false;
-                    break;
-                case SDLK_RIGHT://Plein ecran
-                    optionsFire::pleinEcran=true;
-                    break;
-                case SDLK_UP://Monte le niveau de difficulté
-                    if (choice<2)
-                    {
-                        choice++;
-                    }
-
-                    break;
-                case SDLK_DOWN://Baisse le niveau de difficulte
-                    if (choice>0)
-                    {
-                        choice--;
-                    }
-
-                    break;
-            }
-            break;
-        } // end switch
-        // CALCULING STARTS HERE
-        switch(choice)
-        {
-            case 0:
-                bmpSelect=bmp;
-                break;
-            case 1:
-                bmpSelect=bmpDeux;
-                break;
-            case 2:
-                bmpSelect=bmpTrois;
-                break;
-        }
-        // DRAWING STARTS HERE
-
-        // clear screen
-        SDL_FillRect(ecran, 0, SDL_MapRGB(ecran->format, 0, 0, 0));
-
-        // draw bitmap
-        SDL_BlitSurface(bmpSelect, 0, ecran, &position);
-        SDL_BlitSurface(indication, 0, ecran, &positionIndication);
-
-        // DRAWING ENDS HERE
-
-        // finally, update the screen :)
-        SDL_Flip(ecran);
-    } // end main loop
-    //Attribution des options
-    optionsFire::level=bmpSelect;
-    optionsFire::difficulte=choice;
-
-    // free loaded bitmap
-    if (!(bmpSelect==bmp))
-    {
-        SDL_FreeSurface(bmp);
-    }
-    else if(!(bmpSelect==bmpDeux))
-    {
-        SDL_FreeSurface(bmpDeux);
-    }
-    else if (!(bmpSelect==bmpTrois))
-    {
-        SDL_FreeSurface(bmpTrois);
-    }
-    SDL_FreeSurface(indication);
-    //END EVENT LOOP*******************************
-
-    // all is well ;)
-    printf("Exited cleanly\n");
-
-    return quit;
-}
-
+#include "menuFire.h"
+bool optionsFire::continuer=true;
+unsigned int optionsFire::difficulte=0;
+bool optionsFire::pleinEcran=false;
+SDL_Surface* optionsFire::level=0;
+
+int menuFire()
+{
+    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
+    {
+        printf( "Unable to init SDL: %s\n", SDL_GetError() );
+        return 1;
+    }
+
+    // Lorsque le programme ferme, la SDL se ferme automatiquement.
+    atexit(SDL_Quit);
+
+    // create a new window
+    SDL_WM_SetIcon(SDL_LoadBMP("Images/Icone Prog D.bmp"),NULL);//Icone en haut à droite de la fenêtre.
+    SDL_Surface* ecran = SDL_SetVideoMode(640, 480, 16,SDL_HWSURFACE|SDL_DOUBLEBUF);//Création de la fenêtre
+    SDL_WM_SetCaption("Fire !!!",NULL);//Nom de la fenêtre
+    if ( !ecran )
+    {
+        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    int quit(0);
+    SDL_ShowCursor(SDL_ENABLE);
+    //EVENT LOOP***********************************
+    SDL_Surface* bmp = SDL_LoadBMP("Images/Hiver.bmp");
+    SDL_Surface* bmpDeux = SDL_LoadBMP("Images/Collines.bmp");
+    SDL_Surface* bmpTrois = SDL_LoadBMP("Images/Soleil.bmp");
+    SDL_Surface* bmpSelect = bmp;//Choix par defaut
+    int choice(0);
+    SDL_Surface* indication = SDL_LoadBMP("Images/MenuFire.bmp");
+    SDL_SetColorKey(indication,SDL_SRCCOLORKEY,SDL_MapRGB(indication->format,255,255,255));
+    if (!bmp)//Recherche d'erreurs
+    {
+        printf("Unable to load bitmap: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Coordonnées des surfaces
+    SDL_Rect position;  SDL_Rect positionIndication;
+    position.x = 0;     positionIndication.x = 160;
+    position.y = 0;     positionIndication.y = 120;
+
+    bool done = false;
+    while (!done)
+    {
+        // message processing loop
+        SDL_Event event;
+        SDL_WaitEvent(&event);
+            // check for messages
+        switch (event.type)
+        {
+            // exit if the window is closed
+        case SDL_QUIT:
+            optionsFire::continuer=false;
+            done = true;
+            quit = 2;//Signifie que le joueur quitte pour de bon.
+            break;
+
+            // check for keypresses
+        case SDL_KEYDOWN:
+            switch(event.key.keysym.sym)
+            {
+                case SDLK_ESCAPE://Touche Echape
+                    done = true;
+                    break;
+                case SDLK_LEFT://Petit ecran
+                    optionsFire::pleinEcran=false;
+                    break;
+                case SDLK_RIGHT://Plein ecran
+                    optionsFire::pleinEcran=true;
+                    break;
+                case SDLK_UP://Monte le niveau de difficulté
+                    if (choice<2)
+                    {
+                        choice++;
+                    }
+
+                    break;
+                case SDLK_DOWN://Baisse le niveau de difficulte
+                    if (choice>0)
+                    {
+                        choice--;
+                    }
+
+                    break;
+            }
+            break;
+        } // end switch
+        // CALCULING STARTS HERE
+        switch(choice)
+        {
+            case 0:
+                bmpSelect=bmp;
+                break;
+            case 1:
+                bmpSelect=bmpDeux;
+                break;
+            case 2:
+                bmpSelect=bmpTrois;
+                break;
+        }
+        // DRAWING STARTS HERE
+
+        // clear screen
+        SDL_FillRect(ecran, 0, SDL_MapRGB(ecran->format, 0, 0, 0));
+
+        // draw bitmap
+        SDL_BlitSurface(bmpSelect, 0, ecran, &position);
+        SDL_BlitSurface(indication, 0, ecran, &positionIndication);
+
+        // DRAWING ENDS HERE
+
+        // finally, update the screen :)
+        SDL_Flip(ecran);
+    } // end main loop
+    //Attribution des options
+    optionsFire::level=bmpSelect;
+    optionsFire::difficulte=choice;
+
+    // free loaded bitmap
+    if (!(bmpSelect==bmp))
+    {
+        SDL_FreeSurface(bmp);
+    }
+    else if(!(bmpSelect==bmpDeux))
+    {
+        SDL_FreeSurface(bmpDeux);
+    }
+    else if (!(bmpSelect==bmpTrois))
+    {
+        SDL_FreeSurface(bmpTrois);
+    }
+    SDL_FreeSurface(indication);
+    //END EVENT LOOP*******************************
+
+    // all is well ;)
+    printf("Exited cleanly\n");
+
+    return quit;
+}
+

+ 17 - 17
menuFire.h

@@ -1,17 +1,17 @@
-#ifndef MENUFIRE_H_INCLUDED
-#define MENUFIRE_H_INCLUDED
-
-#include <iostream>
-#include <SDL/SDL.h>
-
-class optionsFire
-{
-    public:
-    static bool continuer;
-    static unsigned int difficulte;
-    static bool pleinEcran;
-    static SDL_Surface* level;
-};
-
-int menuFire();
-#endif // MENUFIRE_H_INCLUDED
+#ifndef MENUFIRE_H_INCLUDED
+#define MENUFIRE_H_INCLUDED
+
+#include <iostream>
+#include <SDL/SDL.h>
+
+class optionsFire
+{
+    public:
+    static bool continuer;
+    static unsigned int difficulte;
+    static bool pleinEcran;
+    static SDL_Surface* level;
+};
+
+int menuFire();
+#endif // MENUFIRE_H_INCLUDED

+ 28 - 28
takeRand.cpp

@@ -1,28 +1,28 @@
-#include "takeRand.h"
-
-int takeRand(int maxiNb)
-{
-    int nombreHasard(0);
-    srand(time(0));
-    nombreHasard = rand() % maxiNb;
-
-    return nombreHasard;
-}
-
-int takeRand(int maxiNb,int antiLatence)
-{
-    int nombreHasard(0);
-    srand(time(0)+antiLatence*antiLatence);
-    nombreHasard = rand() % maxiNb;
-
-    return nombreHasard;
-}
-
-int takeRand(int maxiNb,Uint32 noLatence)
-{
-    int nombreHasard(0);
-    srand(time(0)+noLatence);
-    nombreHasard = rand() % maxiNb;
-
-    return nombreHasard;
-}
+#include "takeRand.h"
+
+int takeRand(int maxiNb)
+{
+    int nombreHasard(0);
+    srand(time(0));
+    nombreHasard = rand() % maxiNb;
+
+    return nombreHasard;
+}
+
+int takeRand(int maxiNb,int antiLatence)
+{
+    int nombreHasard(0);
+    srand(time(0)+antiLatence*antiLatence);
+    nombreHasard = rand() % maxiNb;
+
+    return nombreHasard;
+}
+
+int takeRand(int maxiNb,Uint32 noLatence)
+{
+    int nombreHasard(0);
+    srand(time(0)+noLatence);
+    nombreHasard = rand() % maxiNb;
+
+    return nombreHasard;
+}

+ 19 - 19
takeRand.h

@@ -1,19 +1,19 @@
-#ifndef TAKERAND_H_INCLUDED
-#define TAKERAND_H_INCLUDED
-
-/*Description:
-Permet d'obtenir un entier au hasard.
-*/
-
-#include<iostream>
-#include<ctime>
-#include<cstdlib>
-
-#include<SDL/SDL.h>
-
-int takeRand(int maxiNb);
-int takeRand(int maxiNb,int antiLatence);
-
-int takeRand(int maxiNb,Uint32 noLatence);
-
-#endif // TAKERAND_H_INCLUDED
+#ifndef TAKERAND_H_INCLUDED
+#define TAKERAND_H_INCLUDED
+
+/*Description:
+Permet d'obtenir un entier au hasard.
+*/
+
+#include<iostream>
+#include<ctime>
+#include<cstdlib>
+
+#include<SDL/SDL.h>
+
+int takeRand(int maxiNb);
+int takeRand(int maxiNb,int antiLatence);
+
+int takeRand(int maxiNb,Uint32 noLatence);
+
+#endif // TAKERAND_H_INCLUDED