cursor wraps around

wrap-around
Felix Pankratz 2 years ago
parent dc2c8d51ef
commit cf138cd9be

@ -407,25 +407,25 @@ int32_t minesweeper_app(void* p) {
case InputKeyUp: case InputKeyUp:
minesweeper_state->cursor_y--; minesweeper_state->cursor_y--;
if(minesweeper_state->cursor_y < 0) { if(minesweeper_state->cursor_y < 0) {
minesweeper_state->cursor_y = 0; minesweeper_state->cursor_y = PLAYFIELD_HEIGHT - 1;
} }
break; break;
case InputKeyDown: case InputKeyDown:
minesweeper_state->cursor_y++; minesweeper_state->cursor_y++;
if(minesweeper_state->cursor_y >= PLAYFIELD_HEIGHT) { if(minesweeper_state->cursor_y >= PLAYFIELD_HEIGHT) {
minesweeper_state->cursor_y = PLAYFIELD_HEIGHT-1; minesweeper_state->cursor_y = 0;
} }
break; break;
case InputKeyRight: case InputKeyRight:
minesweeper_state->cursor_x++; minesweeper_state->cursor_x++;
if(minesweeper_state->cursor_x >= PLAYFIELD_WIDTH) { if(minesweeper_state->cursor_x >= PLAYFIELD_WIDTH) {
minesweeper_state->cursor_x = PLAYFIELD_WIDTH-1; minesweeper_state->cursor_x = 0;
} }
break; break;
case InputKeyLeft: case InputKeyLeft:
minesweeper_state->cursor_x--; minesweeper_state->cursor_x--;
if(minesweeper_state->cursor_x < 0) { if(minesweeper_state->cursor_x < 0) {
minesweeper_state->cursor_x = 0; minesweeper_state->cursor_x = PLAYFIELD_WIDTH-1;
} }
break; break;
case InputKeyOk: case InputKeyOk:

Loading…
Cancel
Save