I'm trying to write a function that keeps the mouse restrained to the game window- not that big of a problem. However, I'm getting some funky behavior from dbPositionMouse()- here's what I'm trying to do:
void restrainMouse(){
int xPos, yPos, xMove, yMove = 0;
xMove = dbMouseMoveX();
yMove = dbMouseMoveY();
xPos = dbMouseX(); - xMove;
yPos = dbMouseY(); - yMove;
dbPositionMouse(xPos, yPos);
dbText(0,0, dbStr(xPos));
dbText(0,15, dbStr(yPos));
}
When I call this from my game loop, the mouse shoots straight to the bottom-right corner of the screen! The "debug" outputs show that the "xPos" and "yPos" variables are both increasing extremely quickly. When I replace the xPos and yPos paramaters in dbPositionMouse() with dbMouseX(), and dbMouseY(), the behavior is the same. (Of course, "dbPositionMouse(dbMouseX(), dbMouseY())" is redundant, but it shouldn't be pushing the mouse in to the corner).