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.

DarkBASIC Professional Discussion / Help needed for a simple menu, please ?

Author
Message
Serge Adjo
19
Years of Service
User Offline
Joined: 3rd Aug 2006
Location:
Posted: 19th May 2010 12:31 Edited at: 19th May 2010 12:45
hello everyone ! I'm working on simple menu based on simple text and mouse controled, no media needed so you can compile it directly... but it don't work correctly: only the last line return the correct value if the user click on it...
the 'choice / option selected' equals 0 for every line except the last...
I don't find any solution.
please just copy and paste this code below, it work without external media:


the main function here is: 'f_TEXT_MENU(v_TEXT_$,v_LINE_E,v_OPTION_N_E)' where 'v_TEXT_$' is the text you want to display, 'v_LINE_E' set at wich line you want the text to be printed ( there are 25 lines at all), 'v_OPTION_N_E' is the id of the text and it makes possible to know if the text is clicked and then react with the proper function. the function return a value that equals 'v_OPTION_N_E' if the user clicked on the text.
hope you understand...

please help me fix this

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th May 2010 13:10
I think it's because you are resetting that returned value to 0 everytime - unless you click the last option, then that's the only one that isn't reset - because it's reset with...

IF V_LANGUAGE_E = 0 THEN V_MENU_CHOICE_E = f_TEXT_MENU("QUITTER",8,4)
IF V_LANGUAGE_E = 1 THEN V_MENU_CHOICE_E = f_TEXT_MENU("QUIT",8,4)


See V_MENU_CHOICE_E will always be reset to 0.

In the function, instead of resetting it to 0, reset it to the current value, but set it to -1 before calling any text functions so that you know when any menu item is clicked, maybe something like this:




Health, Ammo, and bacon and eggs!
Serge Adjo
19
Years of Service
User Offline
Joined: 3rd Aug 2006
Location:
Posted: 19th May 2010 14:12 Edited at: 19th May 2010 14:12
@Van B, yeah the two mistake I've made are:
-resetting the variable v_CLICK_E to 0
-let the variable v_CLICK_E be a local variable
the solution is quite simple:
-let the variable v_CLICK_E be global
-no resetting to 0

now that it is fixed I recommend everyone to use this function in their project: it can be useful to quick menu prototypes, or even a final menu:


thank you Van B !

HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 19th May 2010 14:15
Put in code sinppets then when were looking for some thing like this will be able to find it.

Dark Physics makes any hot drink go cold.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 19th May 2010 16:50
One thing, have you though of create a sort of text bank to handle the languages instead of hard coding them all over the place. Two maybe fine now, but what if you have eight, that's a lot of repeat code. I quickly wrote an example which could be quite useful:



Enjoy

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Serge Adjo
19
Years of Service
User Offline
Joined: 3rd Aug 2006
Location:
Posted: 21st May 2010 10:21 Edited at: 21st May 2010 17:23
@hi there ! I've uploaded an HD 720p video of my game "The Sharpshooter 3D" on youtube, in this video you can see the menu functions in action along with action, game footage:

http://www.youtube.com/watch?v=8i2rV5h5bUY

and some screenshot showing the menu:





enjoy the video !
here is the WIP thread:http://forum.thegamecreators.com/?m=forum_view&t=151744&b=8

Login to post a reply

Server time is: 2026-07-26 00:15:58
Your offset time is: 2026-07-26 00:15:58