diff --git a/pygo.py b/pygo.py index ad3066b..354fad1 100755 --- a/pygo.py +++ b/pygo.py @@ -7,8 +7,11 @@ import sys sys.path.append('lib/') import os +import math + import pygame from pygame.locals import * + import goban @@ -58,6 +61,10 @@ def build_img_res(): return ret +def magnitude(vector): + x,y = vector + return math.sqrt(x*x + y*y) + def main(): # Basic screen init @@ -102,9 +109,12 @@ def main(): row = y / board_inc col = x / board_inc - if x <= board_size: - gb.set_hover((row,col)) - else: + if magnitude(event.rel) < 3: + if x <= board_size: + gb.set_hover((row,col)) + else: + gb.clear_hover() + elif gb.hover != gb._real_pos((row,col)): gb.clear_hover() # Place a stone on left-click