1
0
mirror of https://github.com/ssloy/tinyraycaster.git synced 2025-09-01 18:03:47 +02:00

cosine perspective correction

This commit is contained in:
Dmitry V. Sokolov
2019-02-09 13:45:09 +01:00
parent ff7d714453
commit 35ed743b6f
3 changed files with 1 additions and 1 deletions

BIN
doc/008.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
doc/008.mkv Normal file

Binary file not shown.

View File

@@ -111,7 +111,7 @@ int main() {
if (map[int(cx)+int(cy)*map_w]!=' ') { // our ray touches a wall, so draw the vertical column to create an illusion of 3D
size_t icolor = map[int(cx)+int(cy)*map_w] - '0';
assert(icolor<ncolors);
size_t column_height = win_h/t;
size_t column_height = win_h/(t*cos(angle-player_a));
draw_rectangle(framebuffer, win_w, win_h, win_w/2+i, win_h/2-column_height/2, 1, column_height, colors[icolor]);
break;
}