我正在尝试将pygame KEYUP
和KEYDOWN
函数添加到我的pygame控件中。我插入它时遇到问题,我会很乐意帮助解决这个简单的问题。我有我的主游戏循环,然后是一个程序范围的if else语句,(如果gun_select == True),这将创建我的起始屏幕。非常感谢!
# Loop as long as done == False
while not done:
for event in pygame.event.get(): # User did something
if event.type == pygame.QUIT: # If user clicked close
done = True # Flag that we are done so we exit this loop
# Clear the screen and set the screen background
screen.fill(GREEN)
if gun_select == True:
#Controls
if j == True:
keys = pygame.key.get_pressed()
#log
last_x1 = x1
last_x2 = x2
last_y1 = y1
last_y2 = y2
if keys[pygame.K_LEFT]:
p1option -=1
print p1option
if keys[pygame.K_RIGHT]:
p1option += 1
print p1option
if keys[pygame.K_a]:
p2option -=1
if keys[pygame.K_d]:
p2option +=1
if keys[pygame.K_r]:
print "begin"
gun_select = False