Attempt to add better bounding detection.
This commit is contained in:
parent
4ca9a39256
commit
21a5431071
7
main.py
7
main.py
|
@ -4,6 +4,7 @@ from kivy import app, properties
|
||||||
from kivy.uix.label import Label
|
from kivy.uix.label import Label
|
||||||
from kivy.uix.floatlayout import FloatLayout
|
from kivy.uix.floatlayout import FloatLayout
|
||||||
from kivy.graphics import Color, Ellipse, Line, Rectangle
|
from kivy.graphics import Color, Ellipse, Line, Rectangle
|
||||||
|
from kivy.vector import Vector
|
||||||
import kivy.utils
|
import kivy.utils
|
||||||
|
|
||||||
MapCoords = collections.namedtuple('MapCoords', ['row', 'col'])
|
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)
|
self.ell = Line(circle=(self.x, self.y, radius, 0, 360, 6), width=2)
|
||||||
return False
|
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:
|
with self.canvas.after:
|
||||||
if 'button' in touch.profile and touch.button == 'left':
|
if 'button' in touch.profile and touch.button == 'left':
|
||||||
Color(*kivy.utils.get_color_from_hex('#00FF00'))
|
Color(*kivy.utils.get_color_from_hex('#00FF00'))
|
||||||
|
|
Loading…
Reference in New Issue