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.

Newcomers DBPro Corner / Main Menus

Author
Message
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 1st Sep 2003 04:59 Edited at: 1st Sep 2003 05:24
How would i be able to make one of those main menu's? like, where theirs buttons like, play, about, options, load, ect. how i make those? and how would i make it so... when u choose like.. red in a drop-down list, and the object on the screen would turn red... how would i make the drop down list..

You did what? For who?! For how many jellybeans?!?
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 1st Sep 2003 05:42
gimme a code sample?

You did what? For who?! For how many jellybeans?!?
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 1st Sep 2003 20:00
awww.. common, no one can tellme how to make menu's? commmmon...
i need ta know

You did what? For who?! For how many jellybeans?!?
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 1st Sep 2003 20:00
i use darkbasic classic by theway

You did what? For who?! For how many jellybeans?!?
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 1st Sep 2003 21:27
well, u can have several types of menu, image menus, object menus, alot of programmers these days use objects menus.
whats an object menu?:-
it's a menu containing object items. as u know, u can do anything with objects.
here's an example of a menu made out of objects:-
1. lets say u want to make a menu of 4 items:
sync on: autocam off
for i=1 to 4
make object plain i,100,25
next i
this creats 4 PLAIN objects.
2. now to postision ur items on the screen and give them colors:
position object 1,0,100,200 :position object 2,0,0,200
color object 1,rgb(255,255,0) :color object 2,rgb(255,255,0)
3. here's the loop for which DB will detect ur position of ur mouse, and when the mouse is over an item, it will change its color:
do
if mousex()>(mousex value) and mousey()>(mousey value) and mousex()<(mousex value) and mousey()<(mousey value) then color object 1,rgb(255,0,0)
else
if mousex()>(mousex value object 2) and mousey()>(mousey value object 2) and mousex()<(mousex value object 2) and mousey()<(mousey value object 2) then color object 1,rgb(255,0,0)

sync :loop
just replace the (mouse value objects) with the position of where ur mouse is over an item.

THAT'S IT! u made an object menu, the same thing for doing an image menu, just load ur images and paste them where u want them to be, and put the values of ur mouseX and mouseY.
dont forget that by object menus u can also make cool animations. just read the tutorials on the DarkBASIC.
cheers!

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
TDK_Man
21
Years of Service
User Offline
Joined: 24th Aug 2003
Location: Tenerife, Spain
Posted: 1st Sep 2003 22:27
Download my menu system from the downloads page at http://www.matedit.com.

It's small, simple and free! Oh and it looks quite nice too...

TDK

MatEdit Pro Info & Progress Reports: http://www.matedit.com
TeePee
21
Years of Service
User Offline
Joined: 18th Apr 2003
Location: Australia
Posted: 2nd Sep 2003 12:41
rightyo ill try and explain some stuff to you...i was gonna do this the other day but i didnt have any time so ill see what i can do now. i wont give you any source code just a description of 1 way that you can use menus.

firstly in my code i like to use a lot of gosubs because it makes the code more organised. just in case you didnt know, a gosub is a section of code that you declare like a function but when you use the command 'gosub', it will jump to the beginning of the defined section of code and it will return to where it was before when it reaches the 'return' command at the end of the section of code.

alright so the first thing you need to do is actually construct the menu. usually you do this every frame so you need to put it in a gosub. in this code you need to draw up the menu now you can choose what design you want. you might choose to colour the background and then put some 8 boxes or so around the screen you may even want to surround the boxes with lines. so you do all that stuff manually and work out where you want to place everything. you may also want to use images instead of boxes and text so that you can draw images outside of dark basic, so in this section you would just be using sprites if you did that. note that this section also includes text.

now the next gosub. you need to be able to control which item in the list is selected. to do this you need to have a variable which you might call, for example, 'selected' and this will determine which option is selected. so it may start on 1 and then you say something like if upkey()=1 then selected = selected - 1 and then do the opposite for downkey(). then have something like if selected = 0 then selected = 8 and visa versa (assuming that you have 8 options). this is where you also put stuff to do with where the mouse is if you are including that but ill come to that later.

next gosub is to do with what happens when an option is selected. you start this with a general condition which may be something as simple as....if returnkey()=1....inside this condition you will have things like.....if selected = 1 then blah blah blah then youd have if selected = 2 then blah blah blha. so basically in this you define what happens when the option is selected.

now thats a basic menu system very basic. if you did use this design that ive talked about using gosubs your do loop would be as simple as:

do
cls
gosub drawmenu
gosub itemselect
gosub outcome
sync
loop

now there are a few more things i have to mention. firstly, you want the user to know which item in the menu is selected so to do this you would need to have if conditions in the drawmenu gosub. im going to use the example where you have boxes in your menu. basically you might have something like this...

if selected = 1
ink rgb(255,0,0),1
box x1,y1,x2,y2
else
ink rgb(0,255,0),1
box x1,y1,x2,y2
endif

now in this im using x1,y1,x2,y2 to represent the values where the box would be. this would be related to drawing the first box in your menu because the condition is if selected = 1. if this condition is true it will make the box red (ink rgb(255,0,0)) but if this isnt true and this item isnt selected then the box will be green (ink rgb(0,255,0)). so if you repeat a similar code for all of the boxes then whatever the selected box is it will be a different colour from the rest of them.

the other point i wanted to go through was using the mouse to select items however i really have to go now so i dont have to to go through this but i hope this helps you understand how a basic menu system works. sorry its a lot to read but i dont know what level your at in dark basic and programming so i had to go through it more thoroughly then i normally would have.
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 3rd Sep 2003 04:35
ok, thnx people, i'll try..

You did what? For who?! For how many jellybeans?!?
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 3rd Sep 2003 04:36
umm.. how would i make it so if i clicked on my button, it would delete the menu and start up the game...

You did what? For who?! For how many jellybeans?!?
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 3rd Sep 2003 04:48 Edited at: 3rd Sep 2003 04:52
umm.. when i run ur program digital, my db crashes.... it jus closes...

TDK: there is no 'menu system' on ur website...

You did what? For who?! For how many jellybeans?!?
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 3rd Sep 2003 05:13
Oi this weekend Ill see what I can whip up for a real quick tutorial. Basically like this.



RPGamer

Current Project: Eternal Destiny
Porting all files to my new computer
TeePee
21
Years of Service
User Offline
Joined: 18th Apr 2003
Location: Australia
Posted: 3rd Sep 2003 10:34
Quote: "umm.. how would i make it so if i clicked on my button, it would delete the menu and start up the game..."


simple. i will use my post above as an example. first set a variable:

menu = 1

now if option 1 is to start the game then in the outcome gosub you would do:

if returnkey()=1
if selected=1 then menu = 0:game = 1

then change your do loop to something like this:

do
cls

if menu = 1
gosub drawmenu
gosub itemselect
gosub outcome
endif

if game = 1
all the code
for you game
goes here
endif

sync
loop

so when start game is selected it stops drawing the menu, detecting if an option is selected etc. all that stuff and it starts doing all the game related stuff.
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 4th Sep 2003 00:47
ok, thanks RPGgamer, i find ur code the easiest, umm, but is there a way to make the box go to a different place? if i make more then 1, i need to move it, srry if i sound newbish... but i'll search the help files.. if its in there.. usually the forums r easiest, sooo..
question: how to i posistion a 2D box?

You did what? For who?! For how many jellybeans?!?

Login to post a reply

Server time is: 2024-09-20 21:25:18
Your offset time is: 2024-09-20 21:25:18