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.

Newcomers DBPro Corner / Whats wrong with my button?

Author
Message
Purplepickle
13
Years of Service
User Offline
Joined: 4th Jun 2011
Location: Between hopeless and needs improvement..
Posted: 13th Aug 2011 21:00

whats wrong with my button
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Aug 2011 21:18 Edited at: 13th Aug 2011 21:18
TEXT WIDTH() and TEXT HEIGHT() are two words. You also only have one ENDIF when you need two (because you have two IF statements without a THEN) and it cannot be outside of a DO/LOOP. It's easier to do the x2,y2 calculation once outside of the DO/LOOP than doing it every loop.



Purplepickle
13
Years of Service
User Offline
Joined: 4th Jun 2011
Location: Between hopeless and needs improvement..
Posted: 15th Aug 2011 01:54
Hey thank you, you don't have to write it out but how would I make a button for the other string variables? Would I put those in the same do loop?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Aug 2011 05:23
Yeah it's basically the same way. But you don't have to use variables. You can use the actual numbers for the x and y coordinates (especially if you don't allow the user to change resolutions).

I didn't do it above but usually you want to put the MOUSECLICK() check before the mouse coordinate checks because if you don't want to add any mouseover effects (like buttons changing colors) there's no need to check every box unless the user presses a mouse button.

Psuedo-code:


Purplepickle
13
Years of Service
User Offline
Joined: 4th Jun 2011
Location: Between hopeless and needs improvement..
Posted: 15th Aug 2011 22:28
Thanks I have this all worked out, but the buttons are conflicting.

The BOB button goes to the start, (Which it should)
And so do all of the rest excluding the credit button which does what it is supposed to.

Thank you for all of the help.


Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Aug 2011 10:59 Edited at: 16th Aug 2011 11:04
It's probably because you're still adding and subtracting the coordinates rather than the straight variables. You only need to use x1,y1,x2,y2... there's no need to add to and/or subtract from the variables when checking for the coordinates because their fine by themselves.

Run this code of your first button check and notice the color differences. The red area is where your code was checking for the mouse click... the green area is where it should be.



When checking for mouse coordinates it's always best to keep them the way a box is drawn because that's basically what your checking for is an imaginary box (you have x1,x2,y1,y2 which should be like a box which is x1,y1,x2,y2).

A box is drawn like this:
Upper left corner x coordinate (x1)
Upper left corner y coordinate (y1)
Lower right corner x coodrinate (x2)
Lower right corner y coordinate (y2)


If you haven't seen it yet check out TDKs Tutorials to learn the basics of Darkbasic:
http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Login to post a reply

Server time is: 2024-11-22 18:31:00
Your offset time is: 2024-11-22 18:31:00