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 / Need help making GUI

Author
Message
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 16th Jul 2005 06:12
Hi,

I need help to make GUI functions.
I can make buttons, no problem, but say I want to make two radio buttons, and I click one of them, it clicks both of them.
The same thing happens if I try to make sliders, text boxes, check boxes etc... What kind of functions could I use to stop this from happening?

Thanks in advance

Your signature has been erased by a mod because it's larger than 600x120...
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 16th Jul 2005 06:57
I've helped on this a similar problem to this before.
You've not posted any code, so I can't say for sure,
but the problem this other guy had was that he used the a set of varibles for one box that changed the colour and size of the box. The problem was that this set of varibles was used for all the boxes, so when he clicked one box it appeared all the boxes were being selected - he needed to use a set of arrays.
You haven't stated whether you are drawing your buttons, or using sprites?
I would use arrays or seperate varibles for each button. But without seeing your code I can't say anymore. Or suggest a fix.
Have you got your sliders working? I have some code if you haven't.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 16th Jul 2005 08:36
Ahh, I see your point.. Now I know how I'm doing it wrong, if you could send me your code for the sliders then that should answer alot of my questions, if I still have any questions left I'll post here with some code..

Your signature has been erased by a mod because it's larger than 600x120...
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Jul 2005 02:29
oh man... my buttons are doing it too now! I really need help

Your signature has been erased by a mod because it's larger than 600x120...
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 17th Jul 2005 04:02
Can you post your code - that would really help!
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Jul 2005 04:05 Edited at: 17th Jul 2005 04:05
Alright, here's how you call the function




and here's the actual function


Your signature has been erased by a mod because it's larger than 600x120...
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 17th Jul 2005 04:18
Ok, the slider code:
Bear in mind that I use a datum set of co-ordinates that change when a mode change is selected.



This allows me to alter the volume setting for my game, the principal is there you just need to adapt the code for your game.
At the end of the day all you are doing is creating an area that sees if the mouse is selecting the slider and move that slider to the mouse position. If you keep the mouse button pressed and move around within the defined area the slider will follow.
Hope this helps!
Any Q's please fire away!
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 17th Jul 2005 04:46
Ok,
1. Don't bother with using # for your 2D Co-ords, they are exact numbers anyway.

2. You need to use arrays.
a. DIM btest$ ( ? ) : DIM bux( ? ) : Dim buy( ? ) : Dim colour( ? ) : Dim i1( ? ) : Dim i2( ? ) : Dime i3( ? )

Each button will have its own label and X & Y Co-ordinate, colour and sprite number.

3. Use sprites instead of images, this will make it easier for you to show and hide - remember to print them all first and then hide them all at the start of your program.

i.e. Sprite <sprite number>,bux( ? ),buy( ? ),<image number>
Then just : Hide Sprite <sprite number>
Or : Show Sprite <sprite number>
Note that the last sprite printed is the one on top that is how the order is worked out.

4. You have your ink colour set to black? I assume this is mean't to be? In any case have that as an array as well - colour( ? )


So:


All the buttons have their own values now, and individuality.
This should work, I haven't tried it, but please let me know what happens
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Jul 2005 05:02 Edited at: 17th Jul 2005 05:04
hmm, i havent tried it, but wont each button need a new array thing, like btext$( ? ), what would i replace the q mark with, would this mean that i'd have to make a function for every button, or when i call the function do i use an array?

edit: never mind, ui forgot to read the thing at the bottom

Your signature has been erased by a mod because it's larger than 600x120...
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Jul 2005 05:36
hmm, still wont work, ok, let me explain the things to you

here the code to call the function


and here is the actual function


btext$(?) - text for sprite
bux(?) / buy(?) - positions
i1 / i2 /i3 - images for sprites, the not the actual sprites themselves,

but it still doesnt work, it just says "function declaration has unknown parameter", and i cant see it...
i think its cause im using arrays in the function..

Your signature has been erased by a mod because it's larger than 600x120...
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 17th Jul 2005 06:28
Have you actually set up your arrays? You haven't mentioned it.
i.e.
Dim btext$(4):for l=1 to 4:read btext$(l):next l
Data "button1","button2","button3","button4"

and the same for the other arrays.

Also don't initalise your sprites in the function, do it near the begining then hide them, that way you can show and hide the sprites on demand.
I don't think you can use a varible like i1 or i2 or i3 anyway - at least other Basics won't let you, try ione, itwo and ithree.

When you call the function, just use button(btext$(b),bux(b),buy(b),ione,itwo,ithree). That way all varibles have a meaning.
Hope this helps you better!
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Jul 2005 07:34
man, this doesn't work at all, you cant even see them, ill tell you what, what if i send you the images for the buttons and you can put together a function for me and them i might get a clearer understandning of what your talking about...

P.S. remember to make more than one button so that I can make sure they're not all pressed..

Your signature has been erased by a mod because it's larger than 600x120...

Attachments

Login to view attachments
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 17th Jul 2005 15:48
Ok, Done!
It works, only thing is the text - I'm not sure how to bring it to the front - if you do can you let me know please.
I was wrong about the arrays in the function, you can call a function using arrays within the command, but the actual function has its own 'Local' varibles - you'll see the difference in the code anyway.

Attachments

Login to view attachments
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Jul 2005 20:45
ok, looks cool apart from that text thing, but atleast ive learned how to make separate buttons and stuff..thanks alot

P.S. why instead of using 'do / loop' do you do 'start: / goto start' , just wondering

Your signature has been erased by a mod because it's larger than 600x120...
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 18th Jul 2005 20:56
What can I say... old habits die hard. I used to program a lot on the 8 bit machines, do & loop didn't exist then.

Login to post a reply

Server time is: 2025-05-22 19:50:26
Your offset time is: 2025-05-22 19:50:26