mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
Ajout commentaires et destructeurs
This commit is contained in:
parent
e3d43d638a
commit
806b37890d
@ -3,56 +3,68 @@
|
|||||||
#include <Texture.hpp>
|
#include <Texture.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "MobsCorpACorpIA.h"
|
||||||
|
|
||||||
GestionCollision::GestionCollision(GestionMobs* m, GestionPlayer* p, GestionTerrain* t) : gMobs(m), gPlayer(p), gTerrain(t)
|
GestionCollision::GestionCollision(GestionMobs* m, GestionPlayer* p, GestionTerrain* t) : gMobs(m), gPlayer(p), gTerrain(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MobsIA*> GestionCollision::CheckCollisonSol()
|
/**
|
||||||
{
|
* <summary>Test des collisions entre les entités et le sol</summary>
|
||||||
std::vector<MobsIA*> mobs_collision;
|
*/
|
||||||
/*for (MobsIA* m : gMobs->mobs)
|
void GestionCollision::CheckCollisonSol()
|
||||||
{
|
{
|
||||||
Vector2 pos = m->get_transform().get_origin();
|
|
||||||
Vector2 size = m->get_transform().get_scale();
|
|
||||||
for (StaticBody2D* elem : gTerrain->elems_terrains)
|
|
||||||
{
|
|
||||||
if (elem->get_transform().get_origin().y > pos.x) {
|
|
||||||
Godot::print("Mob touche");
|
|
||||||
mobs_collision.push_back(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Vector2 posPlayer = gPlayer->get_transform().get_origin();
|
Vector2 posPlayer = gPlayer->get_transform().get_origin();
|
||||||
Vector2 taille_Player = ((Sprite*)gPlayer->get_children()[0])->get_texture().ptr()->get_size();
|
Vector2 taille_Player = ((Sprite*)gPlayer->get_children()[0])->get_texture().ptr()->get_size();
|
||||||
|
|
||||||
bool player_touch = false;
|
bool player_touch_temp = false;
|
||||||
|
|
||||||
for (StaticBody2D* elem : gTerrain->elems_terrains)
|
for (StaticBody2D* elem : gTerrain->elems_terrains)
|
||||||
{
|
{
|
||||||
|
//Récuperation des données de position de l'elem
|
||||||
Vector2 posTerrain = elem->get_transform().get_origin();
|
Vector2 posTerrain = elem->get_transform().get_origin();
|
||||||
Vector2 taille_Sol = ((Sprite*)elem->get_children()[0])->get_texture().ptr()->get_size();
|
Vector2 taille_Sol = ((Sprite*)elem->get_children()[0])->get_texture().ptr()->get_size();
|
||||||
|
|
||||||
|
//Test collision avec le sol et le player
|
||||||
|
if (!player_touch_temp) // Si player ne touche pas encore
|
||||||
|
if (posTerrain.y - (taille_Sol.y) < posPlayer.y
|
||||||
|
&& posTerrain.y > posPlayer.y
|
||||||
|
&& posTerrain.x - (taille_Sol.x / 2) < posPlayer.x + taille_Player.x / 4
|
||||||
|
&& posTerrain.x + (taille_Sol.x / 2) > posPlayer.x - taille_Player.x / 4) //Test de si touche
|
||||||
|
player_touch_temp = true;
|
||||||
|
|
||||||
|
//Test collision de chaque mobs avec le sol
|
||||||
|
for (KinematicBody2D* m : gMobs->mobs)
|
||||||
|
{
|
||||||
|
Vector2 pos = m->get_transform().get_origin();
|
||||||
|
Vector2 size = ((Sprite*)elem->get_children()[0])->get_texture().ptr()->get_size();
|
||||||
|
|
||||||
|
MobsCorpACorpIA* m_cast = (MobsCorpACorpIA*) m;
|
||||||
|
|
||||||
if (posTerrain.y - (taille_Sol.y) < posPlayer.y
|
|
||||||
&& posTerrain.y > posPlayer.y
|
if (posTerrain.y - (taille_Sol.y) < pos.y
|
||||||
&& posTerrain.x - (taille_Sol.x / 2) < posPlayer.x + taille_Player.x / 4
|
&& posTerrain.y > pos.y
|
||||||
&& posTerrain.x + (taille_Sol.x / 2) > posPlayer.x - taille_Player.x / 4) {
|
&& posTerrain.x - (taille_Sol.x / 2) < pos.x + size.x / 4
|
||||||
|
&& posTerrain.x + (taille_Sol.x / 2) > pos.x - size.x / 4) {
|
||||||
player_touch = true;
|
Godot::print("Mob touche");
|
||||||
break;
|
m_cast->on_ground = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
gPlayer->on_ground = player_touch;
|
gPlayer->on_ground = player_touch_temp;
|
||||||
|
|
||||||
return mobs_collision;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MobsIA*> GestionCollision::CheckCollisonMur()
|
/**
|
||||||
|
* <summary>Test des collisions entre les entités et les murs</summary>
|
||||||
|
*/
|
||||||
|
void GestionCollision::CheckCollisonMur()
|
||||||
{
|
{
|
||||||
return std::vector<MobsIA*>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MobsIA*> GestionCollision::CheckCollisonToit()
|
/**
|
||||||
|
* <summary>Test des collisions entre les entités et les plafonds</summary>
|
||||||
|
*/
|
||||||
|
void GestionCollision::CheckCollisonToit()
|
||||||
{
|
{
|
||||||
return std::vector<MobsIA*>();
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <summary>Classe permettant la gestion des collisions entr eles divers objets composant le jeu</summary>
|
||||||
|
*/
|
||||||
class GestionCollision
|
class GestionCollision
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
@ -17,8 +20,8 @@ public :
|
|||||||
public:
|
public:
|
||||||
GestionCollision(GestionMobs* m, GestionPlayer* p, GestionTerrain* t);
|
GestionCollision(GestionMobs* m, GestionPlayer* p, GestionTerrain* t);
|
||||||
|
|
||||||
std::vector<MobsIA*> CheckCollisonSol();
|
void CheckCollisonSol();
|
||||||
std::vector<MobsIA*> CheckCollisonMur();
|
void CheckCollisonMur();
|
||||||
std::vector<MobsIA*> CheckCollisonToit();
|
void CheckCollisonToit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,11 +8,16 @@ using namespace godot;
|
|||||||
|
|
||||||
GestionTerrain::GestionTerrain()
|
GestionTerrain::GestionTerrain()
|
||||||
{
|
{
|
||||||
Godot::print("Constructeur Terrain");
|
//Godot::print("Constructeur Terrain");
|
||||||
}
|
}
|
||||||
|
|
||||||
GestionTerrain::~GestionTerrain()
|
GestionTerrain::~GestionTerrain()
|
||||||
{
|
{
|
||||||
|
Array childrens = this->get_children();
|
||||||
|
for (int i = 0; i < childrens.size(); i++)
|
||||||
|
{
|
||||||
|
((Node*)childrens[i])->queue_free();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GestionTerrain::_register_methods()
|
void GestionTerrain::_register_methods()
|
||||||
@ -34,12 +39,25 @@ void GestionTerrain::_init()
|
|||||||
void GestionTerrain::_ready()
|
void GestionTerrain::_ready()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* <summary>Permet l'ajout de murs</summary>
|
||||||
|
* <param name="posX">Position dans la largeur</param>
|
||||||
|
* <param name="posY">Position dans la hauteur</param>
|
||||||
|
* <param name="sizeX">Echelle en largeur</param>
|
||||||
|
* <param name="sizeY"Echelle en hauteur></param>
|
||||||
|
*/
|
||||||
void GestionTerrain::AjoutMur(float sizeX, float sizeY, float posX, float posY)
|
void GestionTerrain::AjoutMur(float sizeX, float sizeY, float posX, float posY)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <summary>Permet l'ajout de sols</summary>
|
||||||
|
* <param name="posX">Position dans la largeur</param>
|
||||||
|
* <param name="posY">Position dans la hauteur</param>
|
||||||
|
* <param name="sizeX">Echelle en largeur</param>
|
||||||
|
* <param name="sizeY"Echelle en hauteur></param>
|
||||||
|
*/
|
||||||
void GestionTerrain::AjoutSolSolide(float sizeX, float sizeY, float posX, float posY)
|
void GestionTerrain::AjoutSolSolide(float sizeX, float sizeY, float posX, float posY)
|
||||||
{
|
{
|
||||||
Godot::print("Ajout sol solide");
|
Godot::print("Ajout sol solide");
|
||||||
@ -69,14 +87,27 @@ void GestionTerrain::AjoutSolSolide(float sizeX, float sizeY, float posX, float
|
|||||||
elems_terrains.push_back(m);
|
elems_terrains.push_back(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <summary>Permet l'ajout de sols traversables</summary>
|
||||||
|
* <param name="posX">Position dans la largeur</param>
|
||||||
|
* <param name="posY">Position dans la hauteur</param>
|
||||||
|
* <param name="sizeX">Echelle en largeur</param>
|
||||||
|
* <param name="sizeY"Echelle en hauteur></param>
|
||||||
|
*/
|
||||||
void GestionTerrain::AjoutSolTraversable(float sizeX, float sizeY, float posX, float posY)
|
void GestionTerrain::AjoutSolTraversable(float sizeX, float sizeY, float posX, float posY)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <summary>Permet la suppression de tous les elements du terrains</summary>
|
||||||
|
*/
|
||||||
void GestionTerrain::SuppressionTout()
|
void GestionTerrain::SuppressionTout()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <summary>Permet une génération de base des éléments du terrains</summary>
|
||||||
|
*/
|
||||||
void GestionTerrain::GenerationCarte()
|
void GestionTerrain::GenerationCarte()
|
||||||
{
|
{
|
||||||
AjoutSolSolide(1, 1, 85, 300);
|
AjoutSolSolide(1, 1, 85, 300);
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <summaryClasse permettant l'ajout et la suppression des divers elements composant le terrain</summary>
|
||||||
|
*/
|
||||||
class GestionTerrain : public TileMap
|
class GestionTerrain : public TileMap
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user