-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartie.cpp
More file actions
64 lines (52 loc) · 1.3 KB
/
partie.cpp
File metadata and controls
64 lines (52 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "partie.h"
Partie::Partie()
{
InitPartie(20, 20);
}
Partie::Partie(int x, int y)
{
InitPartie(x, y);
}
Carte *Partie::getCarte()
{
m_Carte->centrerSur(m_Joueur->getX(), m_Joueur->getY());
m_Carte->vision();
return m_Carte;
}
std::vector<Entite*> Partie::getEntites()
{
return m_Entites;
}
bool Partie::isEntiteHere(int x, int y){
bool yes = false;
for(unsigned int i = 0; i < m_Entites.size() && !yes; i++)
yes = m_Entites[i]->getX() == x && m_Entites[i]->getY() == y && !m_Entites[i]->isPassable();
return yes;
}
bool Partie::deplacer(int xoffset, int yoffset)
{
bool deplacementPossible = false;
int x = m_Joueur->getX();
int y = m_Joueur->getY();
deplacementPossible = (*m_Carte)[y+yoffset][x+xoffset]->isPassable() && !isEntiteHere(x+xoffset,y+yoffset);
if (deplacementPossible){
m_Joueur->deplacer(x+xoffset, y+yoffset);
}
return deplacementPossible;
}
int Partie::getViePerso()
{
return (int)m_Joueur->getVieActuelle();
}
int Partie::getFaimPerso()
{
return m_Joueur->getFaim();
}
void Partie::InitPartie(int x, int y)
{
m_Entites = std::vector<Entite*>(0);
m_Carte = new Carte(x, y);
m_Joueur = new Joueur(x/2, y/2);
m_Entites.push_back(m_Joueur);
m_Entites.push_back(new Creature(5,5));
}