Return to repo list

heart-of-gold

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

commit fa8c10d13a497b29af730fa1adbdbed5316f5aa5
parent d3b0771aac24a712143d2be66336e0c1dc17144c
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun,  4 Oct 2020 22:01:46 -0500

More menu work, temp checkpoint

Diffstat:
Adata/img/menubuttons_1.png | 0
Adata/json/menus/mainmenu.json | 30++++++++++++++++++++++++++++++
Msrc/menu.py | 16++++++++++++++++
Msrc/vgo.py | 6++++--
4 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/data/img/menubuttons_1.png b/data/img/menubuttons_1.png Binary files differ. diff --git a/data/json/menus/mainmenu.json b/data/json/menus/mainmenu.json @@ -0,0 +1,30 @@ +{ + "name" : "MainMenu", + "bg_sheet" : "mainmenubg.png", + "bg_sprite" : [0, 0], + "buttons" : { + "NewGame" : { + "sheet" : "mainmenu_buttons_1.png", + "sprite" : [0, 0], + "pos" : [100, 100], + "intlayer" : 0, + "effect" : ["me_quit"] + }, + "LoadGame" : { + "sheet" : "mainmenu_buttons_1.png", + "sprite" : [0, 1], + "pos" : [100, 200], + "intlayer" : 0, + "effect" : ["me_quit"] + }, + "Options" : { + "sheet" : "mainmenu_buttons_1.png", + "sprite" : [0, 2], + "pos" : [100, 300], + "intlayer" : 0, + "effect" : ["me_quit"] + } + }, + "entities" : { }, + "sublayouts" : { } +} diff --git a/src/menu.py b/src/menu.py @@ -2,6 +2,8 @@ import pygame, json, os from . import images, vgo, manager from .constants import MENU_JSON_PATH +# TODO: EntityManager should be used to manage menu entities as well, eventually. + ########### # menu.py # ########### @@ -69,4 +71,18 @@ class Menu(object): # Saved values self.manager = manager self.menu_file = menufile + self.button_group = pygame.sprite.LayeredDirty() + self.entities_group = pygame.sprite.LayeredDirty() self.definition = json.load(open(os.path.join(MENU_JSON_PATH, menufile))) + + # Load/setup menu + self.load_menu() + + def load_menu(self): + """ + Load Menu from definition, if it exists. This is called in + the __init__ of the Menu object, and should not be called + anywhere else. + """ + if self.definition != None: + self.background = vgo.Entity( diff --git a/src/vgo.py b/src/vgo.py @@ -280,9 +280,11 @@ class EntityManager(manager.Manager): """ Manager for all entity objects. Handles creating them, placing them on the screen, managing their updates, disposing of them - when need be, and transferring info to them for e.g. moving. + when need be, and transferring info to them for e.g. moving. It + should be noted that EntityManager is only employed for in-battle + entities. Menus manage their own entities in menu modes. """ - + # TODO: EntityManager should eventually be managing menu entities as well. def __init__(self, game): super().__init__(game)