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 Discussion / How to make GUIs?

Author
Message
Diablo 98188
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: In front of my computer.
Posted: 21st Jul 2005 22:51
Hey, I\'m about to try and make a game, and was wondering if there is a program that you set up your gui in and it tell you the code you need to put in your game for it to show. Thank you.

"May the fires of the underworld burn you"
- ME ^_^
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Jul 2005 02:38
I've not seen one, but it's a great idea for a program! I might just have a go at that myself...

In the meantime, the quickest method it to create your GUI in a paint program, load the image and paste it onto the screen in your program and write the code for the mouse clicks on the buttons.

To see what using this method looks like, take a look at the prog I'm currently working on at my WIP post at http://forum.thegamecreators.com/?m=forum_view&t=57506&b=8.

TDK
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 22nd Jul 2005 02:39
yeah, thats my method too, i tryed making separate buttons and everythig though and its just not worth it..

Your signature has been erased by a mod because it's larger than 600x120...
P Schnell
20
Years of Service
User Offline
Joined: 13th Feb 2005
Location:
Posted: 22nd Jul 2005 20:27
There's a project I might look at.

Anyway, if you have it, use Photoshop.

The easiest way for button-pressing is checking for the mouse in a rectangle:


If it's any more than a few buttons for starting or viewing rules make sure you keep it organized. It would be good practice to do that anyway.

Diablo 98188
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: In front of my computer.
Posted: 22nd Jul 2005 22:30
Thnx for your answrs.Schnell, would i make that >x1 and <x2 thing like ax1, ax2 if i had multible buttons? Again thank you for your answers..

"May the fires of the underworld burn you"
- ME ^_^
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Jul 2005 10:26
Diablo 98188

Quote: " Thnx for your answrs.Schnell, would i make that >x1 and <x2 thing like ax1, ax2 if i had multible buttons?"


No!

In your main loop, use:

Mx=MouseX()
My=MouseY()
Mc=MouseClick()

Then, use the same Mx, My and Mc for every button like this:

Rem First button at 10,10,40,20
If Mx>10 and My>10 and Mx<40 and My<20 and Mc=1
Rem Do Button 1 stuff here
Endif

Rem Second button at 60,10,90,20
If Mx>60 and My>10 and Mx<90 and My<20 and Mc=1
Rem Do Button 2 stuff here
Endif

and so on for all your buttons...

TDK_Man
P Schnell
20
Years of Service
User Offline
Joined: 13th Feb 2005
Location:
Posted: 23rd Jul 2005 11:01 Edited at: 23rd Jul 2005 11:01
I actually like to use arrays to represent buttons, I usually define a button with 4 values:



This is the function I use:



NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 23rd Jul 2005 11:21 Edited at: 23rd Jul 2005 11:23
Diablo 98188,

TDK's method for the detection between the mouse and multiple buttons is a "hard-code" method. Which, is useful if you are not using sprites as the button images, or do not have your buttons "patterned out" around the screen, as to be enabled to use some pattern formula to detect the collisions in a single for next loop.

However, if your buttons are sprites, you could set up a for next loop, where its starting value is the sprite number of the first button, and then ending value is the sprite number of the last button. Note, that to use this method, your button sprites must be a group of numbers in series. To clarify, for example: 1,2,3,4,5 or 20,21,22,23,24. This way, the for next loop just counts up through the sprite numbers.

Within the for next loop, you check the mouse against the dimensions of each sprite image, by using their x and y coordinates along with their heights and widths. So to say, if the mouse is to the right of its x coordinate, and below its y coordinate, and to the left of its right side(x coordinate + sprite width), and above its bottom side(y coordinate + sprite height), then the mouse is within the sprite.

Example:


Also, if you are not using sprites, but some other form of displaying the buttons onto the screen, then you can use this same method by checking the values in an array.

Example:


If your not using sprites, the last method I prefer to you.


+NanoBrain+
Diablo 98188
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: In front of my computer.
Posted: 24th Jul 2005 03:39
Thank you all, TK, your method makes the most sense to me so i will use that. Now, i just needa learn to draw good so i can make the gui ^_^

"May the fires of the underworld burn you"
- ME ^_^
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 24th Jul 2005 08:43

Login to post a reply

Server time is: 2025-05-22 13:29:13
Your offset time is: 2025-05-22 13:29:13