forked from jaildesigner-jailgames/jaildoctors_dilemma
Terminado el cálculo de superficies
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.9" tiledversion="1.9.0" orientation="orthogonal" renderorder="right-down" width="32" height="16" tilewidth="8" tileheight="8" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<map version="1.9" tiledversion="1.9.1" orientation="orthogonal" renderorder="right-down" width="32" height="16" tilewidth="8" tileheight="8" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" source="../../../jaildoctors_dilemma_resources/tilesets/standard.tsx"/>
|
||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
0,0,0,0,0,0,0,0,0,0,0,203,203,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,23,23,23,23,0,0,0,0,0,0,0,0,0,23,
|
||||
23,23,23,23,23,23,0,0,0,203,0,0,0,0,0,0,0,0,0,23,0,0,0,0,203,203,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,203,0,0,0,0,0,0,0,0,0,23,0,0,0,0,203,203,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,0,203,203,23,
|
||||
0,0,0,0,0,0,0,203,203,203,203,203,203,0,0,0,0,0,0,23,0,0,0,0,203,203,0,0,0,0,0,23,
|
||||
0,0,0,0,0,203,0,0,0,0,0,0,0,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,0,0,0,23,
|
||||
43,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,83,83,83,83,83,83,83,83,83,83,83,83,
|
||||
43,43,43,43,43,43,43,43,43,43,43,43,43,43,223,0,0,223,43,43,43,43,43,43,43,43,43,43,43,43,43,43
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
0,0,0,0,0,0,0,0,0,0,0,203,203,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24,0,0,0,0,0,0,0,0,0,24,
|
||||
24,24,24,24,24,24,0,0,0,203,0,0,0,0,0,0,0,0,0,24,0,0,0,0,203,203,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,203,0,0,0,0,0,0,0,0,0,24,0,0,0,0,203,203,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,203,203,24,
|
||||
0,0,0,0,0,0,0,203,203,203,203,203,203,0,0,0,0,0,0,24,0,0,0,0,203,203,0,0,0,0,0,24,
|
||||
0,0,0,0,0,203,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,24,
|
||||
44,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,84,84,84,84,84,84,84,84,84,84,84,84,
|
||||
44,44,44,44,44,44,44,44,44,44,44,44,44,44,223,0,0,223,44,44,44,44,44,44,44,44,44,44,44,44,44,44
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
<tileset firstgid="1" source="../../../jaildoctors_dilemma_resources/tilesets/standard.tsx"/>
|
||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||
<data encoding="csv">
|
||||
26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
|
||||
26,26,0,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,167,66,66,66,66,187,0,0,0,0,164,65,65,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,86,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,86,86,86,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,86,0,86,0,0,0,0,0,0,0,0,167,66,66,66,66,187,0,0,0,0,164,65,65,0,0,0,26,
|
||||
26,0,0,0,86,0,86,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,0,0,0,161,212,212,212,212,212,212,212,0,212,212,181,0,0,0,0,0,0,0,0,0,0,26,
|
||||
@@ -17,8 +17,8 @@
|
||||
26,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,269,0,0,0,0,181,0,0,0,0,0,0,0,0,26,
|
||||
26,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,269,0,0,0,0,0,181,0,0,0,0,0,0,0,0,
|
||||
26,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,0,289,0,0,0,0,0,0,181,0,0,0,0,0,0,0,
|
||||
26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
|
||||
26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26
|
||||
26,0,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
|
||||
26,0,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
|
||||
@@ -14,6 +14,7 @@ Debug::Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
// Inicializa variables
|
||||
x = 0;
|
||||
y = 0;
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -41,7 +42,7 @@ void Debug::render()
|
||||
if (y > 192 - text->getCharacterSize())
|
||||
{
|
||||
y = this->y;
|
||||
x += w*text->getCharacterSize() + 2;
|
||||
x += w * text->getCharacterSize() + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,3 +65,21 @@ void Debug::clear()
|
||||
{
|
||||
slot.clear();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Debug::setEnabled(bool value)
|
||||
{
|
||||
enabled = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Debug::getEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
// Cambia el valor de la variable
|
||||
void Debug::switchEnabled()
|
||||
{
|
||||
enabled = !enabled;
|
||||
}
|
||||
@@ -23,6 +23,7 @@ private:
|
||||
std::vector<std::string> slot; // Vector con los textos a escribir
|
||||
int x; // Posicion donde escribir el texto de debug
|
||||
int y; // Posición donde escribir el texto de debug
|
||||
bool enabled; // Indica si esta activo el modo debug
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
@@ -45,6 +46,15 @@ public:
|
||||
|
||||
// Borra la información de debug
|
||||
void clear();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabled(bool value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool getEnabled();
|
||||
|
||||
// Cambia el valor de la variable
|
||||
void switchEnabled();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,9 +33,9 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
|
||||
playerLives = 9;
|
||||
itemsPicked = 0;
|
||||
|
||||
debugEnabled = true;
|
||||
player->setInvincible(debugEnabled);
|
||||
musicEnabled = !debugEnabled;
|
||||
debug->setEnabled(true);
|
||||
player->setInvincible(debug->getEnabled());
|
||||
musicEnabled = !debug->getEnabled();
|
||||
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.subsection = SUBSECTION_GAME_PLAY;
|
||||
@@ -79,9 +79,9 @@ void Game::checkEventHandler()
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_D:
|
||||
debugEnabled = !debugEnabled;
|
||||
player->setInvincible(debugEnabled);
|
||||
musicEnabled = !debugEnabled;
|
||||
debug->switchEnabled();
|
||||
player->setInvincible(debug->getEnabled());
|
||||
musicEnabled = !debug->getEnabled();
|
||||
musicEnabled ? JA_PlayMusic(music) : JA_StopMusic();
|
||||
break;
|
||||
|
||||
@@ -200,7 +200,7 @@ void Game::updateDebugInfo()
|
||||
// Pone la información de debug en pantalla
|
||||
void Game::renderDebugInfo()
|
||||
{
|
||||
if (!debugEnabled)
|
||||
if (!debug->getEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ private:
|
||||
section_t section; // Seccion actual dentro del juego
|
||||
std::string currentRoom; // Fichero de la habitación actual
|
||||
player_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
||||
bool debugEnabled; // Indica si el modo debug está activo
|
||||
int playerLives; // Lleva la cuenta de ls vidas restantes del jugador
|
||||
int itemsPicked; // Lleva la cuenta de los objetos recogidos
|
||||
Uint32 clock; // Cuenta el tiempo que dura la partida
|
||||
|
||||
@@ -441,6 +441,8 @@ void Room::fillMapTexture()
|
||||
}
|
||||
|
||||
// ****
|
||||
if (debug->getEnabled())
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);
|
||||
for (auto l : bottomSurfaces)
|
||||
{
|
||||
@@ -464,8 +466,9 @@ void Room::fillMapTexture()
|
||||
{
|
||||
SDL_RenderDrawLine(renderer, l.x, l.y1, l.x, l.y2);
|
||||
}
|
||||
|
||||
}
|
||||
// ****
|
||||
|
||||
SDL_SetRenderTarget(renderer, nullptr);
|
||||
}
|
||||
|
||||
@@ -704,9 +707,15 @@ void Room::setBottomSurfaces()
|
||||
// tienen un tile de tipo vacio
|
||||
for (int i = 0; i < tilemap.size() - mapWidth; i++)
|
||||
{
|
||||
if (getTile(i) == t_wall && getTile(i + mapWidth) == t_empty)
|
||||
if (getTile(i) == t_wall && getTile(i + mapWidth) != t_wall)
|
||||
{
|
||||
tile.push_back(i);
|
||||
|
||||
// Si llega al final de la fila, introduce un separador
|
||||
if (i % mapWidth == mapWidth - 1)
|
||||
{
|
||||
tile.push_back(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -717,9 +726,14 @@ void Room::setBottomSurfaces()
|
||||
h_line_t line;
|
||||
line.x1 = (tile[i] % mapWidth) * tileSize;
|
||||
line.y = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||
|
||||
while (tile[i] + 1 == tile[i + 1])
|
||||
{
|
||||
i++;
|
||||
if (i % mapWidth == mapWidth - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
line.x2 = ((tile[i] % mapWidth) * tileSize) + tileSize - 1;
|
||||
bottomSurfaces.push_back(line);
|
||||
@@ -736,9 +750,15 @@ void Room::setTopSurfaces()
|
||||
// tienen un tile de tipo vacio
|
||||
for (int i = mapWidth; i < tilemap.size(); i++)
|
||||
{
|
||||
if (getTile(i) == t_wall && getTile(i - mapWidth) == t_empty)
|
||||
if ((getTile(i) == t_wall || getTile(i) == t_passable) && getTile(i - mapWidth) != t_wall)
|
||||
{
|
||||
tile.push_back(i);
|
||||
|
||||
// Si llega al final de la fila, introduce un separador
|
||||
if (i % mapWidth == mapWidth - 1)
|
||||
{
|
||||
tile.push_back(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -752,6 +772,10 @@ void Room::setTopSurfaces()
|
||||
while (tile[i] + 1 == tile[i + 1])
|
||||
{
|
||||
i++;
|
||||
if (i % mapWidth == mapWidth - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
line.x2 = ((tile[i] % mapWidth) * tileSize) + tileSize - 1;
|
||||
topSurfaces.push_back(line);
|
||||
@@ -770,7 +794,7 @@ void Room::setLeftSurfaces()
|
||||
{
|
||||
if (i % mapWidth != 0)
|
||||
{
|
||||
if (getTile(i) == t_wall && getTile(i - 1) == t_empty)
|
||||
if (getTile(i) == t_wall && getTile(i - 1) != t_wall)
|
||||
{
|
||||
tile.push_back(i);
|
||||
}
|
||||
@@ -784,11 +808,11 @@ void Room::setLeftSurfaces()
|
||||
v_line_t line;
|
||||
line.x = (tile[i] % mapWidth) * tileSize;
|
||||
line.y1 = ((tile[i] / mapWidth) * tileSize);
|
||||
while (tile[i] + 1 == tile[i + mapWidth])
|
||||
while (tile[i] + mapWidth == tile[i + 1])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
line.x2 = ((tile[i] % mapWidth) * tileSize) + tileSize - 1;
|
||||
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||
leftSurfaces.push_back(line);
|
||||
i++;
|
||||
}
|
||||
@@ -797,4 +821,34 @@ void Room::setLeftSurfaces()
|
||||
// Calcula las superficies laterales derechas
|
||||
void Room::setRightSurfaces()
|
||||
{
|
||||
std::vector<int> tile;
|
||||
|
||||
// Busca todos los tiles de tipo wall (excepto los de la ultima columna) que a su derecha
|
||||
// tienen un tile de tipo vacio
|
||||
for (int i = 0; i < tilemap.size(); i++)
|
||||
{
|
||||
if (i % mapWidth != mapWidth - 1)
|
||||
{
|
||||
if (getTile(i) == t_wall && getTile(i + 1) != t_wall)
|
||||
{
|
||||
tile.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recorre el vector de tiles buscando tiles consecutivos para localizar las superficies
|
||||
int i = 0;
|
||||
while (i < tile.size())
|
||||
{
|
||||
v_line_t line;
|
||||
line.x = (tile[i] % mapWidth) * tileSize + tileSize;
|
||||
line.y1 = ((tile[i] / mapWidth) * tileSize);
|
||||
while (tile[i] + mapWidth == tile[i + 1])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||
rightSurfaces.push_back(line);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user