intravenous
changeset 8:0f305fc0b548
fixed the mouse warping in low framerates
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 22 Apr 2012 07:15:28 +0300 |
parents | 3fae5eb6a411 |
children | 90af225f469a |
files | src/game.cc |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/src/game.cc Sun Apr 22 06:39:23 2012 +0300 1.2 +++ b/src/game.cc Sun Apr 22 07:15:28 2012 +0300 1.3 @@ -150,6 +150,8 @@ 1.4 prev_y = y; 1.5 } 1.6 1.7 +#define EDGE_PIXELS (win_ysz / 4) 1.8 + 1.9 void game_input_mmotion(int x, int y) 1.10 { 1.11 int dx = x - prev_x; 1.12 @@ -157,7 +159,8 @@ 1.13 prev_x = x; 1.14 prev_y = y; 1.15 1.16 - if(ignore_next_motion) { 1.17 + if(ignore_next_motion || abs(dx) >= win_xsz / 2 - EDGE_PIXELS || 1.18 + abs(dy) >= win_ysz / 2 - EDGE_PIXELS) { 1.19 ignore_next_motion = false; 1.20 return; 1.21 } 1.22 @@ -165,8 +168,9 @@ 1.23 if(dbg_inside) { 1.24 ship.turn((float)-dx / win_xsz, (float)-dy / win_ysz); 1.25 1.26 - ignore_next_motion = true; 1.27 - glutWarpPointer(win_xsz / 2, win_ysz / 2); 1.28 + if(x < EDGE_PIXELS || x >= win_xsz - EDGE_PIXELS || y < EDGE_PIXELS || y >= win_ysz - EDGE_PIXELS) { 1.29 + glutWarpPointer(win_xsz / 2, win_ysz / 2); 1.30 + } 1.31 } else { 1.32 if(bnstate[0]) { 1.33 dbgcam.input_rotate(10.0 * dx / win_xsz, 10.0 * dy / win_ysz, 0);