mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#include "GestionCollision.h"
|
|
|
|
#include <Texture.hpp>
|
|
#include <string>
|
|
|
|
GestionCollision::GestionCollision(GestionMobs* m, GestionPlayer* p, GestionTerrain* t) : gMobs(m), gPlayer(p), gTerrain(t)
|
|
{
|
|
}
|
|
|
|
std::vector<MobsIA*> GestionCollision::CheckCollisonSol()
|
|
{
|
|
std::vector<MobsIA*> mobs_collision;
|
|
for (MobsIA* m : gMobs->mobs)
|
|
{
|
|
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_position();
|
|
|
|
bool player_touch = false;
|
|
for (StaticBody2D* elem : gTerrain->elems_terrains)
|
|
{
|
|
if (elem->get_transform().get_origin().y - ((Sprite*)elem->get_children()[0])->get_texture().ptr()->get_size().y < posPlayer.y
|
|
&& elem->get_transform().get_origin().x + ((Sprite*)elem->get_children()[0])->get_texture().ptr()->get_size().x > posPlayer.x) {
|
|
player_touch = true;
|
|
break;
|
|
}
|
|
}
|
|
gPlayer->on_ground = player_touch;
|
|
|
|
return mobs_collision;
|
|
}
|
|
|
|
std::vector<MobsIA*> GestionCollision::CheckCollisonMur()
|
|
{
|
|
return std::vector<MobsIA*>();
|
|
}
|
|
|
|
std::vector<MobsIA*> GestionCollision::CheckCollisonToit()
|
|
{
|
|
return std::vector<MobsIA*>();
|
|
}
|