I’m trying to implement a standard in-game menu/display for my RPG similar to the one in pokemon, with the option to show player stats, inventory, options etc.
I’m wondering what’s the best way to integrate this into my game in terms of game state management?
Right now I’m planning to have a boolean value for each option, like showingStats and showingInventory and a unique class for each menu option, like StatsMenu and InventoryMenu. In my paintComponent method in the main game loop, it will check if a menu is showing and call the proper draw method. I feel like this approach is pretty inflexible, results in a lot of constant checking, and would require a lot of ugly nested code. For example if I have many submenus, I would need to create a separate class and hold a boolean value for each one.
Also the menu is transparent over the game, so it should be in the same JPanel. Can anyone suggest a more streamlined and extensible approach? Thanks