145 lines
5.8 KiB
C++
145 lines
5.8 KiB
C++
#include "room.h"
|
|
#include "jdraw.h"
|
|
|
|
namespace room
|
|
{
|
|
static vec3_t size = {8,8,8};
|
|
static vec3_t tmin = {0,0,0};
|
|
static vec3_t tmax = {7,7,7};
|
|
static vec3_t min = {0,0,0};
|
|
static vec3_t max = {56,56,56};
|
|
|
|
static uint8_t doors = DOOR_XN | DOOR_YN ;
|
|
static uint8_t door_height[4];
|
|
|
|
void load(int x, int y)
|
|
{
|
|
size = {(x+1)*2,(y+1)*2,3};
|
|
tmin = {3-x,3-y,0};
|
|
tmax = {4+x,4+y,3};
|
|
min = {tmin.x*8,tmin.y*8,0};
|
|
max = {tmax.x*8,tmax.y*8,24};
|
|
door_height[0] = 2; //XP
|
|
door_height[1] = 3; //XN
|
|
door_height[2] = 2; //YP
|
|
door_height[3] = 5; //YN
|
|
}
|
|
|
|
void draw()
|
|
{
|
|
if (doors & DOOR_YN)
|
|
{
|
|
if (door_height[3] > 0) {
|
|
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, 128, 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, 128, 16+(5-door_height[3])*8);
|
|
}
|
|
|
|
// Pintem els dos tiles baix de la porta
|
|
draw::draw(164+4*16-(tmin.y-1)*16, -door_height[3]*8+84+4*8+(tmin.y-1)*8, 16, 15, 144, 49); // Vora
|
|
draw::draw(148+3*16-(tmin.y-1)*16, -door_height[3]*8+76+3*8+(tmin.y-1)*8, 32, 15, 0, 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, 0, 1); // Tile de Piso
|
|
|
|
// Pintem la porta
|
|
draw::draw(164+3*16-tmin.y*16, -door_height[3]*8+32+3*8+tmin.y*8,40,59,18,133);
|
|
}
|
|
if (doors & DOOR_XN)
|
|
{
|
|
if (door_height[1] > 0) {
|
|
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, 144, 16+(5-door_height[1])*8);
|
|
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, 144, 16+(5-door_height[1])*8);
|
|
}
|
|
|
|
// Pintem els dos tiles baix de la porta
|
|
draw::draw(164+(tmin.x-1)*16-5*16, -door_height[1]*8+84+(tmin.x-1)*8+4*8, 16, 15, 128, 49); // Vora
|
|
draw::draw(148+(tmin.x-1)*16-3*16, -door_height[1]*8+76+(tmin.x-1)*8+3*8,32,15,0,1);
|
|
draw::draw(148+(tmin.x-1)*16-4*16, -door_height[1]*8+76+(tmin.x-1)*8+4*8,32,15,0,1);
|
|
|
|
// Pintem la porta
|
|
draw::draw(164+(tmin.x-1)*16-4*16-8, -door_height[1]*8+32+3*8+9+(tmin.x-1)*8, 40,59, 64,133);
|
|
}
|
|
|
|
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 ( !(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,128,49);
|
|
|
|
// 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,128,16);
|
|
}
|
|
|
|
for (int y=tmin.y;y<=tmax.y;++y)
|
|
{
|
|
// Si hi ha porta en XP i està a altura 0, no pintem la vorera en eixos dos tiles
|
|
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,144,49);
|
|
|
|
// 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,144,16);
|
|
|
|
// Pintem tots els tiles del piso
|
|
for (int x=tmin.x;x<=tmax.x;++x)
|
|
{
|
|
draw::draw(148+x*16-y*16,76+x*8+y*8,32,15,0,1);
|
|
}
|
|
}
|
|
|
|
if (doors & DOOR_YP)
|
|
{
|
|
// Pintem les voreres dels dos tiles extra per a la porta YP
|
|
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,144,49-door_height[2]*8);
|
|
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,128,49-door_height[2]*8);
|
|
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,128,49-door_height[2]*8);
|
|
|
|
// Pintem els dos tiles de piso extra de la porta YP
|
|
draw::draw(148+3*16-(tmax.y+1)*16, -door_height[2]*8+76+3*8+(tmax.y+1)*8,32,15,0,1);
|
|
draw::draw(148+4*16-(tmax.y+1)*16, -door_height[2]*8+76+4*8+(tmax.y+1)*8,32,15,0,1);
|
|
}
|
|
if (doors & DOOR_XP)
|
|
{
|
|
// Pintem les voreres dels dos tiles extra per a la porta XP
|
|
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,128,49-door_height[0]*8);
|
|
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,144,49-door_height[0]*8);
|
|
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,144,49-door_height[0]*8);
|
|
|
|
// Pintem els dos tiles de piso extra de la porta XP
|
|
draw::draw(148+(tmax.x+1)*16-3*16, -door_height[0]*8+76+(tmax.x+1)*8+3*8,32,15,0,1);
|
|
draw::draw(148+(tmax.x+1)*16-4*16, -door_height[0]*8+76+(tmax.x+1)*8+4*8,32,15,0,1);
|
|
}
|
|
|
|
}
|
|
|
|
void draw2()
|
|
{
|
|
if (doors & DOOR_YP)
|
|
{
|
|
// Pintem la porta YP
|
|
draw::draw(164+3*16-8-(tmax.y+1)*16, -door_height[2]*8+32+3*8+4+(tmax.y+1)*8,40,59,18,133);
|
|
}
|
|
if (doors & DOOR_XP)
|
|
{
|
|
// Pintem la porta XP
|
|
draw::draw( 164+(tmax.x+1)*16-4*16-16, -door_height[0]*8+32+3*8+4+(tmax.x+1)*8, 40,59, 64,133);
|
|
}
|
|
|
|
}
|
|
|
|
vec3_t getSize()
|
|
{
|
|
return size;
|
|
}
|
|
|
|
vec3_t getMin()
|
|
{
|
|
return min;
|
|
}
|
|
|
|
vec3_t getMax()
|
|
{
|
|
return max;
|
|
}
|
|
|
|
uint8_t getDoors()
|
|
{
|
|
return doors;
|
|
}
|
|
}
|