Browse Source

Import source code from old project

xayon40-12 4 years ago
commit
f563566439
66 changed files with 2394 additions and 0 deletions
  1. 40 0
      .gitignore
  2. 31 0
      Fantome.h
  3. 181 0
      Fenetre.cpp
  4. 47 0
      Fenetre.h
  5. BIN
      Images/._Thumbs.db
  6. BIN
      Images/Maquette 2.bmp
  7. BIN
      Images/Maquette finale.bmp
  8. BIN
      Images/Maquette.bmp
  9. BIN
      Images/Thumbs.db
  10. BIN
      Images/boutonLevel.bmp
  11. BIN
      Images/boutonLevelB.bmp
  12. BIN
      Images/droite.bmp
  13. BIN
      Images/gauche.bmp
  14. 124 0
      Input.h
  15. 28 0
      Joueur.cpp
  16. 21 0
      Joueur.h
  17. 56 0
      Menestrel.cpp
  18. 16 0
      Menestrel.h
  19. 70 0
      Menu/Bouton.cpp
  20. 58 0
      Menu/Bouton.h
  21. 226 0
      Menu/gestionnaireNiveaux.cpp
  22. 83 0
      Menu/gestionnaireNiveaux.h
  23. 81 0
      Menu/menu.cpp
  24. 28 0
      Menu/menu.h
  25. 51 0
      Menu/transform.cpp
  26. 30 0
      Menu/transform.h
  27. 438 0
      Niveau.cpp
  28. 70 0
      Niveau.h
  29. 22 0
      Niveaux/level 1.txt
  30. 22 0
      Niveaux/level 10.txt
  31. 22 0
      Niveaux/level 11.txt
  32. 22 0
      Niveaux/level 12.txt
  33. 22 0
      Niveaux/level 13.txt
  34. 22 0
      Niveaux/level 2.txt
  35. 22 0
      Niveaux/level 21.txt
  36. 22 0
      Niveaux/level 24.txt
  37. 22 0
      Niveaux/level 3.txt
  38. 22 0
      Niveaux/level 4.txt
  39. 22 0
      Niveaux/level 5.txt
  40. 22 0
      Niveaux/level 6.txt
  41. 22 0
      Niveaux/level 7.txt
  42. 22 0
      Niveaux/level 8.txt
  43. 22 0
      Niveaux/level 9.txt
  44. 101 0
      Ogre.cpp
  45. 26 0
      Ogre.h
  46. 49 0
      Personnage.cpp
  47. 36 0
      Personnage.h
  48. BIN
      Polices/angelina.ttf
  49. BIN
      Polices/angelina.zip
  50. BIN
      Polices/droid.ttf
  51. BIN
      Skins/Fantome.png
  52. BIN
      Skins/Menestrel.png
  53. BIN
      Skins/Ogre.png
  54. BIN
      Skins/OgreBerzerk.png
  55. BIN
      Skins/grosBourin.png
  56. BIN
      Skins/vie.png
  57. BIN
      Textures/cobblestone.bmp
  58. BIN
      Textures/planks.bmp
  59. BIN
      Textures/plaque.bmp
  60. BIN
      Textures/spawnAllie.bmp
  61. BIN
      Textures/spawnFantom.bmp
  62. BIN
      Textures/steak.bmp
  63. BIN
      Textures/tonneau.bmp
  64. 136 0
      fantome.cpp
  65. 11 0
      main.cpp
  66. 26 0
      makefile

+ 40 - 0
.gitignore

@@ -0,0 +1,40 @@
+# Created by https://www.toptal.com/developers/gitignore/api/c++
+# Edit at https://www.toptal.com/developers/gitignore?templates=c++
+
+### C++ ###
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
+# End of https://www.toptal.com/developers/gitignore/api/c++
+
+bin/

+ 31 - 0
Fantome.h

@@ -0,0 +1,31 @@
+#ifndef FANTOME_H
+#define FANTOME_H
+#include "Personnage.h"
+#include "Ogre.h"
+#include "Menestrel.h"
+
+#define TEMPS_MORT 5000
+
+
+class Fantome: public Personnage
+{
+public:
+    Fantome(Niveau *terrain, Ogre *ogre, Menestrel *menestrel, Controle controle = local);
+    ~Fantome();
+    void deplacer();
+    void positionner(SDL_Rect position, bool coordonnee = false);
+    void afficher(SDL_Surface *ecran);
+    void tuer();
+    bool vivant();
+    bool getMultiKill(int nbFantomes);
+
+private:
+    Controle m_controle;
+    Ogre *m_ogre;
+    Menestrel *m_menestrel;
+    Uint32 m_tempsRestant;
+    bool m_vivant;
+    static int m_multiKill;
+};
+
+#endif // FANTOME_H

+ 181 - 0
Fenetre.cpp

@@ -0,0 +1,181 @@
+#include "Fenetre.h"
+
+Fenetre::Fenetre(): m_ecran(0), m_vies(0), typeCo(LOCAL), m_ogre(&m_input, &m_terrain), m_menestrel(&m_input, &m_terrain)
+{
+    if(init())
+    {
+        std::string nomNiveau;
+        while((nomNiveau = menu(m_ecran)) != "quitter")
+        {
+            if(!chargerNiveau(nomNiveau))
+                break;
+            if(typeCo == LOCAL)
+                jeulocal();
+            if(typeCo == HOST)
+                jeuhost();
+            if(typeCo == CLIENT)
+                jeuclient();
+            if(!m_input.continuer())
+                break;
+        }
+    }
+}
+Fenetre::~Fenetre()
+{
+    SDL_FreeSurface(m_ecran);
+    SDL_FreeSurface(m_vies);
+    SDL_FreeSurface(m_grosBourin);
+    SDL_Quit();
+    TTF_Quit();
+}
+
+
+bool Fenetre::init()
+{
+    m_vies = IMG_Load("Skins/vie.png");
+    if(m_vies == 0)
+    {
+        std::cout << "Chargement de l'image vie impossible" << std::endl;
+        return false;
+    }
+    m_grosBourin = IMG_Load("Skins/grosBourin.png");
+    if(m_grosBourin == 0)
+    {
+        std::cout << "Chargement de l'image grosBourin impossible" << std::endl;
+        return false;
+    }
+    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1 || TTF_Init() == -1)
+    {
+        std::cout << "Initialisation de la SDL impossible" << std::endl;
+        SDL_Quit();
+        TTF_Quit();
+        return false;
+    }
+    SDL_WM_SetCaption("PacMen", 0);
+    m_ecran = SDL_SetVideoMode(600, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
+    if(m_ecran == 0)
+    {
+        std::cout << "Creation de l'ecran impossible" << std::endl;
+        SDL_Quit();
+        TTF_Quit();
+        return false;
+    }
+    return true;
+}
+
+void Fenetre::jeulocal()
+{
+    int vie = 3;
+    Uint32 tempsprecedent = SDL_GetTicks();
+    SDL_Rect pos;
+    m_input.reset();
+    while(m_terrain.itemsRestants()!=0)
+    {
+        m_input.updateEvenement();
+
+        if(m_input.getTouches(SDLK_ESCAPE) || !m_input.continuer())
+        {
+            std::cout << "quitter niveau" << std::endl;
+            return;
+        }
+
+        m_terrain.afficher(m_ecran);
+
+        m_ogre.deplacer();
+        m_menestrel.deplacer();
+        for(unsigned int i = 0;i<m_fantomes.size();i++)
+            m_fantomes[i]->deplacer();
+
+        for(unsigned int i = 0;i<m_fantomes.size();i++)
+        {
+            if(m_ogre.getPosition() == m_fantomes[i]->getPosition() && m_fantomes[i]->vivant())
+            {
+                if(m_ogre.getBerzerk())
+                {
+                    m_fantomes[i]->positionner(m_posFantomes);
+                    m_fantomes[i]->tuer();
+                }
+                else
+                {
+                    for(unsigned int i = 0;i<m_fantomes.size();i++)
+                        m_fantomes[i]->positionner(m_posFantomes);
+                    m_menestrel.positionner(m_posPersos);
+                    m_ogre.positionner(m_posPersos);
+                    vie--;
+                }
+            }
+            if(m_menestrel.getPosition() == m_fantomes[i]->getPosition() && m_fantomes[i]->vivant())
+            {
+                for(unsigned int i = 0;i<m_fantomes.size();i++)
+                    m_fantomes[i]->positionner(m_posFantomes);
+                m_ogre.positionner(m_posPersos);
+                m_menestrel.positionner(m_posPersos);
+                vie--;
+            }
+        }
+        m_ogre.afficher(m_ecran);
+        m_menestrel.afficher(m_ecran);
+        for(unsigned int i = 0;i<m_fantomes.size();i++)
+            m_fantomes[i]->afficher(m_ecran);
+
+        pos.y = 0;
+        for(int i = 0;i<vie;i++)
+        {
+            pos.x = i*30;
+            SDL_BlitSurface(m_vies, 0, m_ecran, &pos);
+        }
+        if(m_fantomes[0]->getMultiKill(m_fantomes.size()))
+        {
+            vie++;
+            pos.x = 44;
+            pos.y = 247;
+            SDL_BlitSurface(m_grosBourin, 0, m_ecran, &pos);
+            SDL_Flip(m_ecran);
+            SDL_Delay(2000);
+        }
+        if(vie <= 0)
+        {
+            std::cout << "mort" << std::endl;
+            return;
+        }
+
+        SDL_Flip(m_ecran);
+        while((SDL_GetTicks()-tempsprecedent)<1000/60);
+        tempsprecedent = SDL_GetTicks();
+    }
+    std::cout << "plus de steaks" << std::endl;
+}
+
+void Fenetre::jeuhost()
+{
+
+}
+void Fenetre::jeuclient()
+{
+
+}
+
+bool Fenetre::chargerNiveau(std::string nomNiveau)
+{
+    viderFantomes();
+    if(!m_terrain.creer(nomNiveau))
+        return false;
+    m_posPersos.x = m_terrain.popAllie(X);
+    m_posPersos.y = m_terrain.popAllie(Y);
+    m_posFantomes.x = m_terrain.popFantom(X);
+    m_posFantomes.y = m_terrain.popFantom(Y);
+    m_ogre.positionner(m_posPersos);
+    m_menestrel.positionner(m_posPersos);
+    for(int i = 0;i<m_terrain.getEffectifMobs();i++)
+    {
+        m_fantomes.push_back(new Fantome(&m_terrain, &m_ogre, &m_menestrel));
+        m_fantomes[i]->positionner(m_posFantomes);
+    }
+    return true;
+}
+void Fenetre::viderFantomes()
+{
+    for(unsigned int i = 0;i<m_fantomes.size();i++)
+        delete m_fantomes[i];
+    m_fantomes.clear();
+}

+ 47 - 0
Fenetre.h

@@ -0,0 +1,47 @@
+#ifndef FENETRE_H_INCLUDED
+#define FENETRE_H_INCLUDED
+
+#include <iostream>
+#include <SDL/SDL.h>
+#undef main
+#include <ctime>
+#include "Input.h"
+#include "Ogre.h"
+#include "Menestrel.h"
+#include "Niveau.h"
+#include "Fantome.h"
+#include "Menu/menu.h"
+/**
+  fenetre adapté a des cases de 30x30 pixels
+
+
+  */
+enum TypeConnexion {HOST, CLIENT, LOCAL};
+
+class Fenetre
+{
+public:
+    Fenetre();
+    ~Fenetre();
+
+    bool init();
+    void jeuhost();
+    void jeuclient();
+    void jeulocal();
+    bool chargerNiveau(std::string nomNiveau);
+    void viderFantomes();
+    void fin();
+
+private:
+    SDL_Surface *m_ecran, *m_vies, *m_grosBourin;
+    SDL_Rect m_posPersos, m_posFantomes;
+    Input m_input;
+    TypeConnexion typeCo;
+
+    Niveau m_terrain;
+    Ogre m_ogre;
+    Menestrel m_menestrel;
+    std::vector<Fantome*> m_fantomes;
+};
+
+#endif // FENETRE_H_INCLUDED

BIN
Images/._Thumbs.db


BIN
Images/Maquette 2.bmp


BIN
Images/Maquette finale.bmp


BIN
Images/Maquette.bmp


BIN
Images/Thumbs.db


BIN
Images/boutonLevel.bmp


BIN
Images/boutonLevelB.bmp


BIN
Images/droite.bmp


BIN
Images/gauche.bmp


+ 124 - 0
Input.h

@@ -0,0 +1,124 @@
+#ifndef INPUT_H_INCLUDED
+#define INPUT_H_INCLUDED
+
+#include <SDL/SDL.h>
+#undef main
+
+class Input
+{
+public:
+    Input(): m_x(0), m_y(0), m_xRel(0), m_yRel(0), m_continuer(true)
+    {
+        reset();
+    }
+    ~Input()
+    {
+
+    }
+
+    void updateEvenement()
+    {
+        m_xRel = 0;
+        m_yRel = 0;
+
+        while(SDL_PollEvent(&m_evenement))
+        {
+            switch(m_evenement.type)
+            {
+            case SDL_QUIT:
+                m_continuer = false;
+                break;
+
+            case SDL_KEYDOWN:
+                m_touches[m_evenement.key.keysym.sym] = true;
+                break;
+
+            case SDL_KEYUP:
+                m_touches[m_evenement.key.keysym.sym] = false;
+                break;
+
+            case SDL_MOUSEBUTTONDOWN:
+                m_boutonsSouris[m_evenement.button.button] = true;
+                break;
+
+            case SDL_MOUSEBUTTONUP:
+                m_boutonsSouris[m_evenement.button.button] = false;
+                break;
+
+            case SDL_MOUSEMOTION:
+                m_x = m_evenement.motion.x;
+                m_y = m_evenement.motion.y;
+
+                m_xRel = m_evenement.motion.xrel;
+                m_yRel = m_evenement.motion.yrel;
+                break;
+
+            default:
+                break;
+            }
+        }
+    }
+    bool continuer() const
+    {
+        return m_continuer;
+    }
+    bool getTouches(const SDLKey touche) const
+    {
+        return m_touches[touche];
+    }
+    bool getBoutonSouris(const Uint8 bouton) const
+    {
+        return m_boutonsSouris[bouton];
+    }
+    bool mouvementSouris() const
+    {
+        if(m_xRel == 0 && m_yRel == 0)
+            return false;
+
+        else
+            return true;
+    }
+    int getX() const
+    {
+        return m_x;
+    }
+    int getY() const
+    {
+        return m_y;
+    }
+    int getXRel() const
+    {
+        return m_xRel;
+    }
+    int getYRel() const
+    {
+       return m_yRel;
+    }
+    void afficherPointeur(bool reponse) const
+    {
+        if(reponse)
+            SDL_ShowCursor(SDL_ENABLE);
+        else
+            SDL_ShowCursor(SDL_DISABLE);
+    }
+    void reset()
+    {
+        for(int i = 0;i<323;i++)
+            m_touches[i] = false;
+
+        for(int i = 0;i<8;i++)
+            m_boutonsSouris[i] = false;
+    }
+
+private:
+    SDL_Event m_evenement;
+    bool m_touches[323];
+    bool m_boutonsSouris[8];
+
+    int m_x, m_y;
+    int m_xRel, m_yRel;
+
+    bool m_continuer;
+};
+
+#endif // INPUT_H_INCLUDED

+ 28 - 0
Joueur.cpp

@@ -0,0 +1,28 @@
+#include "Joueur.h"
+
+Joueur::Joueur(Input *input, Niveau *terrain, Controle controle): Personnage(), m_input(input), m_controle(controle)
+{
+    m_terrain = terrain;
+    m_direction = Arret;
+    m_nouvDir = Arret;
+}
+
+void Joueur::positionner(SDL_Rect position, bool coordonnee)
+{
+    if(coordonnee)
+    {
+        m_pos.x = position.x;
+        m_pos.y = position.y;
+    }
+    else
+    {
+        m_pos.x = position.x*LG_BLOC - (m_skin->w-LG_BLOC)/2;
+        m_pos.y = position.y*LG_BLOC - (m_skin->h-LG_BLOC)/2;
+    }
+    m_direction = Arret;
+}
+
+void Joueur::afficher(SDL_Surface *ecran)
+{
+    SDL_BlitSurface(m_skin, 0, ecran, &m_pos);
+}

+ 21 - 0
Joueur.h

@@ -0,0 +1,21 @@
+#ifndef JOUEUR_H_INCLUDED
+#define JOUEUR_H_INCLUDED
+
+#include "Personnage.h"
+#include "Input.h"
+
+class Joueur : public Personnage
+{
+public:
+    Joueur(Input *input, Niveau *terrain, Controle controle = local);
+    virtual ~Joueur(){}
+    virtual void deplacer() = 0;
+    virtual void afficher(SDL_Surface *ecran);
+    virtual void positionner(SDL_Rect position, bool coordonnee = false);
+
+protected:
+    Input *m_input;
+    Controle m_controle;
+};
+
+#endif // JOUEUR_H_INCLUDED

+ 56 - 0
Menestrel.cpp

@@ -0,0 +1,56 @@
+#include "Menestrel.h"
+
+Menestrel::Menestrel(Input *input, Niveau *terrain, Controle controle): Joueur(input, terrain, controle)
+{
+    m_skin = IMG_Load("Skins/Menestrel.png");
+    if(m_skin == 0)
+        std::cout << "Erreur de chargement du skin Skins/Menestrel.png" << std::endl;
+}
+Menestrel::~Menestrel()
+{
+    SDL_FreeSurface(m_skin);
+}
+
+
+void Menestrel::deplacer()
+{
+    if(m_controle == local)
+    {
+        if(m_input->getTouches(SDLK_UP))
+            m_nouvDir = Haut;
+        else if(m_input->getTouches(SDLK_RIGHT))
+            m_nouvDir = Droite;
+        else if(m_input->getTouches(SDLK_DOWN))
+            m_nouvDir = Bas;
+        else if(m_input->getTouches(SDLK_LEFT))
+            m_nouvDir = Gauche;
+    }
+    int posX = m_pos.x + (m_skin->w-LG_BLOC)/2;
+    int posY = m_pos.y + (m_skin->h-LG_BLOC)/2;
+    int dirPossible = Arret;
+     if(m_terrain->typeBloc(posX-1, posY, 1) != MUR && m_terrain->typeBloc(posX-1, posY+LG_BLOC-1, 1) != MUR)
+            dirPossible |= Gauche;
+     if(m_terrain->typeBloc(posX+LG_BLOC, posY, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC, posY+LG_BLOC-1, 1) != MUR)
+            dirPossible |= Droite;
+     if(m_terrain->typeBloc(posX, posY-1, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY-1, 1) != MUR)
+            dirPossible |= Haut;
+     if(m_terrain->typeBloc(posX, posY+LG_BLOC, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY+LG_BLOC, 1) != MUR)
+            dirPossible |= Bas;
+
+    if(dirPossible & m_nouvDir)
+        m_direction = m_nouvDir;
+
+    if(dirPossible & m_direction)
+    {
+        m_pos+=m_direction;
+        posX = m_pos.x + (m_skin->w-LG_BLOC)/2;
+        posY = m_pos.y + (m_skin->h-LG_BLOC)/2;
+    }
+    else if((!(dirPossible&Haut) && !(dirPossible&Bas) && (m_direction == Gauche || m_direction == Droite)) ||
+            (!(dirPossible&Gauche) && !(dirPossible&Droite) && (m_direction == Haut || m_direction == Bas)))
+    {
+        m_direction = m_direction==Gauche?Droite:m_direction==Droite?Gauche:m_direction==Haut?Bas:Haut;
+        m_nouvDir = m_direction;
+    }
+}
+

+ 16 - 0
Menestrel.h

@@ -0,0 +1,16 @@
+#ifndef MENESTREL_H
+#define MENESTREL_H
+
+#include "Joueur.h"
+#include "Input.h"
+
+class Menestrel : public Joueur
+{
+public:
+    Menestrel(Input *input, Niveau *terrain, Controle controle = local);
+    ~Menestrel();
+    void deplacer();
+protected:
+};
+
+#endif // MENESTREL_H

+ 70 - 0
Menu/Bouton.cpp

@@ -0,0 +1,70 @@
+#include "Bouton.h"
+
+Bouton::Bouton(SDL_Surface *objetImg, SDL_Surface *screen, int const x, int const y)
+:m_x(x),m_y(y),m_selectImg(0)
+{
+    m_objetImg = objetImg;
+    m_screen = screen;
+
+    m_blitImg = m_objetImg;
+}///Constructeur
+
+Bouton::~Bouton()
+{
+    SDL_FreeSurface(m_objetImg);
+    if (m_selectImg != 0)
+        SDL_FreeSurface(m_selectImg);
+}
+
+void Bouton::attribuerImg(SDL_Surface *selectImg)
+{
+    m_selectImg = selectImg;
+}///attribuerImg
+
+bool Bouton::calculer(int const xSouris, int const ySouris)
+{
+    if (m_selectImg != 0)
+    {/**if**/
+        if (m_x < xSouris && xSouris < m_x+m_objetImg->w)
+        {///if
+            if (m_y < ySouris && ySouris < m_y+m_objetImg->h)
+            {//if
+                m_blitImg = m_selectImg;
+                return true;//Souris dessus !
+            }//if
+            else
+            {//else
+                m_blitImg = m_objetImg;
+                return false;//Rien
+            }//else
+        }///if
+        else
+        {//else
+            m_blitImg = m_objetImg;
+            return false;//Rien
+        }//else
+    }/**if**/
+
+    return false;//Il y a pas de seconde image patate !
+}///calculer
+
+void Bouton::afficher()
+{
+    // [1] Attribution des positions
+    SDL_Rect position;
+    position.x=m_x;
+    position.y=m_y;
+
+    // [2] Collage
+    SDL_BlitSurface(m_blitImg, 0, m_screen, &position);
+}///afficher
+
+bool Bouton::estClique(int const xSouris, int const ySouris)
+{
+    if (m_x < xSouris && xSouris < m_x+m_objetImg->w)
+        if (m_y < ySouris && ySouris < m_y+m_objetImg->h)
+            return true;
+    return false;
+}///estClique
+
+

+ 58 - 0
Menu/Bouton.h

@@ -0,0 +1,58 @@
+#ifndef BOUTON_H_INCLUDED
+#define BOUTON_H_INCLUDED
+
+///Modifié le: 02/10/2013
+///Objet: calculer renvoie un bool
+///à faire:
+
+#include <iostream>
+#include <string>
+#include <SDL/SDL.h>
+#undef main
+
+/*
+===La classe Bouton===
+    +Définition:
+        Elle permet de savoir si on clique dessus. On peut l'afficher, on calcule en lui donnant les
+        coordonnées de la souris, et une fonction retourne si ça a été cliqué ou pas ! Voilà le travail. ;)
+        Il peut également changer de forme si on passe la souris dessus...
+    +Méthodes:
+        - Constructeur:
+
+        - attribuerImg:
+            Permet de donner une surface qui s'affiche quand la souris passe dessus.
+            Argument: SDL_surface de la deuxième image affichable.
+
+        - calculer:
+
+        - afficher:
+
+        - estClique:
+            Lorsqu'un clic se déclenche, permet de savoir si l'icone est cliquée.
+
+*/
+
+class Bouton
+{
+    public:
+    Bouton(SDL_Surface *objetImg, SDL_Surface *screen, int const x, int const y);
+    ~Bouton();
+    void attribuerImg(SDL_Surface *selectImg);
+    bool calculer(int const xSouris, int const ySouris);
+    void afficher();
+    bool estClique(int const xSouris, int const ySouris);
+
+    protected:
+    //Attributs standards
+    int m_x;
+    int m_y;
+
+    //Attributs SDL
+    SDL_Surface *m_screen;
+    SDL_Surface *m_objetImg;
+    SDL_Surface *m_selectImg;
+
+    SDL_Surface *m_blitImg;
+};
+
+#endif // BOUTON_H_INCLUDED

+ 226 - 0
Menu/gestionnaireNiveaux.cpp

@@ -0,0 +1,226 @@
+#include "gestionnaireNiveaux.h"
+
+GestionnaireNiveaux::GestionnaireNiveaux(SDL_Surface *screen):
+m_pageActuelle(0),m_estChoisi(false),m_choixJoueur("nothings"),m_screen(screen), m_font(0), m_pagePrecedente(0), m_pageSuivante(0)
+{
+    ///[1] Création des boutons
+    //[1.1] Changement de pages
+    m_pagePrecedente = new Bouton(SDL_LoadBMP("Images/gauche.bmp"), screen, 300-154, 560);
+    m_pageSuivante = new Bouton(SDL_LoadBMP("Images/droite.bmp"), screen, 300, 560);
+
+    //[1.2] Niveaux
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        m_tableauBoutons[i]=0;
+    }
+    allerALaPage(0);
+
+    ///[2] Attribution des secondes images
+    //[2.1] Changement de pages
+
+    //[2.2] Niveaux (pas besoin, fait dans allerPage())
+
+
+}///GestionnaireNiveaux()
+
+GestionnaireNiveaux::~GestionnaireNiveaux()
+{
+    ///[1] Nettoyage boutons
+    //[1.1] Changement de pages
+    delete(m_pagePrecedente);
+    delete(m_pageSuivante);
+
+    //[1.2] Niveaux
+    reinitialiserPage();
+
+}///~GestionnaireNiveaux()
+
+void GestionnaireNiveaux::calculer(int const xSouris, int const ySouris)
+{
+    bool selectOk(false);//Rien de selectionné
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        if (m_tableauBoutons[i]->calculer(xSouris,ySouris))
+        {
+            m_font=m_apercu[i];
+            selectOk=true;
+        }
+    }
+    if (!selectOk)//Rien de selectionné !
+        m_font=0;
+}///calculer(int const xSouris, int const ySouris)
+
+void GestionnaireNiveaux::afficher()
+{
+    ///[1] Affichage des boutons
+    //[1.0] Font
+    if (m_font!=0)
+        SDL_BlitSurface(m_font,0,m_screen,0);
+
+    //[1.1] Changeurs de pages
+    m_pagePrecedente->afficher();
+    m_pageSuivante->afficher();
+
+    //[1.2] Niveaux
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        m_tableauBoutons[i]->afficher();
+    }
+
+}///afficher(SDL_Surface* screen)
+
+void GestionnaireNiveaux::clic(int const xSouris, int const ySouris)
+{
+    ///Teste tous les boutons, si un bouton est cliqué,
+    ///appelez nomDuFichier puis modifier m_choixJoueur et m_estChoisi
+    //[1] Test du tableau de boutons
+    for (Uint8 i(0); i<NB_BOUTONS; i++)
+    {
+        if (m_tableauBoutons[i]->estClique(xSouris,ySouris))
+        {
+            std::cout << "Clic, niveau choisi: " << nomDuFichier(i) << std::endl;
+            if (m_apercu[i]!=0)
+            {
+                m_estChoisi=true;
+                m_choixJoueur=nomDuFichier(i);
+            }
+            else
+                std::cout << nomDuFichier(i) << " n'existe pas. Reste au menu. " << std::endl;
+        }
+    }
+
+	//[2] Tests des boutons de chgmt de page
+	if (m_pageSuivante->estClique(xSouris,ySouris))
+		allerALaPage(m_pageActuelle+1);
+	else if (m_pagePrecedente->estClique(xSouris,ySouris) && m_pageActuelle>0)
+		allerALaPage(m_pageActuelle-1);
+
+}///clic(int const xSouris, int const ySouris)
+
+bool GestionnaireNiveaux::estChoisi()
+{
+    return m_estChoisi;
+}///estChoisi()
+
+std::string GestionnaireNiveaux::getChoix()
+{
+    return m_choixJoueur;
+}///getChoix()
+
+/**---------------------------------FONCTIONS INTERNES---------------------------------**/
+
+void GestionnaireNiveaux::reinitialiserPage()
+{
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        //[1] Nettoyage boutons
+        if (m_tableauBoutons[i]!=0)
+            delete m_tableauBoutons[i];
+        m_tableauBoutons[i]=0;
+
+        //[2] Nettoyage aperçus
+        if (m_apercu[i]!=0)
+            SDL_FreeSurface(m_apercu[i]);
+        m_apercu[i]=0;
+    }
+}///reinitialiserPage()
+
+void GestionnaireNiveaux::allerALaPage(Uint32 numeroPage)
+{
+    //[0] Sécurité:
+    if (m_tableauBoutons[0]!=0)
+        reinitialiserPage();
+
+    //[1] Changement de page, toute !
+    m_pageActuelle=numeroPage;
+
+    //[2] Chargement des images !!!
+    SDL_Surface* apparence[NB_BOUTONS];
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        apparence[i]=SDL_LoadBMP("Images/boutonLevel.bmp");
+    }
+
+    SDL_Surface* surbrillance[NB_BOUTONS];
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        surbrillance[i]=SDL_LoadBMP("Images/boutonLevelB.bmp");
+    }
+
+    //[2bis] Chargement des textes et aperçus !
+    std::string nomNiveau[NB_BOUTONS];
+    std::string ajout;
+    Niveau maquette;
+
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        if (!maquette.creer(nomDuFichier(i)))//Niveau inexistant
+        {
+            nomNiveau[i]="NO_LVL";
+            m_apercu[i]=0;
+        }
+        else
+        {
+            ajout=convertirEntierEnCaracteres(m_pageActuelle*NB_BOUTONS+i+1);
+            nomNiveau[i]="Level "+ajout+" "+maquette.getNom();
+            m_apercu[i]=SDL_CreateRGBSurface(SDL_HWSURFACE,600,600,16,0,0,0,0);
+            maquette.afficher(m_apercu[i]);
+        }
+    }
+
+    //[3] Collage des textes !
+    SDL_Surface* texte[NB_BOUTONS];
+    SDL_Rect position;
+    position.x=20;
+    position.y=4;
+    SDL_Rect positionB;
+    positionB.x=position.x+2;
+    positionB.y=position.y+1;
+
+    SDL_Color bleu={0,0,200};
+
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        texte[i]=transform(nomNiveau[i],25,bleu);
+
+        SDL_BlitSurface(texte[i], 0, apparence[i], &position);
+        SDL_BlitSurface(texte[i], 0, surbrillance[i], &positionB);
+    }
+
+    //[4] Création des boutons !!!
+    int y(80);
+    int x(300-276-7);
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        if (i==8)//Deuxième colonne !
+        {
+            x=300+7;
+            y=80;
+        }
+
+        m_tableauBoutons[i]=new Bouton(apparence[i], m_screen, x, y);
+        y+=38+16;
+
+        m_tableauBoutons[i]->attribuerImg(surbrillance[i]);
+    }
+
+    //[5] On nettoie les déchets
+    for (int i(0); i<NB_BOUTONS; i++)
+    {
+        SDL_FreeSurface(texte[i]);
+    }
+
+}///allerALaPage(Uint32 numeroPage)
+
+std::string GestionnaireNiveaux::nomDuFichier(Uint8 IDTab)
+{
+    //[1] Quel niveau selectionné ?
+    int numLvl;
+    numLvl=m_pageActuelle*NB_BOUTONS+IDTab+1;
+
+    //[2] Renvoi
+    return "level "+convertirEntierEnCaracteres(numLvl)+".txt";
+
+}///nomDuFichier(Uint8 IDTab)
+
+

+ 83 - 0
Menu/gestionnaireNiveaux.h

@@ -0,0 +1,83 @@
+#ifndef GESTIONNAIRENIVEAUX_H_INCLUDED
+#define GESTIONNAIRENIVEAUX_H_INCLUDED
+
+#include <fstream>
+
+#include "Bouton.h"
+#include "transform.h"//Pour les aperçus
+
+#include "../Niveau.h"
+
+///GestionnaireNiveaux.h
+///Date de modification: 03_02_2014
+///Objet: adaptation au projet PacMen, placement des boutons
+///Prochaine étape: nouvelles textures pour l'interface
+
+#define NB_BOUTONS 16
+
+/*
+===La classe GestionnaireNiveaux===
+    +Définition:
+        Elle permet d'afficher les niveaux disponibles, sous forme d'icones. Elle donne le nom du
+        fichier du niveau choisi par le joueur utilisé par la fonction jeu par la suite.
+        Le gestionnaire Niveaux affiche seize icones représentant chacune un niveau, deux boutons
+        pour changer de page.
+    +Méthodes:
+        - Constructeur:
+            Permet de créer le gestionnaire en donnant la surface d'écran.
+
+        - calculer:
+            Permet de renseigner les coordonnées de la souris pour mettre en surbrillance les boutons.
+
+        - afficher:
+            Permet d'afficher l'interface des niveaux.
+
+        - clic:
+            Lorsqu'un clic se déclenche, permet de donner sa position.
+
+        - estChoisi:
+            Retourne vrai dès que l'utilisateur a choisi un niveau.
+
+        - getChoix:
+            Retourne dans un string le nom du fichier niveau à lancer.
+
+        - {PROTECTED} allerALaPage:
+            Permet de charger une page lorsque le bouton est utilisé. Géré en interne.
+
+        - {PROTECTED} nomDuFichier:
+            Permet de connaître le nom du fichier d'un élément du tableau en lui filant l'identifiant.
+
+*/
+
+class GestionnaireNiveaux
+{
+    public:
+    GestionnaireNiveaux(SDL_Surface *screen);
+    ~GestionnaireNiveaux();
+    void calculer(int const xSouris, int const ySouris);
+    void afficher();
+    void clic(int const xSouris, int const ySouris);
+    bool estChoisi();
+    std::string getChoix();
+
+    protected: //Fonctions internes
+    void reinitialiserPage();
+    void allerALaPage(Uint32 numeroPage);
+    std::string nomDuFichier(Uint8 IDTab);
+
+    private:
+    Bouton* m_tableauBoutons[NB_BOUTONS];
+    SDL_Surface* m_apercu[NB_BOUTONS];
+    SDL_Surface* m_font;
+    Bouton* m_pagePrecedente;
+    Bouton* m_pageSuivante;
+    Uint32 m_pageActuelle;
+
+    bool m_estChoisi;
+    std::string m_choixJoueur;
+
+    SDL_Surface* m_screen;
+};
+
+
+#endif // GESTIONNAIRENIVEAUX_H_INCLUDED

+ 81 - 0
Menu/menu.cpp

@@ -0,0 +1,81 @@
+#include "menu.h"
+
+std::string menu(SDL_Surface* screen)
+{
+    /// [1] Lancement du menu
+
+    // [1.3] Préparation des objets
+    std::string retour("quitter");
+
+    SDL_Surface *titre(0);
+    SDL_Rect positionTitre;
+
+    SDL_Color blanc = {255,255,255};
+    Bouton quitButton(transform("Quit", 30), screen, screen->w-80, screen->h-50);
+    quitButton.attribuerImg(transform("Quit", 30, blanc));
+
+    // [1.4] Préparation du texte
+    titre = transform("-^*.PacMen _ stage select.*^-", 40);
+    positionTitre.x = screen->w/2-titre->w/2;
+    positionTitre.y = 20;
+
+    // [1.5] Préparation du gestionnaireNiveaux
+    GestionnaireNiveaux interface(screen);
+
+    /// [2] Boucle principale évenementielle
+    bool done = false;
+    while (!done)
+    {
+        // [2.1] Gestion évènements
+        SDL_Event event;
+        while (SDL_PollEvent(&event))
+        {
+            switch (event.type)
+            {
+            case SDL_QUIT:
+                done = true;
+                break;
+            case SDL_KEYDOWN:
+                if (event.key.keysym.sym == SDLK_ESCAPE)
+                    done = true;
+                break;
+            case SDL_MOUSEMOTION:
+                quitButton.calculer(event.motion.x,event.motion.y);
+                interface.calculer(event.motion.x,event.motion.y);
+                break;
+            case SDL_MOUSEBUTTONUP:
+                if (event.button.button==SDL_BUTTON_LEFT)
+                {
+                    if (quitButton.estClique(event.button.x,event.button.y))
+                        done = true;
+                    else
+                        interface.clic(event.button.x,event.button.y);
+                }
+                break;
+            } // end switch event type
+        } // end of message processing
+
+        // [2.2] Calculs
+        if (interface.estChoisi())
+        {
+            done=true;
+            retour=interface.getChoix();
+        }
+
+        // [2.3] Dessin des composants
+        SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 128, 100, 255));
+
+        interface.afficher();
+        SDL_BlitSurface(titre, 0, screen, &positionTitre);
+        quitButton.afficher();
+
+        SDL_Flip(screen);
+    } //fin bcl principale
+
+    ///[4] Destruction des composants
+    SDL_FreeSurface(titre);
+
+    std::cout << "menu.cpp: Aucune erreur détectée." << std::endl;
+    return retour;
+};
+

+ 28 - 0
Menu/menu.h

@@ -0,0 +1,28 @@
+#ifndef MENU_H_INCLUDED
+#define MENU_H_INCLUDED
+
+///menu.h
+///Date de modification: 4_2_2014
+///Objet: ecran 600*600
+///Prochaine étape:
+
+#include "Bouton.h"
+#include "transform.h"
+#include "gestionnaireNiveaux.h"
+
+/*
+-Rôle de menu.h:
+        La fonction menu permet d'afficher la liste des niveaux disponibles. Lorsque le joueur a chosi
+    le niveau à lancer, le menu retourne le nom du fichier correspondant. Si il a quitté, le
+    string est "quitter".
+
+-Fichiers inclus:
+	+Bouton.h:
+		Fichier contenant de quoi créer des boutons.
+    +transform.h:
+		Permet de créer des SDL surfaces à partir de string.
+*/
+
+std::string menu(SDL_Surface* screen);
+
+#endif // MENU_H_INCLUDED

+ 51 - 0
Menu/transform.cpp

@@ -0,0 +1,51 @@
+#include "transform.h"
+
+SDL_Surface* transform(std::string const chaine, int const taille, SDL_Color couleur)
+{
+    // [1] Préparation du texte
+    TTF_Font *police(0);
+    police = TTF_OpenFont("Polices/droid.ttf",taille);
+
+    // [2] Assignation de la surface
+    SDL_Surface *texte(0);
+    texte = TTF_RenderText_Blended(police, chaine.c_str(),couleur);
+
+    // [3] Fermeture
+    TTF_CloseFont(police);
+
+    // [4] Retourne la surface
+    return texte;
+}
+
+SDL_Surface* transform(std::string const chaine, int const taille)
+{
+    SDL_Color couleurNoire = {0,0,0};
+    return transform(chaine,taille,couleurNoire);
+}
+
+SDL_Surface* transform(std::string const chaine)
+{
+    return transform(chaine,20);
+}
+
+std::string convertirEntierEnCaracteres(int numero)
+{
+    //[1]Préaparer
+    std::string resultat;
+    char caractere(0);
+
+    //[2]S'auto appeler
+    caractere=numero%10;
+    caractere=caractere+48;
+    numero/=10;
+
+    if (numero!=0)
+        resultat=convertirEntierEnCaracteres(numero);
+
+    resultat+=caractere;
+
+
+    //[3]Renvoi
+    return resultat;
+}///convertirEntierEnCaracteres(int numero)
+

+ 30 - 0
Menu/transform.h

@@ -0,0 +1,30 @@
+#ifndef TRANSFORM_H_INCLUDED
+#define TRANSFORM_H_INCLUDED
+
+///Modifié le: 10/10/2013
+///Objet: ajout de la fonction cpnvertirIntEnCaracteres
+
+#include <iostream>
+#include <string>
+
+#include <SDL/SDL.h>
+#undef main
+
+#include <SDL/SDL_ttf.h>
+
+/*
+===La fonction transform===
+    +Définition:
+        Elle permet de convertir un string en SDL_Surface. Attention ! Stocker la valeur retournée dans
+        un pointeur et n'oubliez pas le SDL_FreeSurface ! Sinon, risque de fuite de mémoire.
+
+*/
+
+SDL_Surface* transform(std::string const chaine, int const taille, SDL_Color couleur);
+SDL_Surface* transform(std::string const chaine, int const taille);
+SDL_Surface* transform(std::string const chaine);
+
+std::string convertirEntierEnCaracteres(int numero);
+
+
+#endif // TRANSFORM_H_INCLUDED

+ 438 - 0
Niveau.cpp

@@ -0,0 +1,438 @@
+#include "Niveau.h"
+
+Niveau::Niveau():m_font(0),m_items(0),m_nom("Sans Nom"),m_nomFichier(""),m_lvlNumber(0),m_effectifItems(0)
+{
+    m_font = SDL_CreateRGBSurface(SDL_HWSURFACE, 600, 600, 32, 0, 0, 0, 0);
+    m_items = SDL_CreateRGBSurface(SDL_HWSURFACE, 600, 600, 32, 0, 0, 0, 0);
+    reset();
+}
+
+Niveau::Niveau(std::string nomFichier, Uint16 fraction):m_font(0),m_items(0),m_nom("Sans Nom"),m_nomFichier(""),m_lvlNumber(0),m_effectifItems(0)
+{
+    m_font = SDL_CreateRGBSurface(SDL_HWSURFACE, 600, 600, 32, 0, 0, 0, 0);
+    m_items = SDL_CreateRGBSurface(SDL_HWSURFACE, 600, 600, 32, 0, 0, 0, 0);
+
+    if (!creer(nomFichier,fraction))//Si impossible de créer le niveau ...
+        reset();//On le formate. Utile pour l'éditeur, mais impossible à jouer. ;-)
+}
+
+Niveau::~Niveau()
+{
+    SDL_FreeSurface(m_font);
+    SDL_FreeSurface(m_items);
+}
+
+int Niveau::peindreFont(Uint16 fraction)
+{
+    /// [1] Mettre au point les surfaces
+    // [A] Couleur de m_font en rouge + blanc
+    Uint32 fontColor(8388608);//rouge foncé 32 bits
+    SDL_FillRect(m_font,NULL,fontColor);
+    Uint32 blanc(SDL_MapRGB(m_font->format,255,255,255));
+
+    // [B] Surface de colle en rouge et mur_gomme en blanc
+    SDL_Surface* fontCopie = SDL_CreateRGBSurface(SDL_HWSURFACE, m_font->w, m_font->h, 32, 0, 0, 0, 0);
+    SDL_Surface* mur = SDL_CreateRGBSurface(SDL_HWSURFACE, LG_BLOC, LG_BLOC, 32, 0, 0, 0, 0);
+    SDL_FillRect(fontCopie,NULL,fontColor);
+    SDL_FillRect(mur,NULL,blanc);
+    SDL_Rect pos={0,0,0,0};
+
+    // [C] Préparation au gommage
+    if (fraction==0 || LG_BLOC%fraction!=0)
+    {
+        std::cout << "Objet Niveau: argument non renseigné ou non-multiple de " << LG_BLOC << std::endl;
+        fraction=5;
+    }
+    Uint16 coteGum(LG_BLOC/fraction);
+    SDL_Surface* gomme = SDL_CreateRGBSurface(SDL_HWSURFACE,coteGum, coteGum, 32, 0, 0, 0, 0);
+    SDL_FillRect(gomme,NULL,fontColor);
+
+    // [D] Chargement des textures
+    SDL_Surface* solTexture = SDL_LoadBMP("Textures/planks.bmp");
+    SDL_Surface* murTexture = SDL_LoadBMP("Textures/cobblestone.bmp");
+    SDL_Surface* plaqueSprite = SDL_LoadBMP("Textures/plaque.bmp");
+    SDL_Surface* spawnAllieImg = SDL_LoadBMP("Textures/spawnAllie.bmp");
+    SDL_Surface* spawnFantomImg = SDL_LoadBMP("Textures/spawnFantom.bmp");
+    if (solTexture==0 || murTexture==0 || plaqueSprite==0 || spawnAllieImg==0 || spawnFantomImg==0)
+    {
+        std::cout << "Problème de chargement de texture dans l'objet Niveau, dans textures." << std::endl;
+        return 1;
+    }
+    SDL_SetColorKey(plaqueSprite,SDL_SRCCOLORKEY,blanc);
+    SDL_SetColorKey(spawnAllieImg,SDL_SRCCOLORKEY,blanc);
+    SDL_SetColorKey(spawnFantomImg,SDL_SRCCOLORKEY,blanc);
+
+    // [E] Application des textures
+    SDL_Surface* fullMur = SDL_CreateRGBSurface(SDL_HWSURFACE,600,600, 32, 0, 0, 0, 0);
+    for (int i(0); i<600; i++)
+    {
+        for (int j(0); j<600; j++)
+        {
+            //Collage du sol sur m_font
+            pos.x=i*solTexture->w;
+            pos.y=j*solTexture->h;
+            SDL_BlitSurface(solTexture, 0, m_font, &pos);
+
+            //Collage du mur sur fullMur
+            pos.x=i*murTexture->w;
+            pos.y=j*murTexture->h;
+            SDL_BlitSurface(murTexture, 0, fullMur, &pos);
+        }
+    }
+
+    /// [2] Dessiner la surface de niveau sur la copie du fond
+    const int largeurTabl(LG_BLOC/coteGum);
+    //Balayage du terrain
+    for (int y(0); y<LG_TABL; y++)
+    {
+        for (int x(0); x<LG_TABL; x++)
+        {
+            //Collage si besoin sur m_font
+            if (m_tabl[y][x]==PLAQUE)
+            {
+                pos.x=x*LG_BLOC+(LG_BLOC-plaqueSprite->w)/2;
+                pos.y=y*LG_BLOC+(LG_BLOC-plaqueSprite->h);
+                SDL_BlitSurface(plaqueSprite,0,m_font,&pos);
+            }
+            if (m_tabl[y][x]==SPAWN_ALLIE)
+            {
+                pos.x=x*LG_BLOC+(LG_BLOC-spawnAllieImg->w)/2;
+                pos.y=y*LG_BLOC+(LG_BLOC-spawnAllieImg->h)/2;
+                SDL_BlitSurface(spawnAllieImg,0,m_font,&pos);
+            }
+            if (m_tabl[y][x]==SPAWN_PHANTOM)
+            {
+                pos.x=x*LG_BLOC+(LG_BLOC-spawnFantomImg->w)/2;
+                pos.y=y*LG_BLOC+(LG_BLOC-spawnFantomImg->h)/2;
+                SDL_BlitSurface(spawnFantomImg,0,m_font,&pos);
+            }
+            //Collage du mur en entier sur fontCopie
+            if (m_tabl[y][x]==MUR)
+            {
+                pos.x=x*LG_BLOC;
+                pos.y=y*LG_BLOC;
+                SDL_BlitSurface(mur, 0, fontCopie, &pos);
+
+                //Ajustement mur
+                for (int i(0); i<largeurTabl; i++)//x
+                {
+                    for (int j(0); j<largeurTabl; j++)//y
+                    {
+                        //Inventaire des parties à conserver
+                        short dirx,diry;//permet de savoir où regarder autour
+                        if (i==0)
+                            dirx=-1;
+                        else if (i==largeurTabl-1)
+                            dirx=1;
+                        else
+                            dirx=0;
+                        if (j==0)
+                            diry=-1;
+                        else if (j==largeurTabl-1)
+                            diry=1;
+                        else
+                            diry=0;
+                        //Gommage des parties inutiles
+
+                        if (typeBloc(x+dirx,y+diry)!=MUR || typeBloc(x+dirx,y)!=MUR || typeBloc(x,y+diry)!=MUR)
+                        {
+                            pos.x=x*LG_BLOC+i*coteGum;
+                            pos.y=y*LG_BLOC+j*coteGum;
+                            SDL_BlitSurface(gomme, 0, fontCopie, &pos);
+                        }
+                    }
+                }//[END for] Ajustement mur
+            }//[END if] Collage du mur en entier
+        }
+    }//[END for] Balayage du terrain
+
+    /// [3] Finalisation des textures
+    //Mise en place texture des murs
+    SDL_SetColorKey(fontCopie, SDL_SRCCOLORKEY, blanc);//mur en transparence
+    SDL_BlitSurface(fontCopie, 0, fullMur, 0);//colle le tracé du sol sur fullMur
+    SDL_SetColorKey(fullMur,SDL_SRCCOLORKEY,fontColor);//met le sol transparent
+
+    //Coller les murs sur m_font
+    SDL_BlitSurface(fullMur, 0, m_font, 0);
+
+    /// [4] Nettoyer
+    SDL_FreeSurface(murTexture);
+    SDL_FreeSurface(solTexture);
+    SDL_FreeSurface(plaqueSprite);
+    SDL_FreeSurface(mur);
+    SDL_FreeSurface(fontCopie);
+    SDL_FreeSurface(gomme);
+    SDL_FreeSurface(fullMur);
+    SDL_FreeSurface(spawnAllieImg);
+    SDL_FreeSurface(spawnFantomImg);
+
+    return 0;
+}
+
+bool Niveau::creer(std::string nomFichier, Uint16 fraction)
+{
+    /// [0] Mise au point du nom du fichier
+    nomFichier="Niveaux/"+nomFichier;
+    m_nomFichier=nomFichier;
+
+    /// [1] Ouverture du flux
+    std::ifstream fluxIn(nomFichier.c_str());
+    if (!fluxIn)
+    {
+        std::cout << "Echec de l'ouverture du fichier : "<<nomFichier<<"."<<std::endl;
+        return false;
+    }
+    else
+    {
+        std::cout << "Ouverture du fichier "<<nomFichier<<" réussie."<<std::endl;
+
+        /// [2] Remplissage du niveau
+        getline(fluxIn,m_nom);
+        fluxIn >> m_lvlNumber;
+        for (int y(0); y<LG_TABL; y++)
+        {
+            for (int x(0); x<LG_TABL; x++)
+            {
+                fluxIn >> m_tabl[y][x];
+                if (m_tabl[y][x] == SPAWN_ALLIE)
+                {
+                    m_spawnAllie[Y] = y;
+                    m_spawnAllie[X] = x;
+                }
+                else if (m_tabl[y][x] < 0)
+                {
+                    m_spawnPhantom[Y] = y;
+                    m_spawnPhantom[X] = x;
+                    m_effectifMobs = -m_tabl[y][x];
+                    m_tabl[y][x] = SPAWN_PHANTOM;
+                }
+            }
+        }
+    }
+
+    /// [3] Peindre la surface du niveau
+    if (peindreFont(fraction)==1)
+        std::cout << "Problème dans la fonction peindreFont() dans niveau." << std::endl;
+
+    /// [4] Mettre les items
+    remplirItems();
+
+    /// [5] Tout va bien !
+    return true;
+}
+
+void Niveau::afficher(SDL_Surface* support, bool hideItem)
+{
+    SDL_BlitSurface(m_font, 0, support, 0);
+    if (!hideItem)
+        SDL_BlitSurface(m_items, 0, support, 0);
+}
+
+void Niveau::remplirItems()
+{
+    //Création de la position SDL
+    SDL_Rect pos = {0,0,0,0};
+
+    //Charger les textures
+    SDL_FillRect(m_items,0,0);
+    SDL_Surface* steackImg = SDL_LoadBMP("Textures/steak.bmp");
+    SDL_Surface* tonneauImg = SDL_LoadBMP("Textures/tonneau.bmp");
+    if (steackImg==0 || tonneauImg==0)
+        std::cout << "Problème de chargement de texture dans l'objet Niveau, dans items." << std::endl;
+
+    //Parcours du tableau
+    m_effectifItems=0;
+    for (int x(0); x<LG_TABL; x++)
+        for (int y(0); y<LG_TABL; y++)
+        {
+            //Teste le terrain
+            if (m_tabl[y][x]==RIEN)
+            {
+                //Renseigne la présence du steack
+                m_itemTabl[y][x]=STEACK;
+                m_effectifItems++;
+
+                //Modifie la surface
+                pos.x=x*LG_BLOC+(LG_BLOC-steackImg->w)/2;
+                pos.y=y*LG_BLOC+(LG_BLOC-steackImg->h)/2;
+                SDL_BlitSurface(steackImg, 0, m_items, &pos);
+            }
+            else if (m_tabl[y][x]==PLAQUE)
+            {
+                //Renseignela présence du tonneau
+                m_itemTabl[y][x]=TONNEAU;
+                m_effectifItems++;
+
+                //Modifie la surface
+                pos.x=x*LG_BLOC+(LG_BLOC-tonneauImg->w)/2;
+                pos.y=y*LG_BLOC+(LG_BLOC-tonneauImg->h)/2;
+                SDL_BlitSurface(tonneauImg, 0, m_items, &pos);
+            }
+            else//Renseigne l'absence d'item
+                m_itemTabl[y][x]=VIDE;
+        }
+
+    //Met au point la surface des items
+    SDL_SetColorKey(m_items,SDL_SRCCOLORKEY,0);
+
+    //Nettoyer la texture
+    SDL_FreeSurface(steackImg);
+    SDL_FreeSurface(tonneauImg);
+}
+
+short Niveau::typeBloc(int x, int y, bool coordonee)
+{
+	///Adapter les coordonnées si besoin
+    if(coordonee)
+    {
+        x /= LG_BLOC;
+        y /= LG_BLOC;
+    }
+	///Accès sécurisé au tableau
+    if (x<0 || x>=LG_TABL || y>=LG_TABL || y<0)
+       return MUR;
+    else
+        return m_tabl[y][x];
+}
+
+short Niveau::takeItem(int x, int y, bool coordonee)
+{
+    ///Adapter les coordonnées si besoin
+    if(coordonee)
+    {
+        x /= LG_BLOC;
+        y /= LG_BLOC;
+    }
+	///Accès sécurisé au tableau
+    if (x<0 || x>=LG_TABL || y>=LG_TABL || y<0)
+    {
+        std::cout << "Attention: demande d'une case de tableau inexistante avec typeItem()" << std::endl;
+        return VIDE;
+    }
+    else
+    {
+        //Recupere l'item
+        short butin(m_itemTabl[y][x]);
+        m_itemTabl[y][x]=VIDE;
+
+        if (butin!=VIDE)
+        {
+            //Gommage de l'item
+            SDL_Surface* gomme = SDL_CreateRGBSurface(SDL_HWSURFACE, LG_BLOC, LG_BLOC, 32, 0, 0, 0, 0);
+            SDL_Rect pos = {0,0,0,0};
+            pos.x=x*LG_BLOC;
+            pos.y=y*LG_BLOC;
+            SDL_BlitSurface(gomme,0,m_items,&pos);
+            SDL_SetColorKey(m_items,SDL_SRCCOLORKEY,0);
+            SDL_FreeSurface(gomme);
+
+            //Retire un objet
+            m_effectifItems--;
+        }
+
+        //Retour
+        return butin;
+    }
+}
+
+
+int Niveau::itemsRestants()
+{
+    return m_effectifItems;
+}
+
+
+int Niveau::popFantom(axe choisi)
+{
+    if (choisi == X)
+        return m_spawnPhantom[X];
+    else if (choisi == Y)
+        return m_spawnPhantom[Y];
+    else
+        return EXIT_FAILURE;
+}
+
+int Niveau::popAllie(axe choisi)
+{
+    if (choisi == X)
+        return m_spawnAllie[X];
+    else if (choisi == Y)
+        return m_spawnAllie[Y];
+    else
+        return EXIT_FAILURE;
+}
+
+int Niveau::getEffectifMobs()
+{
+    return m_effectifMobs;
+}
+
+
+std::string Niveau::getNom()
+{
+    return m_nom;
+}
+
+void Niveau::save(int effectifPhantom)
+{
+    std::cout << "Demande de sauvegarde du niveau: " << m_nomFichier << std::endl;
+    std::ofstream ecriture(m_nomFichier.c_str());
+    if (ecriture)
+    {
+        ecriture << m_nom << std::endl;
+        ecriture << m_lvlNumber;
+        for (int y(0); y<LG_TABL; y++)
+        {
+            ecriture << std::endl;
+            for (int x(0); x<LG_TABL; x++)
+            {
+                if (m_tabl[y][x]==SPAWN_PHANTOM)
+                    ecriture << -effectifPhantom;
+                else
+                    ecriture << m_tabl[y][x];
+                ecriture << " ";
+            }
+        }
+    }
+    else
+        std::cout << "La sauvegarde a échoué." << std::endl;
+}
+
+void Niveau::placeBloc(short blocChoisi, int x, int y, Uint32 couleur, bool coordonee)
+{
+    ///Adapter les coordonnées si besoin
+    if(coordonee)
+    {
+        x /= LG_BLOC;
+        y /= LG_BLOC;
+    }
+
+    ///Modifier le tableau numérique
+    if (x>=0 && x<LG_TABL && y>=0 && y<LG_TABL)
+        m_tabl[y][x]=blocChoisi;
+
+    ///Modifier l'image
+    SDL_Surface* carreColore = SDL_CreateRGBSurface(SDL_HWSURFACE, LG_BLOC, LG_BLOC, 32, 0, 0, 0, 0);
+    SDL_FillRect(carreColore,NULL,couleur);
+    SDL_Rect position;
+    position.x = x*LG_BLOC;
+    position.y = y*LG_BLOC;
+    SDL_BlitSurface(carreColore, 0, m_font, &position);
+    SDL_FreeSurface(carreColore);
+}
+
+void Niveau::reset()
+{
+    //Remplir de murs
+    for (int y(0); y<LG_TABL; y++)
+        for (int x(0); x<LG_TABL; x++)
+            m_tabl[y][x]=MUR;
+
+    //Peindre les murs
+    if (peindreFont(5)==1)
+        std::cout << "Problème dans la fonction peindreFont() dans niveau." << std::endl;
+}
+
+
+
+

+ 70 - 0
Niveau.h

@@ -0,0 +1,70 @@
+#ifndef NIVEAU_H_INCLUDED
+#define NIVEAU_H_INCLUDED
+
+/**
+Projet: PacMen
+Programmeur: Jovian Hersemeule
+
+Date de dernière modification: 7 fevrier 2014
+Objet: ajout attribut m_nomFichier, le constructeur créé un niveau MEME si fichier absent + fonction reset
+Prochaine étape:
+*/
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <SDL/SDL.h>
+#undef main
+
+#define LG_BLOC 30
+#define LG_TABL 20
+
+enum axe {Y=0,X=1};
+enum bloc {RIEN=0,MUR=1,PLAQUE=2,SPAWN_ALLIE=3,SPAWN_PHANTOM=4};
+enum item {VIDE=0,STEACK=1,TONNEAU=2};
+
+class Niveau
+{
+    public:
+
+    Niveau();//Niveau vide
+    Niveau(std::string nomFichier, Uint16 fraction = 0);//Appelle automatiquement creer()
+    ~Niveau();
+
+    //Fonctions générales
+    int peindreFont(Uint16 fraction);
+    bool creer(std::string nomFichier, Uint16 fraction = 0);//Charge un niveau
+    void afficher(SDL_Surface* support, bool hideItem=0);//Coller les surfaces de terrain (et les items si besoin)
+
+    //Fonctions de jeu
+    void remplirItems();//Pose les steaks par terre
+    short typeBloc(int x, int y, bool coordonee = 0);//Tester la présence d'un mur (coordonnee true si x et y en nb de pixels)
+    short takeItem(int x, int y, bool coordonee = 0);//Tester la présence d'un item
+    int itemsRestants();//Renvoie le nombre d'items (tonneaux et stecks cofondus) restants
+    int popFantom(axe choisi);//Utiliser l'enum pour choisir entre abscisse ou ordonnée
+    int popAllie(axe choisi);//Exemple: int x = popAllie(X);
+    int getEffectifMobs();//Retourne le nombre de fantômes du niveau
+
+    //Fonctions d'édition
+    std::string getNom();//Retourne l'appellation du niveau
+    void save(int effectifPhantom);//Sauvegarde le niveau dans le fichier
+    void placeBloc(short blocChoisi, int x, int y, Uint32 couleur, bool coordonee = 0);//Modifie un bloc dans le niveau
+    void reset();//Recouvre en totzlité le niveau de pierre
+
+
+    private:
+
+    SDL_Surface* m_font;
+    SDL_Surface* m_items;
+    std::string m_nom;
+    std::string m_nomFichier;
+    int m_lvlNumber;
+    short m_itemTabl[LG_TABL][LG_TABL];//[y;x]
+    short m_tabl[LG_TABL][LG_TABL];//[y;x]
+    int m_effectifItems;
+    short m_effectifMobs;//Se manifeste dans .txt par un nombre négatif, valeur absolue = nb mobs
+    int m_spawnPhantom[2];//y x
+    int m_spawnAllie[2];//y x
+};
+
+#endif // NIVEAU_H_INCLUDED

+ 22 -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

@@ -0,0 +1,101 @@
+#include "Ogre.h"
+
+Ogre::Ogre(Input *input, Niveau *terrain, Controle controle): Joueur(input, terrain, controle), m_berzerk(false), m_timeBerzerk(0)
+{
+    m_skin = IMG_Load("Skins/Ogre.png");
+    if(m_skin == 0)
+        std::cout << "Erreur de chargement du skin Skins/Ogre.png" << std::endl;
+    m_skinBerzerk = IMG_Load("Skins/OgreBerzerk.png");
+    if(m_skinBerzerk == 0)
+        std::cout << "Erreur de chargement du skin Skins/OrgeBerzerk.png" << std::endl;
+}
+Ogre::~Ogre()
+{
+    SDL_FreeSurface(m_skin);
+    SDL_FreeSurface(m_skinBerzerk);
+}
+
+
+void Ogre::deplacer()
+{
+    if(m_controle == local || m_controle == ordi)
+    {
+        if(m_input->getTouches(SDLK_w) && m_direction!=Bas)
+            m_nouvDir = Haut;
+        else if(m_input->getTouches(SDLK_d) && m_direction!=Gauche)
+            m_nouvDir = Droite;
+        else if(m_input->getTouches(SDLK_s) && m_direction!=Haut)
+            m_nouvDir = Bas;
+        else if(m_input->getTouches(SDLK_a) && m_direction!=Droite)
+            m_nouvDir = Gauche;
+    }
+    for(int re = 0;re<VITESSE_BERZERK;re++)
+    {
+        int posX = m_pos.x + (m_skin->w-LG_BLOC)/2;
+        int posY = m_pos.y + (m_skin->h-LG_BLOC)/2;
+        int dirPossible = Arret;
+         if(m_terrain->typeBloc(posX-1, posY, 1) != MUR && m_terrain->typeBloc(posX-1, posY+LG_BLOC-1, 1) != MUR)
+                dirPossible |= Gauche;
+         if(m_terrain->typeBloc(posX+LG_BLOC, posY, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC, posY+LG_BLOC-1, 1) != MUR)
+                dirPossible |= Droite;
+         if(m_terrain->typeBloc(posX, posY-1, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY-1, 1) != MUR)
+                dirPossible |= Haut;
+         if(m_terrain->typeBloc(posX, posY+LG_BLOC, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY+LG_BLOC, 1) != MUR)
+                dirPossible |= Bas;
+
+        if(dirPossible & m_nouvDir)
+            m_direction = m_nouvDir;
+
+        if(dirPossible & m_direction)
+        {
+            m_pos+=m_direction;
+            posX = m_pos.x + (m_skin->w-LG_BLOC)/2;
+            posY = m_pos.y + (m_skin->h-LG_BLOC)/2;
+        }
+        else if((!(dirPossible&Haut) && !(dirPossible&Bas) && (m_direction == Gauche || m_direction == Droite)) ||
+                (!(dirPossible&Gauche) && !(dirPossible&Droite) && (m_direction == Haut || m_direction == Bas)))
+        {
+            m_direction = m_direction==Gauche?Droite:m_direction==Droite?Gauche:m_direction==Haut?Bas:Haut;
+            m_nouvDir = m_direction;
+        }
+        if(SDL_GetTicks()-m_timeBerzerk>TEMPS_BERZERK)
+            m_berzerk = false;
+        if(m_terrain->takeItem(posX, posY, 1) == TONNEAU)
+        {
+            m_berzerk = true;
+            m_timeBerzerk = SDL_GetTicks();
+        }
+        if(m_berzerk == false)
+            break;
+    }
+}
+
+bool Ogre::getBerzerk()
+{
+    return m_berzerk;
+}
+
+void Ogre::afficher(SDL_Surface *ecran)
+{
+    if(m_berzerk)
+        SDL_BlitSurface(m_skinBerzerk, 0, ecran, &m_pos);
+    else
+        SDL_BlitSurface(m_skin, 0, ecran, &m_pos);
+}
+void Ogre::positionner(SDL_Rect position, bool coordonnee)
+{
+    if(coordonnee)
+    {
+        m_pos.x = position.x;
+        m_pos.y = position.y;
+    }
+    else
+    {
+        m_pos.x = position.x*LG_BLOC - (m_skin->w-LG_BLOC)/2;
+        m_pos.y = position.y*LG_BLOC - (m_skin->h-LG_BLOC)/2;
+    }
+    m_direction = Arret;
+    m_berzerk = false;
+    m_timeBerzerk = 0;
+}
+

+ 26 - 0
Ogre.h

@@ -0,0 +1,26 @@
+#ifndef OGRE_H
+#define OGRE_H
+
+#include "Joueur.h"
+#include "Input.h"
+
+#define TEMPS_BERZERK 10000
+#define VITESSE_BERZERK 2
+
+class Ogre : public Joueur
+{
+public:
+    Ogre(Input *input, Niveau *terrain, Controle controle = local);
+    ~Ogre();
+    void deplacer();
+    void afficher(SDL_Surface *ecran);
+    bool getBerzerk();
+    void positionner(SDL_Rect position, bool coordonnee = false);
+
+protected:
+    SDL_Surface *m_skinBerzerk;
+    bool m_berzerk;
+    Uint32 m_timeBerzerk;
+};
+
+#endif // OGRE_H

+ 49 - 0
Personnage.cpp

@@ -0,0 +1,49 @@
+#include "Personnage.h"
+
+SDL_Rect operator+=(SDL_Rect &pos, Direction dir)
+{
+    switch(dir)
+    {
+        case Arret:
+            break;
+        case Haut:
+            pos.y -= 1;
+            break;
+        case Droite:
+            pos.x += 1;
+            break;
+        case Bas:
+            pos.y += 1;
+            break;
+        case Gauche:
+            pos.x -= 1;
+            break;
+    }
+    return pos;
+}
+
+void Personnage::afficher(SDL_Surface *ecran)
+{
+    SDL_BlitSurface(m_skin, 0, ecran, &m_pos);
+}
+SDL_Rect Personnage::getPosition(bool coordonnee)
+{
+    if(coordonnee)
+        return m_pos;
+    else
+    {
+        SDL_Rect pos;
+        pos.x = m_pos.x+(m_skin->w-LG_BLOC)/2+LG_BLOC/2;
+        pos.x /= LG_BLOC;
+        pos.y = m_pos.y+(m_skin->h-LG_BLOC)/2+LG_BLOC/2;
+        pos.y /= LG_BLOC;
+        return pos;
+    }
+}
+bool operator==(SDL_Rect pos1, SDL_Rect pos2)
+{
+    if(pos1.x==pos2.x && pos1.y==pos2.y)
+        return true;
+    else
+        return false;
+}

+ 36 - 0
Personnage.h

@@ -0,0 +1,36 @@
+#ifndef PERSONNAGE_H_INCLUDED
+#define PERSONNAGE_H_INCLUDED
+#include <iostream>
+#include <SDL/SDL.h>
+#undef main
+#include <SDL/SDL_image.h>
+#include "Niveau.h"
+#include <vector>
+#include <cstdlib>
+#include <cmath>
+
+enum Direction {Arret = 0, Haut = 1, Droite = 2, Bas = 4, Gauche = 8};
+enum Controle {local, ordi, distant};
+
+//static int vitesse = 1;// pour changer l'incrementation du a l'operateur +=
+SDL_Rect operator+=(SDL_Rect &pos, Direction dir);
+bool operator==(SDL_Rect pos1, SDL_Rect pos2);
+
+class Personnage
+{
+public:
+    virtual ~Personnage(){}
+
+    virtual void deplacer() = 0;
+    virtual void positionner(SDL_Rect position, bool coordonnee = false) = 0;// pos[0] -> x, pos[1] -> y
+    virtual void afficher(SDL_Surface *ecran);
+    virtual SDL_Rect getPosition(bool coordonnee = 0);
+
+protected:
+    SDL_Rect m_pos;
+    Direction m_direction, m_nouvDir;
+    SDL_Surface *m_skin;
+    Niveau *m_terrain;
+};
+
+#endif // PERSONNAGE_H_INCLUDED

BIN
Polices/angelina.ttf


BIN
Polices/angelina.zip


BIN
Polices/droid.ttf


BIN
Skins/Fantome.png


BIN
Skins/Menestrel.png


BIN
Skins/Ogre.png


BIN
Skins/OgreBerzerk.png


BIN
Skins/grosBourin.png


BIN
Skins/vie.png


BIN
Textures/cobblestone.bmp


BIN
Textures/planks.bmp


BIN
Textures/plaque.bmp


BIN
Textures/spawnAllie.bmp


BIN
Textures/spawnFantom.bmp


BIN
Textures/steak.bmp


BIN
Textures/tonneau.bmp


+ 136 - 0
fantome.cpp

@@ -0,0 +1,136 @@
+#include "Fantome.h"
+
+int Fantome::m_multiKill = 0;
+
+Fantome::Fantome(Niveau *terrain, Ogre *ogre, Menestrel *menestrel, Controle controle): Personnage(), m_controle(controle), m_ogre(ogre), m_menestrel(menestrel), m_tempsRestant(0), m_vivant(true)
+{
+    m_terrain = terrain;
+    m_direction = Arret;
+    m_nouvDir = Arret;
+
+    m_skin = IMG_Load("Skins/Fantome.png");
+    if(m_skin == 0)
+        std::cout << "Erreur de chargement du skin Skins/Fantome.png" << std::endl;
+}
+Fantome::~Fantome()
+{
+    SDL_FreeSurface(m_skin);
+}
+
+
+void Fantome::deplacer()
+{
+    if(!m_vivant)
+    {
+        if(SDL_GetTicks()<m_tempsRestant)
+            return;
+        else
+        {
+            m_vivant = true;
+            m_multiKill = 0;
+        }
+    }
+    if(m_controle == local)
+    {
+        int posX = m_pos.x + (m_skin->w-LG_BLOC)/2;
+        int posY = m_pos.y + (m_skin->h-LG_BLOC)/2;
+        int FdirPossible = Arret;
+        if(m_terrain->typeBloc(posX, posY-1, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY-1, 1) != MUR)
+               FdirPossible |= Haut;
+        if(m_terrain->typeBloc(posX+LG_BLOC, posY, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC, posY+LG_BLOC-1, 1) != MUR)
+               FdirPossible |= Droite;
+        if(m_terrain->typeBloc(posX, posY+LG_BLOC, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY+LG_BLOC, 1) != MUR)
+               FdirPossible |= Bas;
+        if(m_terrain->typeBloc(posX-1, posY, 1) != MUR && m_terrain->typeBloc(posX-1, posY+LG_BLOC-1, 1) != MUR)
+               FdirPossible |= Gauche;
+        int dirPerso = Arret;
+        if(m_menestrel->getPosition().y < getPosition().y)
+            dirPerso |= Haut;
+        if(m_menestrel->getPosition().x > getPosition().x)
+            dirPerso |= Droite;
+        if(m_menestrel->getPosition().y > getPosition().y)
+            dirPerso |= Bas;
+        if(m_menestrel->getPosition().x < getPosition().x)
+            dirPerso |= Gauche;
+        std::vector<Direction> nouvDir;
+        for(int i = 0;i<4;i++)
+        {
+            if((m_nouvDir = (Direction)(FdirPossible & (int)pow(2, i))))
+                if(((m_direction<<2) != m_nouvDir) && ((m_direction>>2) != m_nouvDir))
+                    nouvDir.push_back((Direction)pow(2, i));
+        }
+        if(nouvDir.size()>0)
+        {
+            if(nouvDir.size()>1)
+            {
+                int nouvDirTaille = nouvDir.size();
+                for(int i = 0;i<nouvDirTaille;i++)
+                    if(nouvDir[i] & dirPerso)
+                        for(int proba = 1;proba<10;proba++)
+                            nouvDir.push_back(nouvDir[i]);
+                m_direction = nouvDir[rand()%nouvDir.size()];
+            }
+            else
+                m_direction = nouvDir[0];
+            m_pos += m_direction;
+        }
+        else
+            m_direction = m_direction==Gauche?Droite:m_direction==Droite?Gauche:m_direction==Haut?Bas:Haut;
+    }
+}
+
+void Fantome::positionner(SDL_Rect position, bool coordonnee)
+{
+    if(coordonnee)
+    {
+        m_pos.x = position.x;
+        m_pos.y = position.y;
+    }
+    else
+    {
+        m_pos.x = position.x*LG_BLOC - (m_skin->w-LG_BLOC)/2;
+        m_pos.y = position.y*LG_BLOC - (m_skin->h-LG_BLOC)/2;
+    }
+    int posX = m_pos.x + (m_skin->w-LG_BLOC)/2;
+    int posY = m_pos.y + (m_skin->h-LG_BLOC)/2;
+    std::vector<Direction> dirPossible;
+    if(m_terrain->typeBloc(posX-1, posY, 1) != MUR && m_terrain->typeBloc(posX-1, posY+LG_BLOC-1, 1) != MUR)
+           dirPossible.push_back(Gauche);
+    if(m_terrain->typeBloc(posX+LG_BLOC, posY, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC, posY+LG_BLOC-1, 1) != MUR)
+           dirPossible.push_back(Droite);
+    if(m_terrain->typeBloc(posX, posY-1, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY-1, 1) != MUR)
+           dirPossible.push_back(Haut);
+    if(m_terrain->typeBloc(posX, posY+LG_BLOC, 1) != MUR && m_terrain->typeBloc(posX+LG_BLOC-1, posY+LG_BLOC, 1) != MUR)
+           dirPossible.push_back(Bas);
+    if(dirPossible.size()>0)
+        m_direction = dirPossible[rand()%dirPossible.size()];
+    m_nouvDir = m_direction;
+    m_tempsRestant = 0;
+}
+void Fantome::afficher(SDL_Surface *ecran)
+{
+    if(m_vivant)
+        SDL_BlitSurface(m_skin, 0, ecran, &m_pos);
+}
+
+void Fantome::tuer()
+{
+    m_multiKill++;
+    m_vivant = false;
+    m_tempsRestant = SDL_GetTicks()+TEMPS_MORT;
+}
+
+bool Fantome::vivant()
+{
+    return m_vivant;
+}
+bool Fantome::getMultiKill(int nbFantomes)
+{
+    if(nbFantomes == m_multiKill)
+    {
+        m_multiKill = 0;
+        return true;
+    }
+    else
+        return false;
+}

+ 11 - 0
main.cpp

@@ -0,0 +1,11 @@
+#include <iostream>
+#include "Fenetre.h"
+#include <cstdlib>
+#include <ctime>
+
+int main ( int argc, char** argv )
+{
+    srand(time(0));
+    Fenetre fenetre;
+    return 0;
+}

+ 26 - 0
makefile

@@ -0,0 +1,26 @@
+CXX=g++
+CXXFLAGS=
+LDFLAGS=-lSDL -lSDL_image -lSDL_ttf
+INC=
+LIB=
+
+EXEC=pacmen
+SRC=$(shell find . -name '*.cpp') 
+OBJ=$(SRC:.cpp=.o)
+
+$(EXEC): $(OBJ)
+	@mkdir -p bin
+	$(CXX) -o bin/$@ $^ $(LDFLAGS) $(LIB)
+
+#TODO add .h in case of global variables
+%.o : %.cpp 
+	$(CXX) -o $@ -c $< $(CXXFLAGS) $(INC)
+	
+clean:
+	rm -rf $(OBJ)
+
+distclean: clean
+	rm -rf $(EXEC)
+
+exec: $(EXEC)
+	./bin/$(EXEC)