home made func
This commit is contained in:
6
main.py
6
main.py
@@ -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)
|
||||
Reference in New Issue
Block a user