Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit 3f597203e9da656e28c50690893ca2843760b426
parent 24347008c0578acab957980cbba01ddc0dbab155
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Tue,  2 Feb 2021 17:22:43 -0600

menu bg can now be transparent

Diffstat:
Msrc/menu.py | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/menu.py b/src/menu.py @@ -61,7 +61,6 @@ class MenuManager(manager.Manager): sub-entities. """ if surface != None and self.current_menu != None: - surface.blit(self.current_menu.background.image, (0, 0)) self.current_menu.update_menu(surface) ########################### @@ -80,6 +79,7 @@ class Menu(object): # Saved values self.manager = manager self.menu_file = menufile + self.background = None self.button_group = pygame.sprite.LayeredDirty() self.entities_group = pygame.sprite.LayeredDirty() with open(os.path.join(MENU_JSON_PATH, menufile)) as df: self.definition = json.load(df) @@ -96,8 +96,9 @@ class Menu(object): if self.definition != None: # Load background, if any - self.background = entity.Entity(self.manager.bus.fetch("sheet_manager", "sheets")[self.definition["bg_sheet"]], - tuple(self.definition["bg_sprite"]), None, False) + if self.definition["bg_sheet"] != None: + self.background = entity.Entity(self.manager.bus.fetch("sheet_manager", "sheets")[self.definition["bg_sheet"]], tuple(self.definition["bg_sprite"]), None, False) + # Load buttons, if any for b in self.definition["buttons"]: nmb = MenuButton(self.manager.bus.fetch("sheet_manager", "sheets")[self.definition["buttons"][b]["sheet"]], @@ -113,8 +114,12 @@ class Menu(object): """ if surface != None: - # TODO: Add the other groups when they get made + # Draw background first, if it exists + if self.background != None: + self.background.update(surface) + # Next, update buttons self.button_group.update(surface) + # TODO: Add the other groups when they get made ############################# # Section 3 - Menu Entities #