Skip to content
Snippets Groups Projects
Unverified Commit fc588184 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

compute the "colliding color" based on #collisions

parent 02aea1bd
No related branches found
No related tags found
No related merge requests found
......@@ -107,8 +107,8 @@ def update(points: list) -> list:
# gives back to the canva the things to show.
# it should be either
# - a list of booleans, one for each point, that indicates whether or not a
# point is colliding with others
# - a list of integers, one for each point, that indicates how many other nodes
# are colliding with a each node
# - a quad-tree and the query range
def f(points: list, mouse: (int, int)):
...
......
......@@ -65,14 +65,19 @@ class Canva:
self.screen.fill(COLORS["background"])
res = f(self.points, self.mouse)
if isinstance(res, list) and isinstance(res[0], bool):
if isinstance(res, list) and isinstance(res[0], int):
for p, c in zip(self.points, res):
pygame.draw.circle(
self.screen,
COLORS["colliding ball"] if c else COLORS["ball"],
(p.x, p.y),
p.r,
)
if c == 0:
color = (255, 0, 0)
elif c == 1:
color = (255, 128, 0)
elif c == 2:
color = (255, 255, 0)
elif c == 3:
color = (128, 255, 0)
else:
color = (0, 255, 0)
pygame.draw.circle(self.screen, color, (p.x, p.y), p.r)
else:
qtree, range = res
self.__render_qtree(qtree)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment