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.

Code Snippets / [DBP] Main menu.

Author
Message
pavel_sv_1982
9
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 13th Dec 2021 12:35 Edited at: 3rd Aug 2022 20:26
We present to your attention the code of the main menu. You can substitute your media files. The functions of drawing buttons were used as buttons.[functions -graham from darkbasic classic]

Suitable for any desktop size.
That's what I did.
programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!

Attachments

Login to view attachments
Derek Darkly
11
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 13th Dec 2021 19:08 Edited at: 13th Dec 2021 19:15
Just throwing my $0.02 in here, but 350 lines of code seems like a bit much just to display a box & text menu.
Maybe consider using READ/DATA for your button list.

Here's essentially the same output with 10% of the typing:

Send your parents to noisy sprite demo hell... enter the D-Zone
pavel_sv_1982
9
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 13th Dec 2021 21:18 Edited at: 13th Dec 2021 21:43
In the code that I have shown there is a page
1) Main game menu
2) Inside the game menu
3) Save menu
4) Load menu.

I still need to ponder your example.
For example, to solve the problem of multiple menu pages.

I'll tell you a secret.
The number of graphic lines does not greatly affect the size of the executable file.
All the same, there will be at least 3 mb.
So I'd rather make the code easier to read.
programming is a hobby, not a job.
Derek Darkly
11
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 15th Dec 2021 20:54
Notice in my code it says if Menu=0 then gosub MainMenu
You could either have a different subroutine for each menu, or simply RESTORE a different DATA statement to produce different menus, which would entail even less code.
If each menu requires different sized boxes, text and screen locations, that info can also be stored in the DATA statement prior to each menu item.

While it's true that the codes easiest to read are usually the ones we write ourselves, or that already use techniques we are familiar with, your code has many redundant lines (Load Game 1, Load Game 2, etc.) that could be narrowed down with better technique. I've always found READ/DATA a very compact way to handle multiple choices without all the extra IF and CASE statements.

Anyhoo, all advice is take-it-or-leave-it, of course.

Happy Holidays!

Send your parents to noisy sprite demo hell... enter the D-Zone

Login to post a reply

Server time is: 2022-10-04 14:12:06
Your offset time is: 2022-10-04 14:12:06