Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GitWatin committed May 13, 2020
2 parents 4429797 + 4f81a20 commit fc162e5
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 26 deletions.
64 changes: 54 additions & 10 deletions SmashBigBordelv2/Entite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,30 @@ void Entite::CheckCollision(Entite *entite, float repoussement, sf::Time dureeIt
{
if (deltaX > 0.0f)
{
this->move((intersectionX *dureeIteration.asSeconds()) * (dureeIteration.asSeconds() - repoussement), 0.0f); //vers la droite
//entite->move(intersectionX * (dureeIteration.asSeconds() - repoussement)* dureeIteration.asSeconds(), 0.0f);
this->move((intersectionX *dureeIteration.asSeconds()) * (dureeIteration.asSeconds() - repoussement), 0.0f);
this->setVersdroite(false);//vers la droite

}
else
else if (deltaX < 0.0f)
{
this->move(-(intersectionX *dureeIteration.asSeconds()) * (dureeIteration.asSeconds() - repoussement), 0.0f);//vers la gauche
//entite->move(intersectionX * (dureeIteration.asSeconds() - repoussement)* dureeIteration.asSeconds(), 0.0f);
this->setVersgauche(false);

}
}
else
{

else if(intersectionX < intersectionY)

if (deltaY > 0.0f)
{
this->move(0.0f, (intersectionX *dureeIteration.asSeconds()) * (dureeIteration.asSeconds() - repoussement));//vers le bas
//entite->move(0.0f ,intersectionX * (dureeIteration.asSeconds() - repoussement)*dureeIteration.asSeconds());
this->setVersbas(false);

}
else
else if (deltaY < 0.0f)
{
this->move(0.0f ,-(intersectionX *dureeIteration.asSeconds()) * (dureeIteration.asSeconds() - repoussement));//vers le haut
//entite->move(0.0f, intersectionX * (dureeIteration.asSeconds() - repoussement)* dureeIteration.asSeconds());
this->setVershaut(false);

}
}

Expand Down Expand Up @@ -81,6 +85,46 @@ bool Entite::getCheckCollision()
return this->CheckColision;
}

void Entite::setVersdroite(bool ok)
{
this->Versdroite = ok;
}

bool Entite::getVersdroite()
{
return this->Versdroite;
}

void Entite::setVersgauche(bool ok)
{
this->Versgauche = ok;
}

bool Entite::getVersgauche()
{
return this->Versgauche;
}

void Entite::setVershaut(bool ok)
{
this->Vershaut = ok;
}

bool Entite::getVershaut()
{
return this->Vershaut;
}

void Entite::setVersbas(bool ok)
{
this->Versbas = ok;
}

bool Entite::getVersbas()
{
return this->Versbas;
}


void Entite::SetNom(std::string nom)
{
Expand Down
15 changes: 15 additions & 0 deletions SmashBigBordelv2/Entite.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ class Entite : public sf::Sprite
virtual void setCheckCollision(bool ok);
virtual bool getCheckCollision();

virtual void setVersdroite(bool ok);
virtual bool getVersdroite();

virtual void setVersgauche(bool ok);
virtual bool getVersgauche();

virtual void setVershaut(bool ok);
virtual bool getVershaut();

virtual void setVersbas(bool ok);
virtual bool getVersbas();

virtual void SetNom(std::string nom);
virtual std::string GetNom();
Expand All @@ -42,6 +53,10 @@ class Entite : public sf::Sprite

protected:
bool Collision = false;
bool Versgauche = true;
bool Versdroite = true;
bool Vershaut = true;
bool Versbas = true;
bool CheckColision = false;
Collider *collider;
std::string Nom;
Expand Down
26 changes: 14 additions & 12 deletions SmashBigBordelv2/Jeu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,45 +115,45 @@ void Jeu::CheckModif()
{
//---------J1--------------------------------

if (perso1choisi->getMoveRight()) //check si le bool est actif
if (perso1choisi->getMoveRight() && perso1choisi->getVersdroite()) //check si le bool est actif
{

Animate(perso1choisi, "droite",1);
perso1choisi->move(dureeIteration.asSeconds()*((VitesseDeplacement / perso1choisi->GetPoids()) * VitesseDeplacement), 0);
}
if (perso1choisi->getMoveLeft()) //check si le bool est actif
if (perso1choisi->getMoveLeft() && perso1choisi->getVersgauche()) //check si le bool est actif
{
Animate(perso1choisi, "gauche",1);
perso1choisi->move(-dureeIteration.asSeconds()*((VitesseDeplacement / perso1choisi->GetPoids()) * VitesseDeplacement), 0);
}
if (perso1choisi->getJump()/*&& perso1choisi->getCollision()*/)
if (perso1choisi->getJump() && perso1choisi->getVershaut()/*&& !perso2choisi->getVersbas()*/)
{
perso1choisi->move(0, (-dureeIteration.asSeconds()*((VitesseSaut / perso1choisi->GetPoids()) * VitesseSaut)));
}
if (!perso1choisi->getCollision() && !perso1choisi->getJump())
if (!perso1choisi->getCollision() && perso1choisi->getVersbas())
{
perso1choisi->move(0, (dureeIteration.asSeconds()*((VitesseDeplacement / perso1choisi->GetPoids()) * Gravity)));
}
//----------J2--------------------------------
if (perso2choisi->getMoveRight()) //check si le bool est actif
if (perso2choisi->getMoveRight() && perso2choisi->getVersdroite())//check si le bool est actif
{
Animate(perso2choisi, "droite",2);
perso2choisi->move(dureeIteration.asSeconds()*((VitesseDeplacement / perso2choisi->GetPoids()) * VitesseDeplacement), 0);
}
if (perso2choisi->getMoveLeft()) //check si le bool est actif
if (perso2choisi->getMoveLeft() && perso1choisi->getVersgauche()) //check si le bool est actif
{
Animate(perso2choisi, "gauche",3);
perso2choisi->move(-dureeIteration.asSeconds()*((VitesseDeplacement / perso2choisi->GetPoids()) * VitesseDeplacement), 0);
}
if (perso2choisi->getJump() /*&& perso2choisi->getCollision()*/)
if (perso2choisi->getJump() && perso2choisi->getVershaut() /*&& !perso2choisi->getVersbas()*/)
{
perso2choisi->move(0, (-dureeIteration.asSeconds()*((VitesseSaut / perso2choisi->GetPoids()) * VitesseSaut)));
}
if (!perso2choisi->getCollision() && !perso2choisi->getJump())
if (!perso2choisi->getCollision() && perso1choisi->getVersbas())
{
perso2choisi->move(0, (dureeIteration.asSeconds()*((VitesseDeplacement / perso2choisi->GetPoids()) * Gravity)));
}
}
}
}


Expand All @@ -172,6 +172,10 @@ void Jeu::CheckCollision(Personnage *michel)
if (!michel->getCheckCollision())
{
michel->setCollision(false);
michel->setVersbas(true);
michel->setVershaut(true);
michel->setVersgauche(true);
michel->setVersdroite(true);
}
michel->setCheckCollision(false);

Expand Down Expand Up @@ -360,15 +364,13 @@ void Jeu::ChoixPerso()
case 1:

perso2choisi = new Rick(Spawn_x2, Spawn_y2);
perso2choisi->SetPersonnage();

std::cout << "J2 : Rick \n " << std::endl;
break;
case 2:

perso2choisi = new Morty(Spawn_x2, Spawn_y2);
perso2choisi->SetPersonnage();


std::cout << "J2 : Morty \n " << std::endl;

break;
Expand Down
4 changes: 2 additions & 2 deletions SmashBigBordelv2/Jeu.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class Jeu
const int Gravity = 150;

const float Spawn_x1 = 100;
const float Spawn_y1 = 0;
const float Spawn_y1 = -500;
const float Spawn_x2 = -100;
const float Spawn_y2 = 0;
const float Spawn_y2 = -500;
// Label HUD
sf::Sprite *avatar1;
sf::Text *NomPerso1;
Expand Down
2 changes: 1 addition & 1 deletion SmashBigBordelv2/Morty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Morty::Morty(int x, int y) : Personnage()
this->setTextureRect(sf::IntRect(0, 0, 78, 110));
//this->setColor(sf::Color::Black);
this->setOrigin(this->getGlobalBounds().width / 2, this->getGlobalBounds().height / 2);
this->setPosition(x, y);
this->setPosition(x , y);
Dessin.push_back(this);

delete t;
Expand Down
2 changes: 1 addition & 1 deletion SmashBigBordelv2/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ void main(int argc,char** argv[])


Game.ChoixMap();
Game.ChargementJeu(Game.GetMapChoisie()); // Chargement une fois
Game.ChoixPerso();
Game.CreateHUD(); // Création de l'interface HUD
Game.ChargementJeu(Game.GetMapChoisie()); // Chargement une fois

//----------------------------- Boucle du jeu --------------------------------------------------
while (Game.GetWindow()->isOpen())
Expand Down

0 comments on commit fc162e5

Please sign in to comment.