Don't hover when the cursor is moving fast, to prevent the weird lagging thing.
This commit is contained in:
parent
79d9fb0d9e
commit
db8eb7aa50
16
pygo.py
16
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user