Created
June 21, 2017 09:04
-
-
Save tomvdb/11dde6d41c4387784e2354e549d4cc47 to your computer and use it in GitHub Desktop.
Quick airwheel pygame example for Flick gesture board
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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