我有一个SPEEDLINK游戏手柄,并希望在游戏手柄中看到移动的结果。我写了这个:Pygame游戏杆
import pygame
from pygame.locals import *
import random
pygame.init()
TV=pygame.display.set_mode((500,500))
joystick_count = pygame.joystick.get_count()
if joystick_count == 0:
# No joysticks!
print("Error, I didn't find any joysticks.")
else:
# Use joystick #0 and initialize it
my_joystick = pygame.joystick.Joystick(0)
my_joystick.init()
x,y=400,400
pygame.draw.circle(TV,(100,200,40),(x,y),10)
pygame.display.flip()
my_joystick = pygame.joystick.Joystick(0)
clock=pygame.time.Clock()
my_joystick.init()
done=False
print pygame.joystick.get_count()
while not done:
for e in pygame.event.get():
if e.type==QUIT:
done=True
elif e.type==JOYBUTTONUP:
x=my_joystick.get_axis(0)
y=my_joystick.get_axis(1)
print x,y
clock.tick(60)
pygame.quit()
但是,当我在帽子右移动的帽子,而不是它给了我0.999969482422 0.0,同样在帽子下,我得到0.0 0.999969482422代替。为什么会这样,我如何才能像其他职位一样在这些地方获得一次性就业机会?
所以我可以得到1与另一个操纵杆,你的意思是? – amirteymuri
0.999969482422与1.0相同您将永远不会有游戏在这些值之间产生差异。 – Fredrik