Attempt to add better bounding detection.

This commit is contained in:
Dorian 2016-07-16 20:46:30 -04:00
parent 4ca9a39256
commit 21a5431071
1 changed files with 7 additions and 0 deletions

View File

@ -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'))