use clamp

This commit is contained in:
Corwin 2024-04-06 02:45:54 +01:00
parent 0d609f6d4a
commit 559b53456f
No known key found for this signature in database

View file

@ -390,8 +390,7 @@ impl CursorState {
let mut new_x = current_x.saturating_add_signed(lr as isize).max(1);
let new_y = current_y
.saturating_add_signed(ud as isize)
.max(1)
.min(PLAY_AREA_HEIGHT - 2);
.clamp(1, PLAY_AREA_HEIGHT - 2);
if new_x == PLAY_AREA_WIDTH - 1 {
new_x = new_x.min(PLAY_AREA_WIDTH - 2);