I am trying to add the pygame KEYUP
and KEYDOWN
function into my controls for my pygame. I am having trouble inserting it in, would enjoy help with this simple problem. I have my main game loop and then a program wide if else statement, (if gun_select == True), which creates my starting screen. Much help appreciated!
# 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