
-----------------------------------
PesticideUse
Thu Aug 21, 2008 7:06 pm

Help Making Buttons
-----------------------------------
Hey, I've searched a bit for a good tutorial  on how to make buttons but haven't really found one.

it was recently suggested that i add buttons to my games and i believe that's a good suggestion.

i can use mousewhere, but don't want to have to check that "mx" and "my" are inside a box of coordinates around the button every time i click, for my games that could take a lot of time to put in... whatdotcolor could be used with mx and my but again that could take a bit of work, i would like a simple way to add the button into my game.

if anyone can suggest a good tutorial or help me out thank you :)

-----------------------------------
michaelp
Thu Aug 21, 2008 7:31 pm

RE:Help Making Buttons
-----------------------------------
http://compsci.ca/v3/viewtopic.php?t=3583

It was in the Turing Walkthrough...

-----------------------------------
PesticideUse
Thu Aug 21, 2008 7:52 pm

Re: Help Making Buttons
-----------------------------------
Thanks :) , didnt use the GUI thing cuz im totally clueless when it comes to that lol but i went the the walkthrough and found some stuff

-----------------------------------
michaelp
Thu Aug 21, 2008 8:25 pm

RE:Help Making Buttons
-----------------------------------
Just remember to Search next time.
And I didn't even make that turing walkthrough thing a link, that's sweet! :P

-----------------------------------
PesticideUse
Thu Aug 21, 2008 9:43 pm

Re: Help Making Buttons
-----------------------------------
i did search, but not in the tutorial part... duh lol

-----------------------------------
SNIPERDUDE
Thu Aug 21, 2008 10:24 pm

RE:Help Making Buttons
-----------------------------------
Yea.  The Turing GUI really isn't that good, but it is a good simple start.  Check out my package I made for custom buttons, you might like it.

http://compsci.ca/v3/viewtopic.php?p=167643#167643

And yes, anytime you mention the Turing Walkthrough it will auto link it for you! :D

-----------------------------------
PesticideUse
Thu Aug 21, 2008 10:30 pm

Re: Help Making Buttons
-----------------------------------
Very cool, probably wont put that in anything im working on now, but maybe one of my future projects :D

-----------------------------------
SNIPERDUDE
Thu Aug 21, 2008 10:45 pm

RE:Help Making Buttons
-----------------------------------
No prob.  :D
Just remember to give the proper credit...

-----------------------------------
Insectoid
Fri Aug 22, 2008 10:28 am

RE:Help Making Buttons
-----------------------------------
If all your buttons have the same X values, then you can check once for the X and then check what the mouse's Y value is. 


if mousex > X1 and mousex < X2 and button = 1 then
    if mousey > button1y1 and mousey < button1y2 then
        %do some stuff
    elsif mousey > button2y1 and mousey < button2y2 then
        %do other stuff
    end if
end if


This way you save a lot of code (I once had 12 or so buttons in a column, I saved a lot of time & space this way).

-----------------------------------
PesticideUse
Sat Aug 23, 2008 7:38 pm

Re: Help Making Buttons
-----------------------------------
will do sniperdude  :) 
and thank you for the pointer insectoid i didnt think of that :)

-----------------------------------
SNIPERDUDE
Sat Aug 23, 2008 7:49 pm

RE:Help Making Buttons
-----------------------------------
If you want to compact Insectoid's code; if all of your buttons are equally spaced you can use a for loop to check the coordinates.

-----------------------------------
CodeMonkey2000
Sun Aug 24, 2008 12:25 pm

RE:Help Making Buttons
-----------------------------------
Surprised that no one linked to [url=http://compsci.ca/v3/viewtopic.php?t=10904]this.

That's a solid introduction to classes, and object oriented programming. You probably should read all three parts, but the intro has a custom made button class.
