forked from jaildesigner-jailgames/jaildoctors_dilemma
Trabajando en las colisiones y estados
This commit is contained in:
@@ -476,7 +476,7 @@ void Room::fillMapTexture()
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
for (auto l : rightSurfaces)
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, (rand() % 128)+80, (rand() % 128)+80, (rand() % 128)+80, 0xFF);
|
||||
SDL_SetRenderDrawColor(renderer, (rand() % 128) + 80, (rand() % 128) + 80, (rand() % 128) + 80, 0xFF);
|
||||
SDL_RenderDrawLine(renderer, l.x, l.y1, l.x, l.y2);
|
||||
}
|
||||
}
|
||||
@@ -862,4 +862,80 @@ void Room::setRightSurfaces()
|
||||
rightSurfaces.push_back(line);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las colisiones
|
||||
int Room::checkRightSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
bool collision = false;
|
||||
int pos = -1;
|
||||
|
||||
for (auto s : rightSurfaces)
|
||||
{
|
||||
collision = checkCollision(s, *rect);
|
||||
if (collision)
|
||||
{
|
||||
pos = s.x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Comprueba las colisiones
|
||||
int Room::checkLeftSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
bool collision = false;
|
||||
int pos = -1;
|
||||
|
||||
for (auto s : leftSurfaces)
|
||||
{
|
||||
collision = checkCollision(s, *rect);
|
||||
if (collision)
|
||||
{
|
||||
pos = s.x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Comprueba las colisiones
|
||||
int Room::checkTopSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
bool collision = false;
|
||||
int pos = -1;
|
||||
|
||||
for (auto s : topSurfaces)
|
||||
{
|
||||
collision = checkCollision(s, *rect);
|
||||
if (collision)
|
||||
{
|
||||
pos = s.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Comprueba las colisiones
|
||||
int Room::checkBottomSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
bool collision = false;
|
||||
int pos = -1;
|
||||
|
||||
for (auto s : bottomSurfaces)
|
||||
{
|
||||
collision = checkCollision(s, *rect);
|
||||
if (collision)
|
||||
{
|
||||
pos = s.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
Reference in New Issue
Block a user