Im a newbie in the pygame community and python in general. For my computers assignment we have to make a video game. What Im trying to do is have a loop where it starts off by getting user input, then it takes that user input and then displays a new view based on that. Im trying to make a main menu screen where the user can press the up and down arrows to select options on the screen. However, when I run it, its very glitchy and its slow to respond to user input. Only when you hold it down it will move, but it goes all the way to the 4th option.
while Loop_2 == True:
pygame.time.delay(75)
#Checks what keys have been pressed
keys = pygame.key.get_pressed()
#Checks if player has pressed the exit button
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
#Checks if the player has pressed escape and will end python
if keys[pygame.K_ESCAPE]:
pygame.quit()
#The second main menu if statements for moving the curser and selecting
if keys[pygame.K_DOWN] and Position < 4:
#If the player presses the down arrow to move the pointer and its not in the 4th position at the bottom. it will move down
Position = Position + 1
else:
if keys[pygame.K_UP] and Position > 1:
#If the player presses the up arrow to move the pointer and its not in the 1st position at the top. it will move up
Position = Position - 1
else:
if keys[pygame.K_LSHIFT]:
Loop_3 = True
if Position == 1:
Play_Menu()
elif Position == 2:
Saves_Menu()
elif Position == 3:
Settings_Menu()
elif Position == 4:
Quit_Menu()
#Loads the second main Menu
window.blit(main_menu_2,(0,0))
if Position == 1:
window.blit(main_menu_pointer,(650,-525))
elif Position == 2:
window.blit(main_menu_pointer,(650,-385))
elif Position == 3:
window.blit(main_menu_pointer,(650,-240))
elif Position == 4:
window.blit(main_menu_pointer,(650,-100))
pygame.display.update()
I’ve tried changing the pygame.delay to different values and it will either make it too responsive or non-responsive. I just want it so that I can press down or up and when its released it will move onto the next option, not all the way down the bottom. I cant find anything about this on this website here. Thanks
