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 / its just a button but its so frustrating (to me)

Author
Message
MASTER OF PUPPETS
20
Years of Service
User Offline
Joined: 9th Jun 2004
Location: Trapped Under Ice
Posted: 7th Jul 2005 17:14
IM TRYING TO MAKE A BUTTON FUNCTION IN DBC. I CAN ANIMATE THE BUTTON AND ADD A SOUND TO IT WHEN CLICKED BUT I CANT LOAD MULTIPLE BUTTONS BECAUSE THEY ALL GET CLICKED EVEN WHEN I JUST CLICK ONE OF THEM. IM POSTING MY CODE SO YOU CAN SEE WHAT I MEAN. WILL SOMEBODY PLEASE SHOW ME THE PATH TO MY SINGLE BUTTON CLICK SALVATION.

MY GOAL IS TO HAVE ONE FUNCTION THAT I CAN ACCESS MORE THAN ONCE BUT IT ONLY CLICKS ONE BUTTON.

MAYBE I COULD NUMBER THE BUTTONS IN THE FUNCTIONS VARIABLES!?!
BUT I DONT KNOW HOW BECAUSE IM DUMB...

METALLICA!!!

metal is not music but a way of life...all hail to the reigning king METALLICA!!!
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 7th Jul 2005 17:49
After reading through your code, I can only suggest this:
You are using the same varibles ( CHWC & CXY) that colour and offset one box for all your boxes, so it would appear that all boxes are being selected.
Perhaps a DIM CHWC(4)IM CXY(4) is needed?
Each box now has its own CHWC & CXY

Here is what I think your program include:
DIM BUTTON$(4)IM CHWC(4)IM CXY(4)
FOR L=0 TO 4:READ BUTTON$(L):READ CHWC(L):READ CXY(L):NEXT L
DATA "BUTTON 1", ;- whatever chwc and cxy are meant to be and repeat this line for the other four buttons.

Your Data will now be set for all four buttons
Include into your DO/LOOP:

FOR L=0 to 4
toolbox (10,L*50,BUTTON$(L))
NEXT L

Everytime the function is called the Y axis of the box is L * 50 and a different string is printed each time.

Inside your function include (L) for all your CHWC and CXY varibles and it should work. Please let me know if this works. As I haven't tried it out on my DBC.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Jul 2005 19:34
There's something very weird with your code:



Anyway, I'll try to code such a function for you...

Immunity and Annihalation makes Immunihalation...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Jul 2005 19:51
okay, i've done it:



Immunity and Annihalation makes Immunihalation...
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 7th Jul 2005 22:04
Please note the smileys mean : D not
- see what i mean!?
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 7th Jul 2005 22:38
I think his capitals scared him away.


Current Projects: SHADE - Game Maker | Mecho - TGC Puzzle Entry | Halo Physics Engine | COLD - Polygonal Collision Detection
MASTER OF PUPPETS
20
Years of Service
User Offline
Joined: 9th Jun 2004
Location: Trapped Under Ice
Posted: 8th Jul 2005 04:59
thanks for the help now i can sleep LOL
i really do appreciate it though

metal is not music but a way of life...all hail to the reigning king METALLICA!!!
Briere
20
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 9th Jul 2005 01:13
ahh, i wanted to help out a fellow metallifan, but im too late!!!

Formerly The Fixxer
http://www.xiemsoft.cjb.net
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 12th Jul 2005 03:48
I'm not going to say anything about caps lock, you've already learnt the lesson.

More importantly, always try and make your code *READABLE* if you're trying to get somebody else to debug it.

Indentation, blank lines (so as to keep 'clumps' of code together), and comments are all tools that'll help people actually bother to read your code.

Not just you, but you included .. if you see what I mean. Which you probably don't.

How's my typing? Phone 0800-GO-TO-HELL
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 12th Jul 2005 07:43
The code is fine. If you are fluent in programming, no-one would have trouble reading that code. Its not exactly long is it?
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 12th Jul 2005 09:53 Edited at: 12th Jul 2005 09:55
Actually, you may not want to hear this, but I have like just written a bunch of functions in DBC for buttons and a tutorial on them. There's like five functions in total, I'll be putting the up soon. If you want, you can make functions too, and that way nothing will be left out. I'll try to get them up on the net soon and the tutorial. The tutorial is already written and here's a list of the functions that are already done:

CreateButton(Id,X1,Y1,X2,Y2,ClickType,Delay) - Makes a button
CheckButton(Id) - Check to see if the user is clicking a certain button
CheckButtons() - Returns a 1 if any button is being clicked
ClearButton(Id) - Gets rid of a certain button
ClearButtons() - Get rid of all the buttons

All the button data is stored in the project's folder in a file called Button.dat. I'll put them up soon.

Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 12th Jul 2005 18:04
Probably the quickest way to do a button, which I have used for my game, is the use of just two sprites. You print both of them to the screen, and then hide one of them, and when the mouseclick()=1 and the mouse is over the co-ordinates of the button you and then 'swop' over the sprites until the mouseclick() returns a 0 and then swop back.
A bit off topic but maybe a useful tip for one of the last things you may implement into your game the use of datum co-ords for all sprites & buttons for mode changes, that way you only alter one set of varbiles, and everything else will change as all other varibles look at the datum.
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 14th Jul 2005 04:16 Edited at: 14th Jul 2005 04:36
Ok, I haven't got the functions and stuff up on my site, but I'll just post them here for now. Here they are:

Useful function for creating an outline of a button


Creates a button:


Checks to see if a certain button is being clicked or not:


Returns a value of 1 if any button is being clicked, else returns 0


Clears all button data:


You probably should put these functions in a seperate .dba file and use the #Include command to attach them to your main .dba file. I've already written a tutorial on this, but I need to update it first. I'll put the functions, tutorial, and samples up on my site soon, but I don't have time right now.

One last thing.......METALLICA!

Login to post a reply

Server time is: 2025-05-23 00:53:16
Your offset time is: 2025-05-23 00:53:16