Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 15th Aug 2012 17:25
Any decent techniques to create a menu screen for a game? Not an animated menu screen but something akin to an arrow to choose options and navigate and stuff. I have the XGui stuff, would that help? Or do I need something else?
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 15th Aug 2012 17:32
u can create almost any menu u want..
ask your self wich menu u want to make.

after u answered that question, we can talk about techniques.

Advanced Updater for your games!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Aug 2012 17:38 Edited at: 15th Aug 2012 17:39
You can just make a menu in Photoshop. You can make the glow a separate image for each button. Just paste the glow over each button. Each button has a screen zone (a rectangle) and if the mouse is in that zone you light up the button. If you want strange shapes for buttons you can use a colour mask.

Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 15th Aug 2012 18:10 Edited at: 15th Aug 2012 20:04
There's different ways of doing it and I prefer one of the more complicated ways because it means less coding in the long run.

The simplest method would be to have an image and your menu text displayed on the screen. So you have an arrow image - I've put the 'paste image' command in comments for your reference (the code is all commented for your reference anyway)

Think of each menu selection as a number. You store that as an integer in 'selection'. Then depending on what the current selection is, you stick the arrow next to it.

Simple Method:


More complicated method (works better if you want to show inventory items or skills and so on):




The simple code is not very flexible as everything is just hard coded in. The second code is a lot more flexible, you can reuse 'commands' (with 'purpose') without having to write extra code to do so and you just set the variables for each menu item, you can make it bigger or you can make it smaller. You could add to it and make it suitable for an inventory where you could have 3 type of health potions or even more without editing any of the code inside of the loop. You'd just be alterating variables.

Also, to illustrate my point, change all of the MenuItem.Purpose values to "end" except one and press 'enter' on the different selections in the program. You'll find they'll all end the program, except the one you refused to give 'end' to.

Kezzla
17
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 15th Aug 2012 19:04
nice menu code Sep.

just wondering...
with the second snippet, did you leave something out intentionally so they would have to figure out the code to get it working?

I just dont want to post the fix without checking.

Sometimes I like to use words out of contents
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 15th Aug 2012 20:05
lol, you give me too much credit, I just forgot an endif in my code. Fixed.

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 16th Aug 2012 22:27
Thanks, it totally makes sense.
However how do I do this if I want the menu to use graphics? Like a nice jpg or something and I highlight the options with the keyboard? I presume I use sprites right? Like I have let's say 200 jpg's if I want to have volume music and sound from 0 to 100?
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 16th Aug 2012 22:32
i personaly not using jpgs. they are not that high quality.
and since you making a game, u better use other file formats.
TGA or PNG.

Advanced Updater for your games!
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 16th Aug 2012 22:46
You could use sprites or use the paste image command. You wouldn't need 200 jpgs(or pngs), that would be inefficiant.

You could probably do a slider control - so you have 2 images, the slider and the slider bar and you just altera the position of the slider image based on the volume. Visually it might look like this
Volume 0<-----|-->100

If you're looking to have images for the text of each menu item. You could just use images inside of text and have an arrow image where I put "->" or even a 'selected' image to go over top.

OR!

You could have a bitmap font for the text, have an image as a background or/and to represent the current selection. (This way would be more compatible with my second code than just using images)

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 17th Aug 2012 14:33
Thanks a lot.

I took the code (understood it) and modified it in order to use branching menu items like options->sound, music, control, etc.
I just basicaly use a select case endselect in order to verify if I am in a certain menu, like options or whatever.

However I am new to the ideea of bitmap fonts. I found some free bitmap fonts here and some sample code, after I finish my menu and drop it into a general function so I dont have to rewrite it, I will check to see how it works.

My simple Pong code is becoming more and more complex (not the game itself, but menu options, multiplayer, etc). I wonder if there is a tool that would generate sort of a mindmap based on the current functinos I use?
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 17th Aug 2012 16:22
Hey, I made a little modification to the menu screen. However, the "selector" gives me a severe headache. When I enter into a submenu and then exit that submenu, and the select is at the same number as the quit command, instead of returning me to the main menu, it ends the application. I went around this by creating actually two selection variables (or more for more menu options but this is so convoluted it makes my brain spin). Here is a code I thought up. Have any ideeas of improving it?

Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 17th Aug 2012 19:28
I don't use a selector for my system. If I want to use multiple menus, I just use a second 'selection' variable, I call it 'selectionM' (M of menu). So if 'selectionM = 1' then it's the top menu then 'selectionM = 2' is the options menu.

When you hit 'Back' for example, you should be able to reset it to the top selection by adding 'selection = 1'. You could also have them set out in functions too if you wanted to just break up the code a bit.

I'll modify my example to show:



Hope this helps.

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 17th Aug 2012 19:56
Thanks, it helped! But I don't understand why my code ended my application when I exited from my options screen. What was the problem?
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 17th Aug 2012 20:20
I'm not sure. When I run your code I don't encounter the same problem, so that's kinda odd. Maybe it's a bug in the version of DBPro you're using? The version I compiled your code on was 1.0761.

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 17th Aug 2012 20:27 Edited at: 17th Aug 2012 20:28
Thats because it was missing a portion of the code.

Here it is:

If I go to options, exit out of options, the startgame option (which prints a text blablabla) is run. I dont get why.



I am using the same version as you do.
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 17th Aug 2012 21:11
Ah, I gotcha. The reason is because the
'if returnkey() = 1' command is run every single frame and what it checks is if the key is currently being pressed. And because the player's finger doesn't necessarily let go of 'return' at precisely the right time, it'll read the returnkey in the next frame (when you're on the top menu and selection = 1) it'll basically follow the command in your top menu.

To avoid that, I've been using wait commands, but that's only due to laziness and in this particular menu system, it works just fine. The wait command just supends the loop program for however long you set it (in milliseconds), I set the wait to 300 milliseconds.

A better method would actually be this:



Use it like you would "if returnkey()"

if ReturnDown() = 1 then Text 0,20, "Button Down"

This should solve the problem.

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 17th Aug 2012 21:25 Edited at: 17th Aug 2012 21:44
Hey.

It actually did not solved the problem.
It still persists. It still executes the start game function when I exit the options screen.

EDIT: I solved the problem with wait 200 miliseconds. Might not be as clean as it should be, but it works, sort of.
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 17th Aug 2012 21:51 Edited at: 17th Aug 2012 21:52
Sorry, I should have given you ReturnUp() and not ReturnDown()

I tested this with your code, it should work, lemme know if you have any more trouble.



[edit] you need to set this as a global:
global buttondown = 0
For it to work

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 18th Aug 2012 16:17
Thanks, it works perfectly.

So it basically checks if the return key was pressed AND released right?

Why would this would? Does it not check it every single frame?
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 18th Aug 2012 17:03
It's checking if the button is down and the moment it is released it'll return a value. It's relying on the buttondown variable, which for one frame is 'true' when the return key is not being pressed, which is how we determine if the key is up.

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 18th Aug 2012 22:00
Thanks for the explanation!
Do you by chance can recommend me a good book on algorythms for games? Like maze generation and stuff like that. Not copy and paste code, but code explained with the math concepts behind.

Login to post a reply

Server time is: 2026-07-21 20:34:23
Your offset time is: 2026-07-21 20:34:23