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/')
|
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,9 +109,12 @@ def main():
|
||||||
row = y / board_inc
|
row = y / board_inc
|
||||||
col = x / board_inc
|
col = x / board_inc
|
||||||
|
|
||||||
if x <= board_size:
|
if magnitude(event.rel) < 3:
|
||||||
gb.set_hover((row,col))
|
if x <= board_size:
|
||||||
else:
|
gb.set_hover((row,col))
|
||||||
|
else:
|
||||||
|
gb.clear_hover()
|
||||||
|
elif gb.hover != gb._real_pos((row,col)):
|
||||||
gb.clear_hover()
|
gb.clear_hover()
|
||||||
|
|
||||||
# Place a stone on left-click
|
# Place a stone on left-click
|
||||||
|
|
Loading…
Reference in New Issue
Block a user