- Codi preparat per a pintar a partir de i fins a certes coordenades Y
This commit is contained in:
16
main.cpp
16
main.cpp
@@ -172,14 +172,14 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
|
||||
float dpix = 64/wall_height;
|
||||
float cpix = 0;
|
||||
float wall_start = 120-(wall_height/64)*(64-height);
|
||||
if (wall_start<0) {
|
||||
cpix = -wall_start*dpix;
|
||||
wall_height += wall_start;
|
||||
wall_start=0;
|
||||
if (wall_start<start) {
|
||||
cpix = (start-wall_start)*dpix;
|
||||
wall_height -= (start-wall_start);
|
||||
wall_start=start;
|
||||
}
|
||||
|
||||
// Pinta el sostre
|
||||
for (int y=0; y<wall_start-1; y++) {
|
||||
for (int y=start; y<wall_start-1; y++) {
|
||||
float straight_dist = (277 * (64-height)) / (y - (240 >> 1));
|
||||
float actual_dist = straight_dist / SDL_cosf(a_inc*DEG_TO_RAD);
|
||||
int tx = abs(int(actual_dist * SDL_cosf(angle*DEG_TO_RAD) - position.x)) % 64;
|
||||
@@ -189,14 +189,14 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
|
||||
|
||||
// Pinta la pared
|
||||
for (int i=0; i<wall_height; ++i) {
|
||||
if (i>=240) break;
|
||||
if (wall_start+i>=end) break;
|
||||
putp(screen_column, wall_start+i, gif[(int(v)%64)+int(cpix)*64]);
|
||||
cpix += dpix;
|
||||
}
|
||||
|
||||
// Pinta el piso
|
||||
int paint_end = wall_start+wall_height-1;
|
||||
for (int y=paint_end+1; y<240-1; y++) {
|
||||
for (int y=paint_end+1; y<end-1; y++) {
|
||||
float straight_dist = (277 * height) / (y - (240 >> 1));
|
||||
float actual_dist = straight_dist / SDL_cosf(a_inc*DEG_TO_RAD);
|
||||
int tx = abs(int(actual_dist * SDL_cosf(angle*DEG_TO_RAD) + position.x)) % 64;
|
||||
@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
|
||||
infi.x = position.x + SDL_cosf(angle*DEG_TO_RAD)*40000;
|
||||
infi.y = position.y + SDL_sinf(angle*DEG_TO_RAD)*40000;
|
||||
|
||||
drawColumn(s, screen_column, 0, 240, a_inc, infi);
|
||||
drawColumn(s, screen_column, 10, 220, a_inc, infi);
|
||||
/*
|
||||
vec2 result, tmp_result;
|
||||
wall *w = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user