-
Notifications
You must be signed in to change notification settings - Fork 0
/
2dArm.py
50 lines (38 loc) · 1.4 KB
/
2dArm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import numpy as np
import pygame
import pygame.locals
from armpart import ArmPart
#Parametros para Pygame
black = (0, 0, 0)
white = (255, 255, 255)
pygame.init()
width = 500
height = 500
display = pygame.display.set_mode((width, height))
fpsClock = pygame.time.Clock()
upperarm = ArmPart('upperarm.png', scale=.7)
base = (width / 2, height / 2)
while 1:
display.fill(white)
tecla = sys.stdin.read(1)
if tecla == 'a':
ua_image, ua_rect = upperarm.rotate(-.1)
ua_rect.center += np.asarray(base)
ua_rect.center -= np.array([-np.cos(upperarm.rotation) * upperarm.offset,
np.sin(upperarm.rotation) * upperarm.offset])
if tecla == 'h':
ua_image, ua_rect = upperarm.rotate(.1)
ua_rect.center += np.asarray(base)
ua_rect.center -= np.array([-np.cos(upperarm.rotation) * upperarm.offset,
np.sin(upperarm.rotation) * upperarm.offset])
#ua_rect.center -= np.array([np.cos(upperarm.rotation) * upperarm.offset,
# -np.sin(upperarm.rotation) * upperarm.offset])
display.blit(ua_image, ua_rect)
# check for quit
for event in pygame.event.get():
if event.type == pygame.locals.QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fpsClock.tick(100)