Hey everyone,
I'm currently working on learning the basics of game development using a (very nice) low-level graphics library, SDL. I'm trying to use OOP as much as possible and now I'm trying to design classes for state changes in games, such as menus and buttons. Now, my problem is actually managing menus. I belive having a whole bunch of variables whose sole purpose is to handle a a simple main menu is kinda messy (please do correct me if you dont think my position is correct), so I thought about using external files to manage stuff such as the string which should appear on a button, its font and font size, it's colors when in different states, etc...
Now, how do I decide on which format to use on my files?
I came up with this kind of format, please do give your opinion and sugestions:
Note: This is just a draft, a real file would have more properties.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#
# file name: main_menu.mnu
# Main Menu buttons's properties
MENU_TITLE:
TEXT: "Tic-Tac-Toe"
SIZE: 36
SPACING: 3
MENU_ITEM_0:
TEXT: "Single Player"
SIZE: 28
SPACING: 1.5
MENU_ITEM_1:
TEXT: "Two Players"
SIZE: 28
SPACING: 1.5
MENU_ITEM_2:
TEXT: "Options"
SIZE: 28
SPACING: 1.5
MENU_ITEM_3:
TEXT: "Credits"
SIZE: 28
SPACING: 1.5
| |
If I was to make my menus using this method I belive I'd need some sort of parser, am I right? My current idea for a parser is a class with a bunch of data members representing the menu item's different properties, such as strings, colors and fonts togheter with some sort of
void parse(ifstream inFile)
member function. Please do correct me if I'm wrong and please do suggest me other solutions either way, I want to broaden my knowledge as much as possible ;).
Looking forward to hearing from you and best regards,
~Deimos