Move cursor down when moving cards to maneuvre stacks.

This commit is contained in:
Murilo Pereira 2011-06-01 00:47:58 -03:00
parent 36bc8e7d8e
commit 7c28c40ec3
2 changed files with 13 additions and 4 deletions

View File

@ -44,7 +44,6 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
switch (movement) {
case LEFT:
if (cursor->x > CURSOR_BEGIN_X) {
erase_cursor(cursor);
cursor->x = cursor->x - 8;
if (cursor->y > CURSOR_BEGIN_Y) {
move_cursor(cursor, UP);
@ -54,7 +53,6 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
break;
case DOWN:
if (cursor->y == CURSOR_BEGIN_Y) {
erase_cursor(cursor);
switch (cursor->x - 3) {
case MANEUVRE_0_BEGIN_X:
cursor->y = cursor->y + 7 + length(deck->maneuvre[0]);
@ -82,7 +80,6 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
break;
case RIGHT:
if (cursor->x < 49) {
erase_cursor(cursor);
cursor->x = cursor->x + 8;
if (cursor->y > CURSOR_BEGIN_Y) {
move_cursor(cursor, UP);
@ -92,7 +89,6 @@ void move_cursor(struct cursor *cursor, enum movement movement) {
break;
case UP:
if (cursor->y > 1) {
erase_cursor(cursor);
cursor->y = CURSOR_BEGIN_Y;
}
break;

View File

@ -72,21 +72,25 @@ static void handle_card_movement(struct cursor *cursor) {
return;
case 'h':
case KEY_LEFT:
erase_cursor(cursor);
move_cursor(cursor, LEFT);
draw_cursor(cursor);
break;
case 'j':
case KEY_DOWN:
erase_cursor(cursor);
move_cursor(cursor, DOWN);
draw_cursor(cursor);
break;
case 'k':
case KEY_UP:
erase_cursor(cursor);
move_cursor(cursor, UP);
draw_cursor(cursor);
break;
case 'l':
case KEY_RIGHT:
erase_cursor(cursor);
move_cursor(cursor, RIGHT);
draw_cursor(cursor);
break;
@ -97,6 +101,11 @@ static void handle_card_movement(struct cursor *cursor) {
move_card(origin, destination);
draw_stack(*origin);
draw_stack(*destination);
if (maneuvre_stack(*destination) && length(*destination) > 1) {
erase_cursor(cursor);
cursor->y++;
draw_cursor(cursor);
}
}
unmark_cursor(cursor);
draw_cursor(cursor);
@ -114,21 +123,25 @@ void handle_keyboard_event(int key) {
switch (key) {
case 'h':
case KEY_LEFT:
erase_cursor(cursor);
move_cursor(cursor, LEFT);
draw_cursor(cursor);
break;
case 'j':
case KEY_DOWN:
erase_cursor(cursor);
move_cursor(cursor, DOWN);
draw_cursor(cursor);
break;
case 'k':
case KEY_UP:
erase_cursor(cursor);
move_cursor(cursor, UP);
draw_cursor(cursor);
break;
case 'l':
case KEY_RIGHT:
erase_cursor(cursor);
move_cursor(cursor, RIGHT);
draw_cursor(cursor);
break;