Sign in to follow this  
In_Yack_Mode

Checking mouse position [Allegro] SOLVED

Recommended Posts

In_Yack_Mode    160
How do you go about checking the mouse postion? This is what I am trying to use. It is not complete yet but I think it should check if the mouse is over the axe and the left button is pressed, then equip draw the axe equipped man. But in my program it draws him no matter what. Have you ever heard of this happening? If so how can it be fixed? This is the source code:
if(mouse_x > 335 && mouse_y > 382 && mouse_b & 1)
            {
       	       equip_state = 1;	   
            }
if(equip_state == 1)
            {
               draw_sprite(buffer, manwaxe, man_x, man_y);
            } 


[Edited by - In_Yack_Mode on November 25, 2008 4:07:30 PM]

Share this post


Link to post
Share on other sites
Gage64    1235
Do you ever set equip_state to 0?

Also, I think you need more checks on the mouse coordinates, e.g.:

if(mouse_x > 335 && mouse_y > 382 && mouse_x < 500 && mouse_y < 600 && (mouse_b & 1))

Notice that I also added extra parenthesis around the last check. I think this is needed because of operator precedence, but I'm not sure.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this