From 21a5431071b4cb8695995d16fb0b645170987567 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Sat, 16 Jul 2016 20:46:30 -0400 Subject: [PATCH] Attempt to add better bounding detection. --- main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.py b/main.py index e169539..4b1ac8f 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from kivy import app, properties from kivy.uix.label import Label from kivy.uix.floatlayout import FloatLayout from kivy.graphics import Color, Ellipse, Line, Rectangle +from kivy.vector import Vector import kivy.utils MapCoords = collections.namedtuple('MapCoords', ['row', 'col']) @@ -111,6 +112,12 @@ class HexMapCell(Label): self.ell = Line(circle=(self.x, self.y, radius, 0, 360, 6), width=2) return False + # Register if within bounds of circle that the hex is inscribed in. + radius = 2 * self.height + dist = Vector(self.x, self.y).distance((touch.x, touch.y)) + if radius - dist < 0: + return False + with self.canvas.after: if 'button' in touch.profile and touch.button == 'left': Color(*kivy.utils.get_color_from_hex('#00FF00'))