i want to show an image as long as i hold a key pressed. If the key isn't pressed (KEYUP) anymore, the image should disappear.
In my code the image appears when i hold the key down, but i does not disappears right away. Anyone knows why the image does not stay visible as long as I hold my key pressed=?
button_pressed = False
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_UP:
button_pressed = True
print"True"
if event.type == KEYUP:
if event.key == K_UP:
button_pressed = False
if button_pressed:
DISPLAYSURF.blit(arrow_left, (20, SCREEN_HEIGHT/2 - 28))
Thanks in advance!!
button_pressedis false?