Coin
2005.08.26, 06:58 PM
I am trying to make a game that scrolls when you drag the board, so if you drag down say the board scrolls up, so the board comes with the mouse when you are dragging.
When you drag the board, the bottom left side of the board jumps too where the mouse is and it drags like i want it to, how can keep it from jumping to the mouse?
the math is simple here is my drag method.
- (void)mouseDragged:(NSEvent *)event
{
NSPoint loc = [event locationInWindow];
int x = loc.x;
int y = loc.y;
mainCamera.y = y;
mainCamera.x = x;
[self setNeedsDisplay:YES];
}
my drawing method does glTranslatef(mainCamera.x, mainCamera.y, 0); right after the glLoadIdentity
what is the math i have to do to mainCamera?
When you drag the board, the bottom left side of the board jumps too where the mouse is and it drags like i want it to, how can keep it from jumping to the mouse?
the math is simple here is my drag method.
- (void)mouseDragged:(NSEvent *)event
{
NSPoint loc = [event locationInWindow];
int x = loc.x;
int y = loc.y;
mainCamera.y = y;
mainCamera.x = x;
[self setNeedsDisplay:YES];
}
my drawing method does glTranslatef(mainCamera.x, mainCamera.y, 0); right after the glLoadIdentity
what is the math i have to do to mainCamera?