forked from jaildesigner-jailgames/jaildoctors_dilemma
Creadas las colisiones con los enemigos
This commit is contained in:
@@ -84,13 +84,13 @@ bool Room::load(std::string _file_path)
|
||||
// Si la linea contiene el texto [tilemap] se realiza el proceso de carga del fichero tmx
|
||||
else if (line == "[tilemap]")
|
||||
{
|
||||
//printf("Loading tilemap...\n");
|
||||
// printf("Loading tilemap...\n");
|
||||
do
|
||||
{
|
||||
std::getline(file, line);
|
||||
if (line.find(".tmx") != std::string::npos)
|
||||
{
|
||||
//printf("Reading file %s\n", asset->get(line).c_str());
|
||||
// printf("Reading file %s\n", asset->get(line).c_str());
|
||||
std::ifstream file2(asset->get(line)); // Abre el fichero tmx
|
||||
if (file2.good())
|
||||
{
|
||||
@@ -103,10 +103,10 @@ bool Room::load(std::string _file_path)
|
||||
do
|
||||
{
|
||||
std::getline(file2, line);
|
||||
//printf("parsing: %s\n", line.c_str());
|
||||
// printf("parsing: %s\n", line.c_str());
|
||||
|
||||
pos = line.find("data encoding");
|
||||
//printf("pos: %i\n", pos);
|
||||
// printf("pos: %i\n", pos);
|
||||
|
||||
} while (pos == std::string::npos);
|
||||
|
||||
@@ -116,12 +116,12 @@ bool Room::load(std::string _file_path)
|
||||
std::getline(file2, line);
|
||||
if (line != "</data>")
|
||||
{
|
||||
//printf("data: %s\n", line.c_str());
|
||||
// printf("data: %s\n", line.c_str());
|
||||
std::stringstream ss(line);
|
||||
std::string tmp;
|
||||
while (getline(ss, tmp, ','))
|
||||
{
|
||||
//printf("tile: %s\n", tmp.c_str());
|
||||
// printf("tile: %s\n", tmp.c_str());
|
||||
tilemap.push_back(std::stoi(tmp));
|
||||
}
|
||||
}
|
||||
@@ -411,3 +411,16 @@ int Room::getTile(SDL_Point point)
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
// Indica si hay colision con un enemigo a partir de un rectangulo
|
||||
bool Room::enemyCollision(SDL_Rect &rect)
|
||||
{
|
||||
bool collision = false;
|
||||
|
||||
for (auto enemy : enemy_list)
|
||||
{
|
||||
collision |= checkCollision(rect, enemy->getCollider());
|
||||
}
|
||||
|
||||
return collision;
|
||||
}
|
||||
Reference in New Issue
Block a user