From db8eb7aa5007aa6a5d37f98f3a6840a4ea9f8013 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sat, 14 Apr 2012 17:10:12 -0400 Subject: [PATCH] Don't hover when the cursor is moving fast, to prevent the weird lagging thing. --- pygo.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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