From 24c8b4e46d411bcffece404c52135d00247d8acf Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 9 Sep 2016 23:46:58 +0200 Subject: [PATCH] Limit how close lights can be placed to each other --- tabakrolletjie/scenes/day.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tabakrolletjie/scenes/day.py b/tabakrolletjie/scenes/day.py index 7860c87..1c518c5 100644 --- a/tabakrolletjie/scenes/day.py +++ b/tabakrolletjie/scenes/day.py @@ -100,10 +100,13 @@ class DayScene(BaseScene): def _place_spotlight(self, gamestate, colour, ev): if self._seeds > 5: - self._seeds -= 5 - self._update_toolbar(gamestate) pos = pymunk.pygame_util.from_pygame(ev.pos, pygame.display.get_surface()) + # Bail if we're too close to an existing light + if self._lights.nearest(pos, max_distance=25): + return + self._seeds -= 5 + self._update_toolbar(gamestate) cfg = { "type": "spotlight", "colour": colour, -- 2.34.1