Jump to content
  • Advertisement
Sign in to follow this  
Hussain Murtaza

When do you get Mouse.getstate().X or Y as negative?

This topic is 2129 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

I am creating a game in which I use a function:

int x()
{
    int px = 100;
    int pxend = 128;
    int xx = 0;
    for (int i = 0; i < 6; i++)
    {
        l = Mouse.GetState().X;
        if (l> px && l < pxend)
        {
            xx = px;
            break;
        }
        else
        {
            px += 128;
            pxend += 128;
        }
    }
    return xx;
}

And:

int y()
{
    int px = 100;
    int pxend = 128;
    int xx = 0;
    for (int i = 0; i < 4; i++)
    {
        l = Mouse.GetState().X;
        if (l > px && l < pxend)
        {
            xx = px;
            break;
        }
        else
        { 
            px += 128;
            pxend += 128;
        }
    }
    return xx;
}

 

But when I debug I get value a l as negative even though the debug is initiate after a click on theGameWindow screen. Sometimes it works fine sometime does not. I dont know why does it give me negative value. And when I used them with my Rectangle i get Rectangle.X and Rectangle.Y as0.

Edited by rip-off
Formatting

Share this post


Link to post
Share on other sites
Advertisement

Please use [[size="1"]code] and [[size="1"]/code] tags, or the "code" tool in the WYSIWYG editor when pasting source code.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!