forked from jaildesigner-jailgames/jaildoctors_dilemma
Modificado el metodo de carga de habitaciones
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
id=1
|
||||
name=Test Room
|
||||
bg_color=black
|
||||
tileset=room1.png
|
||||
@@ -6,7 +5,10 @@ room_up=0
|
||||
room_down=0
|
||||
room_left=0
|
||||
room_right=02.room
|
||||
tilemap=41,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,41,41,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,41,41,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,41,41,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,41,41,0,0,0,0,41,41,41,41,41,41,41,41,41,41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,0,0,41,41,41,41,41,0,0,0,0,0,0,0,0,0,81,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,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,41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,0,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,41,41,41,41,0,0,0,0,0,0,0,0,0,41,41,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,41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,0,0,41,41,0,0,0,0,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,0,0,0,0,0,41,0,0,0,0,0,0,0,0,0,81,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41
|
||||
|
||||
[tilemap]
|
||||
room1.tmx
|
||||
[tilemap-end]
|
||||
|
||||
[enemy]
|
||||
tileset=enemy01.png
|
||||
@@ -34,4 +36,9 @@ y2=72
|
||||
color=yellow
|
||||
[enemy-end]
|
||||
|
||||
item=1,10,10
|
||||
[item]
|
||||
tileset=items.png
|
||||
tile=1
|
||||
x=10
|
||||
y=10
|
||||
[item-end]
|
||||
@@ -1,4 +1,3 @@
|
||||
id=2
|
||||
name=Test Room 2
|
||||
bg_color=black
|
||||
tileset=room1.png
|
||||
@@ -6,7 +5,7 @@ room_up=0
|
||||
room_down=0
|
||||
room_left=01.room
|
||||
room_right=0
|
||||
tilemap=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,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,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,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,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,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,43,43,0,0,0,0,0,0,0,0,0,0,83,83,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,43,43,43,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,3,0,0,0,0,83,83,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,3,0,0,0,0,83,83,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,0,0,83,83,83,83,83,83,0,0,0,0,0,0,3,0,0,0,0,83,83,0,0,0,0,0,0,0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,43,43,43,43,43,43,43,43,43,43,43,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63
|
||||
enemy=1,0,0,0,1
|
||||
enemy=2,10,0,0,1
|
||||
item=1,10,10
|
||||
|
||||
[tilemap]
|
||||
room2.tmx
|
||||
[tilemap-end]
|
||||
24
data/room/room1.tmx
Normal file
24
data/room/room1.tmx
Normal file
@@ -0,0 +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">
|
||||
<tileset firstgid="1" source="../../resources/tilesets/room1.tsx"/>
|
||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||
<data encoding="csv">
|
||||
41,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,41,
|
||||
41,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,41,
|
||||
41,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,41,
|
||||
41,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,41,
|
||||
41,0,0,0,0,41,41,41,41,41,41,41,41,41,41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,
|
||||
41,0,0,41,41,41,41,41,0,0,0,0,0,0,0,0,0,81,0,0,0,0,0,0,0,0,0,0,0,0,0,41,
|
||||
41,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,41,
|
||||
41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,0,0,0,0,0,0,0,0,0,0,0,0,41,
|
||||
41,41,41,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,41,41,41,41,0,0,0,0,0,0,0,0,0,41,
|
||||
41,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,41,
|
||||
41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,0,0,41,
|
||||
41,0,0,0,0,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,0,0,0,0,0,41,
|
||||
0,0,0,0,0,0,0,0,0,81,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
|
||||
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
24
data/room/room2.tmx
Normal file
24
data/room/room2.tmx
Normal file
@@ -0,0 +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">
|
||||
<tileset firstgid="1" source="../../resources/tilesets/room1.tsx"/>
|
||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||
<data encoding="csv">
|
||||
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,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,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,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,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,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,43,
|
||||
43,0,0,0,0,0,0,0,0,0,0,83,83,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,
|
||||
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,43,43,43,0,0,0,0,0,0,0,0,0,43,
|
||||
43,0,0,0,0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,3,0,0,0,0,83,83,0,0,0,0,0,43,
|
||||
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,
|
||||
43,0,0,0,0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,3,0,0,0,0,83,83,0,0,0,0,0,43,
|
||||
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,
|
||||
0,0,0,0,0,0,0,83,83,83,83,83,83,0,0,0,0,0,0,3,0,0,0,0,83,83,0,0,0,0,0,0,
|
||||
0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
63,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,43,43,43,43,43,43,43,43,43,43,43,63,
|
||||
63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
@@ -198,6 +198,8 @@ void Director::setFileList()
|
||||
mAsset->add("/data/config.bin", data, false);
|
||||
mAsset->add("/data/room/01.room", room);
|
||||
mAsset->add("/data/room/02.room", room);
|
||||
mAsset->add("/data/room/room1.tmx", room);
|
||||
mAsset->add("/data/room/room2.tmx", room);
|
||||
mAsset->add("/media/tilesets/room1.png", bitmap);
|
||||
mAsset->add("/media/enemies/enemy01.png", bitmap);
|
||||
mAsset->add("/media/player/player01.png", bitmap);
|
||||
|
||||
@@ -56,7 +56,7 @@ bool Room::load(std::string _file_path)
|
||||
printf("Reading file %s\n", filename.c_str());
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Si la linea contiene el texto [enemy] se realiza un proceso distinto
|
||||
// Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo
|
||||
if (line == "[enemy]")
|
||||
{
|
||||
enemy_t enemy;
|
||||
@@ -80,6 +80,84 @@ bool Room::load(std::string _file_path)
|
||||
// Añade el enemigo al vector de enemigos
|
||||
enemy_list.push_back(new Enemy(enemy));
|
||||
}
|
||||
|
||||
// Si la linea contiene el texto [tilemap] se realiza el proceso de carga del fichero tmx
|
||||
else if (line == "[tilemap]")
|
||||
{
|
||||
//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());
|
||||
std::ifstream file2(asset->get(line)); // Abre el fichero tmx
|
||||
if (file2.good())
|
||||
{
|
||||
bool data_read = false;
|
||||
while (std::getline(file2, line)) // Lee el fichero linea a linea
|
||||
{
|
||||
if (!data_read)
|
||||
{ // Lee lineas hasta que encuentre donde empiezan los datos del mapa
|
||||
int pos = 0;
|
||||
do
|
||||
{
|
||||
std::getline(file2, line);
|
||||
//printf("parsing: %s\n", line.c_str());
|
||||
|
||||
pos = line.find("data encoding");
|
||||
//printf("pos: %i\n", pos);
|
||||
|
||||
} while (pos == std::string::npos);
|
||||
|
||||
do
|
||||
{ // Se introducen los valores separados por comas en un vector
|
||||
data_read = true;
|
||||
std::getline(file2, line);
|
||||
if (line != "</data>")
|
||||
{
|
||||
//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());
|
||||
tilemap.push_back(std::stoi(tmp));
|
||||
}
|
||||
}
|
||||
} while (line != "</data>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (line != "[tilemap-end]");
|
||||
}
|
||||
|
||||
// Si la linea contiene el texto [item] se realiza el proceso de carga de un item
|
||||
else if (line == "[item]")
|
||||
{
|
||||
// enemy_t enemy;
|
||||
// enemy.asset = asset;
|
||||
// enemy.renderer = renderer;
|
||||
|
||||
do
|
||||
{
|
||||
std::getline(file, line);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
// Procesa las dos subcadenas
|
||||
// if (!setEnemy(&enemy, line.substr(0, pos), line.substr(pos + 1, line.length())))
|
||||
//{
|
||||
// printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
|
||||
// success = false;
|
||||
//}
|
||||
} while (line != "[item-end]");
|
||||
|
||||
// Añade el enemigo al vector de enemigos
|
||||
// enemy_list.push_back(new Enemy(enemy));
|
||||
}
|
||||
|
||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
||||
else
|
||||
{
|
||||
@@ -114,11 +192,7 @@ bool Room::setVars(std::string _var, std::string _value)
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
|
||||
if (_var == "id")
|
||||
{
|
||||
id = _value;
|
||||
}
|
||||
else if (_var == "name")
|
||||
if (_var == "name")
|
||||
{
|
||||
name = _value;
|
||||
}
|
||||
@@ -156,6 +230,9 @@ bool Room::setVars(std::string _var, std::string _value)
|
||||
tilemap.push_back(std::stoi(tmp));
|
||||
}
|
||||
}
|
||||
else if (_var == "")
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
@@ -210,6 +287,9 @@ bool Room::setEnemy(enemy_t *enemy, std::string _var, std::string _value)
|
||||
{
|
||||
enemy->color = stringToColor(_value);
|
||||
}
|
||||
else if (_var == "[enemy-end]")
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
|
||||
@@ -32,7 +32,6 @@ LISTADO DE ITEMS (tipo, posicion)
|
||||
class Room
|
||||
{
|
||||
private:
|
||||
std::string id; // Identificador
|
||||
std::string name; // Nombre de la habitación
|
||||
color_t bg_color; // Color de fondo de la habitación
|
||||
std::string room_up; // Identificador de la habitación que se encuentra arriba
|
||||
|
||||
Reference in New Issue
Block a user