- [CHG] La quantitat de pisos, portes i pareds es calcula al carregar cada GIF

- [CHG] Al eixir de edició la Z del personatge se reseteja a 24 o per ahí.
This commit is contained in:
2024-06-17 13:34:43 +02:00
parent 04d5c41328
commit 4f8404e105
3 changed files with 75 additions and 29 deletions

View File

@@ -491,6 +491,7 @@ bool game::loop()
if (ui::button("EDITING", 2, 2, 96, 11, editor::isEditing()))
{
room::load(room::editor::getCurrentRoom());
if (!editor::isEditing()) actor::find("HERO")->pos.z=24;
editor::setEditing(!editor::isEditing());
}
@@ -543,16 +544,16 @@ switch (section)
//changed |= btn_small(64, line, room::editor::refColor(), 5, 11);
line += 10;
ui::label("FLOOR", 2, line, 48, 11);
changed |= btn_small(48, line, room::editor::refFloorTex(), 0, 5, 50);
changed |= btn_small(48, line, room::editor::refFloorTex(), 0, room::getFloorCount()-1, 50);
line += 10;
ui::label("WALL", 2, line, 48, 11);
changed |= btn_small(48, line, room::editor::refWallTex(), 0, 5, 50);
changed |= btn_small(48, line, room::editor::refWallTex(), 0, room::getWallsCount()-1, 50);
line += 10;
ui::label("DOOR", 2, line, 48, 11);
changed |= btn_small(48, line, room::editor::refDoorTex(), 0, 4, 50);
changed |= btn_small(48, line, room::editor::refDoorTex(), 0, room::getDoorCount()-1, 50);
line += 10;
ui::label("UNDER DOOR", 2, line, 48, 11);
changed |= btn_small(48, line, room::editor::refWallDoorTex(), 0, 5, 50);
changed |= btn_small(48, line, room::editor::refWallDoorTex(), 0, room::getWallsCount()-1, 50);
line += 10;
ui::label("EXITS", 2, line, 96, 11, GRAY); line+=10;

View File

@@ -206,26 +206,42 @@ namespace room
draw::pushSource();
draw::swapcol(1, color);
const int floor_row_tiles = int(floor_surf->w/32);
const int floor_x = (floor_type%floor_row_tiles)*32;
const int floor_y = int(floor_type/floor_row_tiles)*16;
const int walls_row_tiles = int(walls_surf->w/16);
const int walls_x = (walls_type%walls_row_tiles)*16;
const int walls_y = int(walls_type/walls_row_tiles)*48;
const int doors_row_tiles = int(doors_surf->w/40);
const int doors_x = (doors_type%doors_row_tiles)*40;
const int doors_y = int(doors_type/doors_row_tiles)*59;
const int walldoors_row_tiles = int(walls_surf->w/16);
const int walldoors_x = (walldoors_type%walldoors_row_tiles)*16;
const int walldoors_y = int(walldoors_type/walldoors_row_tiles)*48;
// RUTINES DE PINTAT DE LA PORTA DE DALT A LA DRETA
if (doors & DOOR_YN)
{
// Si la porta està elevada, pintar la part frontal de baix de la porta
if (door_height[3] > 0) {
draw::setSource(walls_surf);
draw::draw( 164+3*16-tmin.y*16, (36+3*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, walldoors_type*16, (5-door_height[3])*8);
draw::draw( 164+4*16-tmin.y*16, (36+4*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, walldoors_type*16, (5-door_height[3])*8);
draw::draw( 164+3*16-tmin.y*16, (36+3*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, walldoors_x, walldoors_y+(5-door_height[3])*8);
draw::draw( 164+4*16-tmin.y*16, (36+4*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, walldoors_x, walldoors_y+(5-door_height[3])*8);
}
// Pintem els dos tiles baix de la porta
draw::setSource(walls_surf);
draw::draw(164+4*16-(tmin.y-1)*16, -door_height[3]*8+84+4*8+(tmin.y-1)*8, 16, 15, walls_type*16, 33, DRAW_FLIP_HORIZONTAL); // Vora
draw::draw(164+4*16-(tmin.y-1)*16, -door_height[3]*8+84+4*8+(tmin.y-1)*8, 16, 15, walls_x, walls_y+33, DRAW_FLIP_HORIZONTAL); // Vora
draw::setSource(floor_surf);
draw::draw(148+3*16-(tmin.y-1)*16, -door_height[3]*8+76+3*8+(tmin.y-1)*8, 32, 15, floor_type*32, 1); // Tile de Piso
draw::draw(148+4*16-(tmin.y-1)*16, -door_height[3]*8+76+4*8+(tmin.y-1)*8, 32, 15, floor_type*32, 1); // Tile de Piso
draw::draw(148+3*16-(tmin.y-1)*16, -door_height[3]*8+76+3*8+(tmin.y-1)*8, 32, 15, floor_x, floor_y+1); // Tile de Piso
draw::draw(148+4*16-(tmin.y-1)*16, -door_height[3]*8+76+4*8+(tmin.y-1)*8, 32, 15, floor_x, floor_y+1); // Tile de Piso
// Pintem la porta
draw::setSource(doors_surf);
draw::draw(164+3*16-tmin.y*16, -door_height[3]*8+32+3*8+tmin.y*8,40,59,doors_type*40,0);
draw::draw(164+3*16-tmin.y*16, -door_height[3]*8+32+3*8+tmin.y*8,40,59,doors_x,doors_y);
}
// RUTINES DE PINTAT DE LA PORTA DE DALT A LA ESQUERRA
@@ -234,40 +250,40 @@ namespace room
// Si la porta està elevada, pintar la part frontal de baix de la porta
if (door_height[1] > 0) {
draw::setSource(walls_surf);
draw::draw(148+tmin.x*16-3*16, (36+tmin.x*8+3*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, walldoors_type*16, (5-door_height[1])*8, DRAW_FLIP_HORIZONTAL);
draw::draw(148+tmin.x*16-4*16, (36+tmin.x*8+4*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, walldoors_type*16, (5-door_height[1])*8, DRAW_FLIP_HORIZONTAL);
draw::draw(148+tmin.x*16-3*16, (36+tmin.x*8+3*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, walldoors_x, walldoors_y+(5-door_height[1])*8, DRAW_FLIP_HORIZONTAL);
draw::draw(148+tmin.x*16-4*16, (36+tmin.x*8+4*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, walldoors_x, walldoors_y+(5-door_height[1])*8, DRAW_FLIP_HORIZONTAL);
}
// Pintem els dos tiles baix de la porta
draw::setSource(walls_surf);
draw::draw(164+(tmin.x-1)*16-5*16, -door_height[1]*8+84+(tmin.x-1)*8+4*8, 16, 15, walls_type*16, 33); // Vora
draw::draw(164+(tmin.x-1)*16-5*16, -door_height[1]*8+84+(tmin.x-1)*8+4*8, 16, 15, walls_x, walls_y+33); // Vora
draw::setSource(floor_surf);
draw::draw(148+(tmin.x-1)*16-3*16, -door_height[1]*8+76+(tmin.x-1)*8+3*8,32,15,floor_type*32,1);
draw::draw(148+(tmin.x-1)*16-4*16, -door_height[1]*8+76+(tmin.x-1)*8+4*8,32,15,floor_type*32,1);
draw::draw(148+(tmin.x-1)*16-3*16, -door_height[1]*8+76+(tmin.x-1)*8+3*8,32,15,floor_x, floor_y+1);
draw::draw(148+(tmin.x-1)*16-4*16, -door_height[1]*8+76+(tmin.x-1)*8+4*8,32,15,floor_x, floor_y+1);
// Pintem la porta
draw::setSource(doors_surf);
draw::draw(164+(tmin.x-1)*16-4*16-8, -door_height[1]*8+32+3*8+9+(tmin.x-1)*8, 40,59, doors_type*40,0, DRAW_FLIP_HORIZONTAL);
draw::draw(164+(tmin.x-1)*16-4*16-8, -door_height[1]*8+32+3*8+9+(tmin.x-1)*8, 40,59, doors_x,doors_y, DRAW_FLIP_HORIZONTAL);
}
draw::setSource(walls_surf);
for (int x=tmin.x;x<=tmax.x;++x)
{
// Si hi ha porta en YP i està a altura 0, no pintem la vorera en eixos dos tiles
if (exits[ZN]==-1) if ( !(doors & DOOR_YP) || (door_height[2] != 0) || (x!=3 && x!=4) ) draw::draw(148+x*16-tmax.y*16,84+x*8+tmax.y*8,16,15,walls_type*16, 33);
if (exits[ZN]==-1) if ( !(doors & DOOR_YP) || (door_height[2] != 0) || (x!=3 && x!=4) ) draw::draw(148+x*16-tmax.y*16,84+x*8+tmax.y*8,16,15,walls_x, walls_y+33);
// Si hi ha porta en YN, no pintem la pared en eixos dos tiles
if ( !(doors & DOOR_YN) || (x!=3 && x!=4) ) draw::draw(164+x*16-tmin.y*16,36+x*8+tmin.y*8,16,48,walls_type*16, 0);
if ( !(doors & DOOR_YN) || (x!=3 && x!=4) ) draw::draw(164+x*16-tmin.y*16,36+x*8+tmin.y*8,16,48,walls_x, walls_y);
}
for (int y=tmin.y;y<=tmax.y;++y)
{
draw::setSource(walls_surf);
// Si hi ha porta en XP i està a altura 0, no pintem la vorera en eixos dos tiles
if (exits[ZN]==-1) if ( !(doors & DOOR_XP) || (door_height[0] != 0) || (y!=3 && y!=4) ) draw::draw(164+tmax.x*16-y*16,84+tmax.x*8+y*8,16,15,walls_type*16, 33, DRAW_FLIP_HORIZONTAL);
if (exits[ZN]==-1) if ( !(doors & DOOR_XP) || (door_height[0] != 0) || (y!=3 && y!=4) ) draw::draw(164+tmax.x*16-y*16,84+tmax.x*8+y*8,16,15,walls_x, walls_y+33, DRAW_FLIP_HORIZONTAL);
// Si hi ha porta en XN, no pintem la pared en eixos dos tiles
if ( !(doors & DOOR_XN) || (y!=3 && y!=4) ) draw::draw(148+tmin.x*16-y*16,36+tmin.x*8+y*8,16,48,walls_type*16,0, DRAW_FLIP_HORIZONTAL);
if ( !(doors & DOOR_XN) || (y!=3 && y!=4) ) draw::draw(148+tmin.x*16-y*16,36+tmin.x*8+y*8,16,48,walls_x, walls_y, DRAW_FLIP_HORIZONTAL);
// Pintem tots els tiles del piso
if (exits[ZN]==-1)
@@ -275,7 +291,7 @@ namespace room
draw::setSource(floor_surf);
for (int x=tmin.x;x<=tmax.x;++x)
{
draw::draw(148+x*16-y*16,76+x*8+y*8,32,15,floor_type*32,1);
draw::draw(148+x*16-y*16,76+x*8+y*8,32,15,floor_x, floor_y+1);
}
}
}
@@ -287,13 +303,21 @@ namespace room
draw::pushSource();
draw::swapcol(1, color);
const int doors_row_tiles = int(doors_surf->w/40);
const int doors_x = (doors_type%doors_row_tiles)*40;
const int doors_y = int(doors_type/doors_row_tiles)*59;
const int walldoors_row_tiles = int(walls_surf->w/16);
const int walldoors_x = (walldoors_type%walldoors_row_tiles)*16;
const int walldoors_y = int(walldoors_type/walldoors_row_tiles)*48;
if (doors & DOOR_YP)
{
// Pintem les voreres dels dos tiles extra per a la porta YP
draw::setSource(walls_surf);
draw::draw(164+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walldoors_type*16, 1, DRAW_FLIP_HORIZONTAL);
draw::draw(148+3*16-(tmax.y+1)*16, -door_height[2]*8+84+3*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walldoors_type*16, 1);
draw::draw(148+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walldoors_type*16, 1);
draw::draw(164+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walldoors_x, walldoors_y+1, DRAW_FLIP_HORIZONTAL);
draw::draw(148+3*16-(tmax.y+1)*16, -door_height[2]*8+84+3*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walldoors_x, walldoors_y+1);
draw::draw(148+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walldoors_x, walldoors_y+1);
draw::setSource(aux_surf);
draw::draw(164+4*16-(tmax.y+1)*16, 91+4*8+(tmax.y+1)*8, 16, 8, 16, 0);
@@ -302,15 +326,15 @@ namespace room
// Pintem la porta YP
draw::setSource(doors_surf);
draw::draw(164+3*16-8-(tmax.y+1)*16, -door_height[2]*8+32+3*8+4+(tmax.y+1)*8,40,59,doors_type*40,0);
draw::draw(164+3*16-8-(tmax.y+1)*16, -door_height[2]*8+32+3*8+4+(tmax.y+1)*8,40,59,doors_x,doors_y);
}
if (doors & DOOR_XP)
{
// Pintem les voreres dels dos tiles extra per a la porta XP
draw::setSource(walls_surf);
draw::draw(148+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,walldoors_type*16, 1);
draw::draw(164+(tmax.x+1)*16-3*16, -door_height[0]*8+84+(tmax.x+1)*8+3*8,16,15+door_height[0]*8,walldoors_type*16, 1, DRAW_FLIP_HORIZONTAL);
draw::draw(164+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,walldoors_type*16, 1, DRAW_FLIP_HORIZONTAL);
draw::draw(148+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,walldoors_x, walldoors_y+1);
draw::draw(164+(tmax.x+1)*16-3*16, -door_height[0]*8+84+(tmax.x+1)*8+3*8,16,15+door_height[0]*8,walldoors_x, walldoors_y+1, DRAW_FLIP_HORIZONTAL);
draw::draw(164+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,walldoors_x, walldoors_y+1, DRAW_FLIP_HORIZONTAL);
draw::setSource(aux_surf);
draw::draw(148+(tmax.x+1)*16-4*16, 91+(tmax.x+1)*8+4*8,16,8,0,0);
@@ -319,7 +343,7 @@ namespace room
// Pintem la porta XP
draw::setSource(doors_surf);
draw::draw( 164+(tmax.x+1)*16-4*16-16, -door_height[0]*8+32+3*8+4+(tmax.x+1)*8, 40,59, doors_type*40,0, DRAW_FLIP_HORIZONTAL);
draw::draw( 164+(tmax.x+1)*16-4*16-16, -door_height[0]*8+32+3*8+4+(tmax.x+1)*8, 40,59, doors_x,doors_y, DRAW_FLIP_HORIZONTAL);
}
draw::popSource();
}
@@ -359,6 +383,23 @@ namespace room
return color;
}
int getFloorCount()
{
return int(floor_surf->w / 32) * int(floor_surf->h / 16);
}
int getDoorCount()
{
return int(doors_surf->w / 40) * int(doors_surf->h / 59);
}
int getWallsCount()
{
int num = int(walls_surf->w / 16) * int(walls_surf->h / 48);
return num;
}
namespace editor
{
static bool room_exists[256];

View File

@@ -32,6 +32,10 @@ namespace room
int getExit(const int d);
int getColor();
int getFloorCount();
int getDoorCount();
int getWallsCount();
namespace editor
{
int &refWidth();