• Advertisement
Sign in to follow this  

Checking mouse position [Allegro] SOLVED

This topic is 3376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
Sign in to follow this  

  • Advertisement