Patch from Lee Dowling to implement mouse control in Sokoban, along

pretty much the same lines as Cube and Inertia.

[originally from svn r8301]
This commit is contained in:
Simon Tatham
2008-11-16 15:47:55 +00:00
parent 33be388d41
commit b2f1b324fe

View File

@ -1044,7 +1044,7 @@ int move_type(game_state *state, int dx, int dy)
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
int x, int y, int button) int x, int y, int button)
{ {
int dx, dy; int dx=0, dy=0;
char *move; char *move;
/* /*
@ -1071,9 +1071,23 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
dx = -1, dy = +1; dx = -1, dy = +1;
else if (button == (MOD_NUM_KEYPAD | '3')) else if (button == (MOD_NUM_KEYPAD | '3'))
dx = +1, dy = +1; dx = +1, dy = +1;
else if (button == LEFT_BUTTON)
{
if(x < COORD(state->px))
dx = -1;
else if (x > COORD(state->px + 1))
dx = 1;
if(y < COORD(state->py))
dy = -1;
else if (y > COORD(state->py + 1))
dy = 1;
}
else else
return NULL; return NULL;
if((dx == 0) && (dy == 0))
return(NULL);
if (move_type(state, dx, dy) < 0) if (move_type(state, dx, dy) < 0)
return NULL; return NULL;