Making A Button

Blitz3D Forums/Blitz3D Programming/Making A Button

Link(Posted 2008) [#1]
yo! I'm making a game called Ire and i needed to know REALLY BADLY if anyone knows how to make it to where my cursor (which is an image following my mouse's x and y) could click on another image and start an action (i dont mind what,you could just make it exit if you want).
___________________________________________________________


Ross C(Posted 2008) [#2]
Ok, below should help you. It takes the mousex() and mousey() co-ord, with a width and height of 1, to give the point/cursor an action point. Depending on your image this might not be good enough. Depends on what part of the cursor you want to actually do the selecting.

Anyway, look at the rectsoverlap command. Takes a first x,y cord then first width, and checks for overlaps with a second x,y and height and width. The If checks first for a keypress THEN checks for an overlap.

If Mousehit(1) then ; if left click
   ; BELOW \/ if the mouse co-ords, overlap the images dimensions (NOT pixel perfect)
   If rectsoverlap(mousex(),mousey(),1,1 , image_x,image_y,imagewidth(image),imageheight(image) ) then
      ;Perform action here
   End if
End if



Ross C(Posted 2008) [#3]
Little tip, to, making a MMORPG is extremely tough work. Might want to learn some of the basics first :o) good luck


Link(Posted 2008) [#4]
yeah, i know...lol(?)


dude, thanks!
it took a little tweaking because i was trying to use the image as a sprite so i could make an effect where i make my camera move backwards after a selection and they disappear through fog but i can work around that, ive been trying to get this for months!!! txs!




hey, just one more question, do you know how to make the image stop flickering? its doing that because of the flip command but i cant get rid of it or else i wont see my pointer. any suggestions?


Ross C(Posted 2008) [#5]
I assume your using double buffering? If not, then you should be :o)

your loop should, if using 2d look like so:

LOOP

  Cls

  draw_stuff
  draw_pointer
  flip

END LOOP


That's if your doing 2d. If your doing 3d, i have no idea. You can post the code of your main loop if you wish.


mtnhome3d(Posted 2008) [#6]
the flickering problem could be a z-order issue.
if you've got an image thats exactly on another image and they have the same z coordanate then you will get this problem.


Link(Posted 2008) [#7]
k, txs. i just figured it out. for some reason, where i put the flip affects how it reacts (ill have to come back to it)


Ross C(Posted 2008) [#8]
Flip should be right at the end of your loop.