Dec-28-2016, 09:25 AM
(This post was last modified: Dec-28-2016, 09:56 AM by KHendrikson.)
(Dec-28-2016, 09:12 AM)Mekire Wrote:(Dec-28-2016, 09:04 AM)KHendrikson Wrote: As a note, the different menu screens are in the same general function, split between parts of it, to make navigating easier.Hard to say without seeing code, but this worries me.
I think you should look into how to design a multi scene program before continuing.
https://github.com/Mekire/pygame-mutisce...with-movie
The code itself is pretty simple, since I'm new to Pygame. The screens share a similar background and thus the whole screen doesn't need to be updated each time, rather the contents of the menus, so I thought it would be easier to keep it within the same function. Do you think splitting it between functions would solve the issue?
menu = 'menu'
while True:
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if menu == 'menu':
# Displays main options menu
# Looks for key presses to navigate through options (works great)
# Looks for mouse position and presses:
if x < mouse[0] < x+i and y < mouse[1] < y+j:
if click[0] == 1:
menu = 'attack'
elif ...:
if click[0] == 1:
menu = 'item'
elif ...:
...
if menu == 'attack':
# Displays the different attacks menu
# Since the attack screen shares some button coordinates,
# after switching menu = 'attack' it starts scanning for new input
# relating to the new coordinates. And since the coordinates are
# the same, and it still detects the button being pressed, it activates
# the next button.
# If you want to go back to the previous menu you'd just switch menu = 'menu' again
if menu == 'item':
# Displays the Item menu
# ...
pygame.display.update()
clock.tick(30)
I've now also tried to split the menu between different functions, setting new variables for get_pos() and get_pressed() in them, but that has also failed to work.