Top.Mail.Ru
Ответы

Ошибка в пайтон ZeroDivisionError: float division by zero

Import pygame
from setings import *
from map import word_map
def ray_casting(sc, player_pos, player_angle):
cur_angle = player_angle - HALF_FOV
xo, yo = player_pos
for ray in range(NUM_RAYS):
sin_a = math.sin(cur_angle)
cos_a = math.cos(cur_angle)
for depth in range(MAX_DEPHT):
x = xo + depth * cos_a
y = yo + depth * sin_a
#pygame.draw.line(sc, DARKGRAY, player_pos, (x, y), 2)
if (x//TILE*TILE,y//TILE*TILE)in word_map:
proj_height = max(PROJ_COEFF / depth, 0.00001)
pygame.draw.rect(sc,WHITE,(ray * SCALE,HALF_HEIGHT-proj_height//2,SCALE,proj_height))
break
cur_angle += DELTA_ANGLE

По дате
По Рейтингу
Аватар пользователя
Ученик

213

Аватар пользователя
Высший разум

За тебя проверять делители на ноль?! Сам допишешь - не переломишься.
if переменная != 0:
тут делим