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.

AppGameKit Classic Chat / [agk]main menu for game

Author
Message
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 12th Aug 2022 15:33 Edited at: 13th Aug 2022 04:40






what else can you think of?

programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!

Attachments

Login to view attachments
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 14th Aug 2022 21:17 Edited at: 14th Aug 2022 21:27
I prefer to use sprites rather than buttons.
Instead of storing several dimensional variables, I prefer to store them in a UDT and make an array out of it.
Also, if you want to write more than just one game, I recommend to pay attention to reusability and readability in the code.

Here is an example of my button UDT.

Instead of a function that somehow starts with create, I prefer to use a function with the same name as the UDT.
As a constructor so to speak.
Old C/C++ habit
If the game is in prototyping phase and there are no graphics for the buttons you can set the parameter back to -1 then a background will be created automatically.
If a background graphic is available, width and height can be set to -1. They are automatically set to the size of the graphic.
If the size is to be changed then width and height can also be specified then the graphic is changed accordingly.

I like to define my indieces with constants (readability)

The creation of the buttons could then look like this.

This is what calling the buttons could look like.

The function DoMenuButton only processes events that have a general effect on a button.
For example, playing a sound when a button is clicked.

The statuses of the buttons are also defined via constants.

uiDrawButton draws the button and sets the corresponding state of the button.

The HandleMenuButton function in the main loop does the actual work and processes the input.

This is what it would look like for me and is only a suggestion.
Of course you can use the code and change it as you want.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 15th Aug 2022 11:05 Edited at: 15th Aug 2022 11:31
If you noticed, I draw buttons in the program, and then memorize them.
I used print because the text was not visible. had to be adjusted to fit the text. I use arrays because I have no idea how your methods work. Not taught in school. At the institute, I studied to be an engineer, not a programmer.

I will study your code, maybe I will learn something. Thanks for replying to my message.

P.S.
and what game sales can I dream of?
1) is disconnected from the unified payment system.
2) Linux is not supported?

programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!
Loktofeit
AGK Developer
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location: Sarasota, FL
Posted: 15th Aug 2022 16:11
On the code itself, to each their own. On the Menu...

- Revisit "Return". If it is a "Back" button, then it would go toward the bottom of the list or a corner of the screen. A "Return" button would seem confusing to some, especially when it is prioritized as the first button.
- Music and Sound options typically are in an Options menu or, since they are being used as toggles here, displayed as icons.
- If "Start" is "New Game" then it should say as such. If Start takes you to a place where a person can choose New or Load/Continue, then Load and Save should be moved to that menu.
- Since you will have the space, you might want to consider changing Start, Load, and Save to something like New Game, Load Game, and Save Game, or Start New Game, Continue Game, Save Game - the clearer the instructions, the better
- If your game has a trailer, tutorial, how to play section, etc then you might want to have a buttonf or that here, too.



MadBit, I really like the way you do your button code! Very structured, organized, and flexible. *swipes*

LynxJSA's web games/quizzes - LynxJSA's Android apps
AGK Resource Directory
"Stick to a single main loop (DO...LOOP) and loop through it every frame.
Do everything inside functions.
Use finite state machines to control your game.
Use lots and lots of source files.
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 17th Aug 2022 15:23
Quote: "MadBit, I really like the way you do your button code! Very structured, organized, and flexible. *swipes* "

Thank you

Quote: "If you noticed, I draw buttons in the program, and then memorize them."

This is also what I do when no image is specified.
What you can also do with my example is to always use the same image for the background of the button.
You only need to pass the image ID from the first created button to the others.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 18th Aug 2022 15:25
To be honest, I don't know how your code works. Therefore, I will do my own thing with sprites.





programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 18th Aug 2022 16:13
I think the best way to do a main menu for a game is to make the whole thing in keeping with the game you are creating, also one of the major thing to think about is to keep everything looking the same so the whole GUI system blends together seamlessly.
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 19th Aug 2022 14:21 Edited at: 19th Aug 2022 14:27
I found an error in compiling the code.
Out of the blue, an interesting error appeared.
please get acquainted.
the work program has stopped working correctly.
I give free access to the code and media.
The game I wrote vseravno would be free.





pay attention to screenshots.
Buttons are not displayed correctly.
why is that? everything was fine yesterday.
programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!

Attachments

Login to view attachments
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 20th Aug 2022 17:44
i was able to solve the problem. I had to draw buttons in advance and load ready-made buttons into the desired menu.
programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 21st Aug 2022 09:44 Edited at: 21st Aug 2022 11:26
Here are some of my gui system showcases;











please notice that the gui controls are multi-lingual.

create a typedef and make an array with it.
use not single but let's say 8 sprites and 8 texts and 3 sounds for your any gui control, some of them will use only text, some of them use 3 sprites and 1 text e.t.c Oh I have guicontroltypes which uses nothing also like GuiControlType_HPadControl
some of them will be clickable, some of them have different text styles and text sizes etc

I have commands like createguicontrol() setguicontroltext hideguicontrol() guicontrolpressed() e.tc.

all these commands are checked in a function called rungui() which I call in every loop

I hope these examples will be usefull for you to make a better system than I've shown here.

P.S. Edit: Some of the Images are from my games which are pending to be released. And the images and texts in those pictures are all gui controls and most of them are clickable. Also notice that the numbers bigger than 2^31
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 21st Aug 2022 13:45
I made separate loops for each menu level, and merged them into one. I call in a cycle functions. well, I'm dumb.
I do not understand your programs.
the screenshots are really cool.
programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Aug 2022 22:54
You need bigger buttons, larger more readable text. Good idea to display the game title too.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 21st Aug 2022 23:12
Nice work Arch-Ok
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 24th Aug 2022 12:32 Edited at: 24th Aug 2022 13:20
Guys, what is the best way to do this:
1) to have in memory only parts of the gui and pictures of buttons and texts. and just apply them when I open the corresponding menu or option. Unload from memory when the option is not active.
2) or as each menu item have all texts and buttons. Once loaded and do not unload anything until the program is closed.



programming is a hobby, not a job.
P.S. in google and youtube - nikename pavelman- it is not me!

Attachments

Login to view attachments
JosephB
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 24th Aug 2022 19:48
Here is a link to a similar question that provides various coder preferences basically based on the uses of the images and sprites.

https://forum.thegamecreators.com/thread/228546

Login to post a reply

Server time is: 2024-11-21 12:37:27
Your offset time is: 2024-11-21 12:37:27