home made func

This commit is contained in:
2019-10-10 17:47:35 +02:00
parent 8aa660d12d
commit 04222b6148
2 changed files with 27 additions and 22 deletions

View File

@@ -106,7 +106,7 @@ class Car(pygame.sprite.Sprite):
for i,s in enumerate(self.sensors) :
ip = segments_intersection(s,l)
print(s, l)
if ip is not None :
if ip :
# print("ip", ip)
d = distance(ip, self.left_sensor[1])
# print('d',d)
@@ -137,7 +137,7 @@ all_cars.add(car2)
ip = segments_intersection(car2.center_sensor, car2.left_sensor)
print(ip)
print(math.hypot(ip[0] - car2.rect.center[0], ip[1] - car2.rect.center[1]))
# print(math.hypot(ip[0] - car2.rect.center[0], ip[1] - car2.rect.center[1]))
# stress test
# for x in range(100):
@@ -175,4 +175,4 @@ while True :
for line in lines :
pygame.draw.line(screen, (255,255,255), line[0], line[1])
pygame.display.flip()
clock.tick(2)
clock.tick(10)