• Advertisement
Sign in to follow this  

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

This topic is 1583 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
Sign in to follow this  

  • Advertisement