- Ja funciona que cada sector tinga una altura de sostre diferent

This commit is contained in:
2025-09-28 13:48:56 +02:00
parent cae12a86af
commit 8f972d972d

View File

@@ -162,7 +162,7 @@ void createMap()
{ {
sector s; sector s;
s.floor_height = 0.0f; s.floor_height = 0.0f;
s.ceiling_height = 128.0f; s.ceiling_height = 64.0f;
s.verts.push_back({256.0f, 0.0f}); s.verts.push_back({256.0f, 0.0f});
s.verts.push_back({ 64.0f, 0.0f}); s.verts.push_back({ 64.0f, 0.0f});
@@ -222,12 +222,14 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
float v = dot(AP,AB) / dot(AB,AB); v *= w->u2; v = (v-int(v))*tex_height; float v = dot(AP,AB) / dot(AB,AB); v *= w->u2; v = (v-int(v))*tex_height;
float wall_height = (sector_height*277)/dist; // [64=altura sector] float wall_height = (sector_height*277)/dist; // [64=altura sector]
float wall_cut = 0.0f;
float dpix = tex_height/wall_height; // [64=crec que altura sector] float dpix = tex_height/wall_height; // [64=crec que altura sector]
float cpix = 0; float cpix = 0;
float wall_start = 120-(wall_height/sector_height)*(sector_height-(height-s.floor_height)); // [64=els dos crec que altura sector] float wall_start = 120-(wall_height/sector_height)*(sector_height-(height-s.floor_height)); // [64=els dos crec que altura sector]
if (wall_start<start) { if (wall_start<start) {
cpix = (start-wall_start)*dpix; wall_cut = start-wall_start;
wall_height -= (start-wall_start); cpix = wall_cut*dpix;
wall_height -= wall_cut;
wall_start=start; wall_start=start;
} }
@@ -250,6 +252,22 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
cpix += dpix; cpix += dpix;
} }
} else { } else {
if (sectors[w->portal].ceiling_height < s.ceiling_height)
{
float upper_height = s.ceiling_height - sectors[w->portal].ceiling_height;
float upper_wall_height = (upper_height*277)/dist;
upper_wall_height -= wall_cut;
if (upper_wall_height>0.0f)
{
// Pinta la pared
for (int i=0; i<upper_wall_height; ++i) {
if (wall_start+i>=end) break;
putp(screen_column, wall_start+i, gif[(int(v)%tex_height)+int(cpix)*tex_height]);
cpix += dpix;
}
wall_start += upper_wall_height;
}
}
const int wall_end = SDL_min(wall_start+wall_height+1, 240); const int wall_end = SDL_min(wall_start+wall_height+1, 240);
drawColumn(sectors[w->portal], screen_column, wall_start, wall_end, a_inc, infi); drawColumn(sectors[w->portal], screen_column, wall_start, wall_end, a_inc, infi);
} }