mousehit()

Blitz3D Forums/Blitz3D Beginners Area/mousehit()

po(Posted 2003) [#1]
I am making a small game that requires you click certain options, I want to make it so I can click cetain lines of text and do something.
I guess what I am really asking is how do you use X and Y coordinates with the mousehit() command?
I have tried: If MouseHit(1), 400,365 Then
But that doen't work :(


ronbravo(Posted 2003) [#2]
try mousex() and mouseY() these return the current position of the mouse.


po(Posted 2003) [#3]
So I would put something like:
If MouseX(400), MouseY(300) Then
But I don't think that's right.


Warren(Posted 2003) [#4]
No, they return the mouse position to you. So something like ...

if MouseX() = 400 And MouseY() = 300


... would work.


Neo Genesis10(Posted 2003) [#5]
Here's a quick code example showing how you could put it together (just a guideline).

point = CreateImage(1,1)

...

If MouseHit(1)
	If ImagesOverlap(point, MouseX(), MouseY(), menu_item, 400, 300)
		Do_menu_item()
	Endif
EndIf



jfk EO-11110(Posted 2003) [#6]
Or even simpler:

if mousehit(1)=1 and mousex()=400 and mousey()=300 then
 print "whatever"
endif



Neo Genesis10(Posted 2003) [#7]
JFK: The reason I gave that example is because is EXCEEDINGLY hard to get pixel perfect accuracy using MouseX and MouseY. That would require the user to very carefully move the mouse and click.


jfk EO-11110(Posted 2003) [#8]
Although he asked for this - I agree. To help the User he might add the following:

movemouse 400,300
Print "Now click, hurry!"
;)


GfK(Posted 2003) [#9]
Try this.


po(Posted 2003) [#10]
I got the mouse button thing sorted out now, thenks you guys.