Made this using Python with numba & PIL. Are there efficient ways of creating the floor grid?

This function gives you the positions of the grid pixels for every line of the screen, which is 320 pixels wide:

@jit(nopython=True, fastmath=True, parallel=True)

def compute_floor(size, fov, step, maximal, pl_angle, pl_x, pl_y, map):

sx, sy = size

out = List()

th = 0.1

for n in range(0,sx,1):

buffer = List([0])

angle = radians(fov*(n/sx-0.5)+pl_angle)

dist = 0

for dist2 in prange((int(maximal)+1)*10):

dist = dist2/10

x, y = cos(angle)*dist+pl_x, sin(angle)*dist+pl_y

if fabs(x%1-0.5)<th or fabs(y%1-0.5)<th:

distance = dist*( cos(radians((n-sx/2)/sx*fov)) + 1/1000 )

h = round(sy/(distance+1/1000)/2)

buffer.append(h)

else:

pass#buffer.append(0)

if map[round(y)][round(x)]!=0:

while map[round(y)][round(x)]!=0:

dist-=step/10

x, y = cos(angle)*dist+pl_x, sin(angle)*dist+pl_y

dist+=step/10

x, y = cos(angle)*dist+pl_x, sin(angle)*dist+pl_y

texture = map[round(y)][round(x)]

break

dist+=step

distance = dist*( cos(radians((n-sx/2)/sx*fov)) + 1/1000 )

h = round(sy/(distance+1/1000))

for _ in range(1[spoiler][/spoiler]):

out.append(buffer)

return out