Advertisement
Guest User

Untitled

a guest
May 24th, 2022
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # Variable explanations:
  2. # HEIGHT = window height
  3. # line_height = calculated height of line (from raycast)
  4. # pixels = amount of pixels to draw (to prevent drawing off-screen or wasting time)
  5.  
  6. pixels = int(min(HEIGHT, line_height))
  7. draw_start = int(HEIGHT // 2 - pixels // 2)
  8.  
  9. # Loop through pixels
  10. for y in range(pixels):
  11.     # Get texel Y
  12.     texel_y = (wall_width - 1) * ((y - (pixels - line_height) / 2) / line_height)
  13.  
  14.     # Draw pixel (using PyGame's pixel array)
  15.     pixel_array[x, draw_start + y] = wall_image_pil[texel_x, texel_y]  # texel_x is calculated earlier and doesn't have any problems
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement