Another very basic demo of a menu and managing various gamestates.
There are better ways to do it (like an int instead of strings) but this is the most verbose and easy to read.
Even if you know how to do this basic little thing, its handy having copy-paste code material on hand...
I'm just messing, Kq|1n. And don't mind, AlexClarke, I think he is too. :)
You've made a very solid menu here. Here's a challenge if you are up to it though. Make a multi-layer menu, that is:
WORLD NAME PROPERTIES TILE GLOBAL LOCAL SPRITE COPY SCRIPT
So, you would initially see 3 menus. Selecting one however brings up another with 2-more items that appear like a folder to the side. Canceling that one step brings you back to the main menu.
Yep, you've got it. In S2 I had one menu go 4-levels deep. Hitting [ESC] it would back out of each one very neatly like one piece of paper folded over another.
Here is an example from Tilemaster.
If you look carefully at the top. The primary menu is at 0,0. The next is just a bit below that so you can still see the other menu in the background; but muted.
Ahh, yeah, okay!
I might actually add those little boxes too and add a calculation to check what the longest string is and make the box the correct size.
I'd like to the make the thing more expandable at some point, once I've done a bit more on my main game.
NP, and yes, you are right. When I wrote Tilemaster I had to determine the maximum length of the text. This gets even trickier when you add special commands to the string like:
^* (enter/exit frame building mode)
^0-9 & A-z (change to alternative font set)
^# (double-size for next character, usually icon)
^[ (left justify following text)
^| (center justify following text)
^] (right justify following text)
You can go a little crazy at it, KQ|1N, but the advantage is you can use this library of yours for many other great programs.
Want to really mix it up ? Use proportional typeface. Since screens are no longer fixed at 1024x768, I am having to use pixel-fonts to handle any screen-size or dimensions.
[Please log in to post a comment]