Skip to content

Instantly share code, notes, and snippets.

@tomvdb
Created June 21, 2017 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomvdb/11dde6d41c4387784e2354e549d4cc47 to your computer and use it in GitHub Desktop.
Save tomvdb/11dde6d41c4387784e2354e549d4cc47 to your computer and use it in GitHub Desktop.
Quick airwheel pygame example for Flick gesture board
import signal
import pygame
import flicklib
from pygame.locals import *
pygame.init()
pygame.mouse.set_visible(False)
screen = pygame.display.set_mode((400, 300))
done = False
img = pygame.image.load('switch_inner.png')
value = 10
@flicklib.airwheel()
def spinny(delta):
global value
value += delta*2
if value < 0:
value = 0
if value > 10000:
value = 10000
def rot_center(image, angle):
orig_rect = image.get_rect()
rot_image = pygame.transform.rotate(image, angle)
rot_rect = orig_rect.copy()
rot_rect.center = rot_image.get_rect().center
rot_image = rot_image.subsurface(rot_rect).copy()
return rot_image
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
# print value
screen.blit(rot_center(img, 360 - ((value/10000)*360)), (0,0))
pygame.display.flip()
signal.pause()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment