Don't hover when the cursor is moving fast, to prevent the weird lagging thing.

This commit is contained in:
Anna Rose 2012-04-14 17:10:12 -04:00
parent 79d9fb0d9e
commit db8eb7aa50

10
pygo.py
View File

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